{"data":{"slug":"github-google-skills-skills-cloud-gke-workload-scaling-troubleshooting-33b15ecf6248","title":"Diagnose and Resolve GKE HPA Scaling Issues","summary":"Identify and resolve common issues with GKE HorizontalPodAutoscaler (HPA) scaling, including metric errors, slow recalculation, and configuration problems. The deliverable is a detailed analysis and actionable fixes for HPA failures.","url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-workload-scaling-troubleshooting-33b15ecf6248","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-google-skills-skills-cloud-gke-workload-scaling-troubleshooting-33b15ecf6248","markdown_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-workload-scaling-troubleshooting-33b15ecf6248.md","download_url":"https:\/\/skillshunter.net\/skills\/github-google-skills-skills-cloud-gke-workload-scaling-troubleshooting-33b15ecf6248\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Before executing any `gcloud`, REST API, or MCP command, you must read [Usage Attribution](references\/attribution.md). For terminal commands, prefix `gcloud` with `CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:gke-workload-scaling-troubleshooting)\"` and append `agent-skills\/1.0 (skill:gke-workload-scaling-troubleshooting)` to `User-Agent` headers.","instructions":"---\nname: gke-workload-scaling-troubleshooting\nmetadata:\n  version: \"1.0.1\"\n  category: Containers\ndescription: >-\n  Diagnoses GKE HorizontalPodAutoscaler (HPA) failures \u2014 metrics showing as\n  <unknown>, FailedGetResourceMetric \/ FailedGetScale \/ FailedComputeMetricsReplicas\n  events, missing Pod resource requests, custom\/external metrics-pipeline breakage\n  (FailedGetExternalMetric \/ FailedGetCustomMetric, unavailable metrics adapter,\n  control-plane firewall blocking the adapter), HPA that won't scale up or down\n  (tolerance \/ stabilization window \/ unavailable rate metrics), scale-to\/from-zero\n  problems, and slow HPA reaction on large clusters. Use when an HPA isn't scaling a\n  workload as expected or reports metric errors. Don't use for configuring or\n  authoring new HPA\/VPA objects or scaling best practices (see the\n  gke-workload-scaling skill), or for Cluster Autoscaler \/ node-pool sizing.\n---\n\n# GKE Workload Scaling Troubleshooting Skill\n\nUse this skill to systematically diagnose and resolve **HorizontalPodAutoscaler\n(HPA) failures** on GKE \u2014 metrics reported as `<unknown>`, `FailedGet*` events,\nmissing resource requests, custom\/external metrics-pipeline breakage, HPA that\nrefuses to scale up or down, scale-to\/from-zero issues, and slow HPA reaction on\nlarge clusters. This skill operates non-interactively and enforces a read-only\ndiagnostics boundary before proposing manifest or configuration corrections.\n\n> For configuring HPA\/VPA objects and scaling **best practices**, use the\n> `gke-workload-scaling` skill instead. This skill focuses on **failure\n> diagnosis**.\n\n## Attribution\n\n**MUST READ**: Before executing any `gcloud`, REST API, or MCP command, you\nMUST read [Usage Attribution](references\/attribution.md). For commands executed\ndirectly in the terminal (never in generated scripts, Terraform, or user code),\nprefix `gcloud` with\n`CLOUDSDK_METRICS_REQUEST_ATTRIBUTION=\"agent-skills\/1.0 (skill:gke-workload-scaling-troubleshooting)\"`\nand append `agent-skills\/1.0 (skill:gke-workload-scaling-troubleshooting)` to `User-Agent` headers.\n\n## \ud83d\udd0d Diagnosis & Resolution Workflow\n\n### Step 0: Non-Interactive Context Discovery & Dry-Run Fallback\n\n1.  **Parameter Extraction**: Extract required context (`project_id`,\n    `cluster_name`, `cluster_location`, `hpa_name`, `workload_name`,\n    `workload_namespace`) non-interactively from the user prompt, active\n    `SETTINGS.md`, or environment defaults:\n\n    -   Default `workload_namespace` to `default` if omitted.\n    -   Infer missing cluster parameters from the active environment (`kubectl\n        config current-context` or `gcloud config get-value project`).\n\n2.  **Cluster Credentials & Fallback Mode**:\n\n    -   Attempt credential fetch: `gcloud container clusters get-credentials\n        {cluster_name} --location {cluster_location} --project {project_id}`.\n    -   **Fallback \/ Dry-Run Mode**: If the cluster is unreachable,\n        non-existent, or live command execution fails (such as in sandboxed\n        evaluations, dry-run mode, or offline analysis):\n        -   Limit retry attempts to avoid resource exhaustion and context\n            overflow.\n        -   Immediately present the exact `kubectl` \/ `gcloud` diagnostic\n            commands for the human operator to run.\n        -   Synthesize the root-cause analysis and output the proposed GitOps\n            correction based on the reported symptoms.\n\n--------------------------------------------------------------------------------\n\n### Step 1: Inspect the HPA and Classify the Symptom\n\nStart every investigation with `kubectl describe hpa`, then route to the matching\nbranch. The three key sections are **`Metrics`** (an `<unknown>` value means the\nHPA hasn't fetched the metric or the pipeline is broken), **`Conditions`**\n(`AbleToScale`, `ScalingActive`, `ScalingLimited` \u2014 a `False` status marks a\nfailure), and **`Events`** (specific reasons such as `FailedGetScale` or\n`FailedGetResourceMetric`).\n\n**Diagnostic Commands:**\n\n```bash\nkubectl describe hpa {hpa_name} -n {workload_namespace}\nkubectl get hpa {hpa_name} -n {workload_namespace} -o yaml\n```\n\nFor historical events, query Cloud Logging (the HPA events survive after the live\n`Events` list rolls over):\n\n```\nresource.type=\"k8s_cluster\"\nresource.labels.cluster_name=\"{cluster_name}\"\nresource.labels.location=\"{cluster_location}\"\nlogName=\"projects\/{project_id}\/logs\/events\"\njsonPayload.involvedObject.kind=\"HorizontalPodAutoscaler\"\n```\n\nRoute by signal:\n\n-   **`FailedGetScale`, `FailedComputeMetricsReplicas`, `Error 400 ... label\n    is not allowed`, or fluctuating replicas from competing HPAs** \u2192 **Branch A**\n    (Configuration Errors).\n-   **`FailedGetResourceMetric`, `unable to fetch pod metrics`, or `multiple\n    services selecting the same target`** \u2192 **Branch B** (Workload & Service\n    Errors).\n-   **`<unknown>` custom\/external metric, `FailedGetExternalMetric` \/\n    `FailedGetCustomMetric`, or `no known available metric versions found`** \u2192\n    **Branch C** (Metrics API & Data Availability).\n-   **Conditions all `True` \/ no errors but the workload won't scale up or down**\n    \u2192 **Branch D** (Healthy but Unexpected Scaling).\n-   **Workload configured with `minReplicas: 0` won't scale to or from zero** \u2192\n    **Branch E** (Scale To \/ From Zero).\n-   **Correct HPA but slow reaction on a cluster with many HPA objects** \u2192\n    **Branch F** (Slow Recalculation on Large Clusters).\n\n--------------------------------------------------------------------------------\n\n### Step 2: Resolution \u2014 Route to the Matching Branch\n\nBased on the signal you classified in Step 1, jump to **one** of the\nmutually-exclusive branches below (A\u2013F). These are alternatives \u2014 you do **not**\nrun them in sequence. After applying the branch's fix, go to Step 3 to present it\nas a reviewable GitOps change.\n\n#### Branch A: HorizontalPodAutoscaler Configuration Errors\n\n-   **`FailedGetScale` \u2014 `unable to get the target's current scale: ... \"TARGET\"\n    not found`**: the `scaleTargetRef` doesn't resolve to an existing scalable\n    workload.\n\n    -   Verify the `scaleTargetRef` `name`, `kind`, and `apiVersion` exactly\n        match the target workload's metadata.\n    -   Confirm the target workload exists **in the same namespace** as the HPA\n        (a missing `-n` puts objects in `default`, causing a mismatch).\n    -   The target must be a scalable kind (Deployment, StatefulSet,\n        ReplicaSet) \u2014 you **cannot** autoscale a DaemonSet.\n\n-   **`FailedComputeMetricsReplicas` \u2014 `invalid metrics (1 invalid out of 1)`**:\n    the metric `type` and `target` don't match.\n\n    -   If `type: Utilization`, the target must be `averageUtilization`.\n    -   If `type: AverageValue`, the target must be `averageValue`.\n\n-   **`unable to fetch metrics from external metrics API: googleapi: Error 400:\n    Metric label: 'LABEL' is not allowed`**: an invalid key in\n    `metric.selector.matchLabels`.\n\n    -   Remove or correct the disallowed label; find valid filterable labels in\n        the Cloud Monitoring metric documentation.\n\n-   **Replica count fluctuates \/ contradictory `SuccessfulRescale` events from\n    different HPAs**: more than one HPA targets the same workload via\n    `spec.scaleTargetRef`, and they compete. There is no dedicated condition for\n    this \u2014 confirm with `kubectl get hpa -n {workload_namespace} -o yaml` and\n    look for duplicate `scaleTargetRef` values.\n\n    -   Consolidate all metrics into **one** HPA object (it takes the highest of\n        its `spec.metrics`) and delete the duplicates.\n\n--------------------------------------------------------------------------------\n\n#### Branch B: Workload & Service Errors\n\n-   **`ScalingActive: False`, reason `FailedGetResourceMetric`, message `unable\n    to compute the replica count`** (or a persistent `unable to fetch pod\n    metrics`): the HPA computes utilization as a percentage of the container\n    **resource request**, but at least one container in the Pod is missing a\n    `resources.requests` entry for the scaled resource (`cpu` or `memory`).\n\n    -   Add `resources.requests` for the scaled resource to **every** container\n        in the Pod spec (including sidecars). A brief `unable to fetch pod\n        metrics` right after the metrics server starts is normal and self-heals.\n\n-   **`multiple services selecting the same target of HPA_NAME: SERVICE`**:\n    traffic-based autoscaling requires a **one-to-one** Service\u2194workload\n    relationship, but more than one Service's selector matches the workload's\n    Pods.\n\n    -   Make the intended Service's selector unique (add a distinct label to the\n        workload and to that one Service), or tighten the other Services'\n        selectors so they no longer match the workload's Pods.\n\n--------------------------------------------------------------------------------\n\n#### Branch C: Metrics API & Data Availability (Custom \/ External Metrics)\n\nThe custom\/external pipeline is: HPA controller \u2192 Kubernetes metrics API server\n\u2192 metrics adapter (for example `custom-metrics-stackdriver-adapter`) \u2192 metric\nsource (Cloud Monitoring \/ Prometheus). Symptoms are `<unknown>` metric values or\n`FailedGetExternalMetric` \/ `FailedGetCustomMetric` events.\n\n1.  **Is the adapter registered and available?**\n\n    ```bash\n    kubectl get apiservice | grep -E 'NAME|metrics.k8s.io'\n    ```\n\n    Expect `v1beta1.custom.metrics.k8s.io` and\/or\n    `v1beta1.external.metrics.k8s.io` with `AVAILABLE: True`. If `False`\/missing,\n    the adapter is crashed or misconfigured \u2014 inspect its Pod logs in the\n    `custom-metrics` or `kube-system` namespace for permission, connectivity, or\n    \"metric not found\" errors.\n\n2.  **Query the metrics API directly** (bypasses the HPA to test the whole\n    pipeline; `jq` optional):\n\n    ```bash\n    kubectl get --raw \"\/apis\/external.metrics.k8s.io\/v1beta1\/namespaces\/{workload_namespace}\/{metric_name}\" | jq .\n    kubectl get --raw \"\/apis\/custom.metrics.k8s.io\/v1beta1\/namespaces\/{workload_namespace}\/pods\/*\/{metric_name}\" | jq .\n    ```\n\n3.  **Interpret the result:**\n\n    -   **Valid JSON with a value** \u2192 the pipeline works; the fault is in the HPA\n        manifest (metric-name typo or wrong `matchLabels`).\n    -   **`Error from server (Service Unavailable)`** \u2192 network isolation is\n        blocking the control plane from reaching the adapter. Add the adapter's\n        `targetPort` to the **control-plane firewall rule** (in addition to the\n        existing `tcp:443` and `tcp:10250`). Identify the rule with\n        `gcloud compute firewall-rules list --filter=\"name~gke-{cluster_name}-[0-9a-z]*-master\"`,\n        and also confirm no NetworkPolicy blocks ingress to the adapter Pods.\n    -   **Empty list `[]`** \u2192 the adapter runs but can't retrieve the metric.\n        Inspect the adapter Pod logs, and confirm in Metrics Explorer that the\n        metric actually exists in the source with the expected name and labels.\n\n-   **`unable to fetch metrics from custom metrics API: no known available metric\n    versions found`**: a communication breakdown (control plane briefly\n    unavailable during an upgrade\/repair, or the adapter Pods are unhealthy or\n    not registered) \u2014 **not** a problem at the metric source. Check control-plane\n    health\/notifications, confirm the adapter Pods are `Running` with no restarts\n    (`kubectl get pods -n custom-metrics,kube-system -o wide`), and re-verify the\n    APIServices are `AVAILABLE: True`. Often transient.\n\n-   **`googleapi: Error 400: The supplied filter ... will not return any time\n    series`**: the query is valid but no data matched (different from a value of\n    `0`) \u2014 the application wasn't writing the metric during the window. Verify the\n    metric name\/labels match what the app emits, confirm the app had permission\n    and was active, and check the app logs for metric-emission errors.\n\n--------------------------------------------------------------------------------\n\n#### Branch D: Healthy but Unexpected Scaling Behavior\n\nThe HPA's conditions are `True` and it shows no errors, but scaling doesn't\nhappen as expected.\n\n-   **Won't scale up** \u2014 check, in order:\n    -   **Replica limits**: `currentReplicas` is already at `minReplicas` \/\n        `maxReplicas` (see the `ScalingLimited` condition); adjust the bounds.\n    -   **Tolerance window**: Kubernetes ignores changes while the\n        current\/target ratio stays within `0.9`\u2013`1.1` (default **10%\n        tolerance**). Example: target 85% CPU, current 93% \u2192 ratio \u2248 1.094 < 1.1,\n        so no scale-up. Wait for the metric to move outside the band, or\n        configure a different tolerance.\n    -   **Unready Pods**: `Pending`\/not-`Ready` Pods are excluded from the\n        calculation \u2014 resolve the underlying scheduling\/probe issue.\n    -   **Sync delay**: a 15\u201330s delay between threshold crossing and action is\n        normal.\n\n-   **Won't scale down** \u2014 check, in order:\n    -   **Multiple metrics**: the HPA uses the metric demanding the **most**\n        replicas, so it won't scale down unless **all** metrics agree.\n    -   **Unavailable metric halts scale-down**: if any metric goes `<unknown>`\n        the HPA conservatively refuses to scale down. Common with **rate-based**\n        custom metrics that stop reporting at zero traffic. Prefer **gauge**\n        metrics (for example `num_undelivered_messages`) or make the source\n        publish `0` during inactivity rather than sending no data.\n    -   **Scale-down stabilization window**: the default\n        `behavior.scaleDown.stabilizationWindowSeconds` is **300s (5 min)**.\n        Lower it if scale-down must be faster.\n\n--------------------------------------------------------------------------------\n\n#### Branch E: Scale To \/ From Zero (GKE 1.37+)\n\nScaling a workload to and from zero replicas with HPA (`minReplicas: 0`) is\nsupported on **GKE 1.37 or later**.\n\n-   **Won't scale to zero**:\n    -   `minReplicas: 0` must be set.\n    -   The HPA **cannot** scale to zero using only `Resource` (CPU\/memory)\n        metrics \u2014 configure at least one `External` or `Object` metric.\n    -   With multiple metrics, all must evaluate to zero.\n    -   GKE waits the 5-minute scale-down stabilization window at zero demand\n        before going from 1\u21920.\n    -   Any metric showing `<unknown>` pauses scale-down (see Branch D).\n\n-   **Won't scale up from zero**: run `kubectl describe hpa {hpa_name}` and check:\n    -   **Metrics**: the value must be `> 0` and not `<unknown>`; if missing,\n        confirm the external source (for example Pub\/Sub) is publishing and Cloud\n        Monitoring is receiving.\n    -   **Conditions**: a healthy idle state shows `AbleToScale: True`,\n        `ScalingActive: True`, `ScaledToZero: True`. If `ScalingActive: False`\n        with reason `ScalingDisabledExternalScaleToZero` or\n        `ScalingDisabledReplicaCountZero`, the workload was **manually** scaled to\n        zero (for example `kubectl scale`), which pauses autoscaling. Resume it by\n        scaling the Deployment back to `--replicas=1`.\n    -   Cold-start latency from node provisioning can add delay; Capacity Buffers\n        keep standby capacity ready.\n\n--------------------------------------------------------------------------------\n\n#### Branch F: Slow HPA Recalculation on Large Clusters\n\nIf HPAs are correct but react slowly, the cluster may exceed the HPA object count\nthe standard controller keeps within a 15-second recalculation period.\n\n-   Standard controller: within 15s for up to **300 HPA objects** (GKE 1.22+).\n-   **Performance HPA profile**: within 15s for up to **1,000 HPA objects** (GKE\n    1.31+) or **5,000 HPA objects** (GKE 1.33+, where it is enabled by default on\n    eligible clusters).\n\nEnable it on an eligible cluster (this is a cluster mutation \u2014 present it for the\noperator to run, don't execute it):\n\n```bash\ngcloud container clusters update {cluster_name} \\\n    --location {cluster_location} --project {project_id} \\\n    --hpa-profile=performance\n```\n\nScaling on many metrics per HPA and slow (>~50 ms) custom-metric adapters also\nlengthen the recalculation period. For visibility into scaling decisions, enable\nHPA event logging and review the structured HPA decision logs.\n\n--------------------------------------------------------------------------------\n\n### Step 3: Propose the GitOps Correction\n\nEnforce the read-only diagnostics boundary: **do not** apply live mutations. This\nincludes cluster\/manifest changes (`kubectl edit`, `kubectl patch`, `kubectl\napply`, `kubectl scale`, `kubectl delete`) **and** Google Cloud \/ gcloud changes\n(cluster updates such as `--hpa-profile`, and `gcloud compute firewall-rules`\nupdates). Instead, present the corrected HorizontalPodAutoscaler, PodSpec\n(`resources.requests`), Service selector, workload autoscaling\nconfiguration, or the `gcloud` command as a reviewable patch\/command to be\napplied through the user's GitOps pipeline (for example Config Sync, Argo CD, or\nFlux) or by an authorized operator.\n\n## References\n\n-   [Troubleshoot horizontal Pod autoscaling in GKE](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/troubleshooting\/horizontal-pod-autoscaling.md.txt)\n-   [Horizontal Pod autoscaling (concepts, Performance HPA profile & limits)](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/concepts\/horizontalpodautoscaler.md.txt)\n-   [Configure horizontal Pod autoscaling (hpa-profile)](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/horizontal-pod-autoscaling.md.txt)\n-   [View horizontal Pod autoscaling events](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/how-to\/view-horizontalpodautoscaling-events.md.txt)\n-   [Scale to and from zero using HPA](https:\/\/docs.cloud.google.com\/kubernetes-engine\/docs\/tutorials\/scale-to-from-zero-hpa.md.txt)\n-   [Kubernetes HorizontalPodAutoscaler (tolerance & scaling policies)](https:\/\/kubernetes.io\/docs\/tasks\/run-application\/horizontal-pod-autoscale\/)\n","use_cases":["HPA fails to scale up or down due to metric errors","HPA recalculation is slow on large clusters","HPA reports 'FailedGetScale' or 'FailedComputeMetricsReplicas'"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/google\/skills\/blob\/e3c591afe426ea585e4c21799e5199d6d47cd1be\/skills\/cloud\/gke-workload-scaling-troubleshooting\/SKILL.md","source_commit":"e3c591afe426ea585e4c21799e5199d6d47cd1be","license":null,"version":null,"listing_approved_at":"2026-11-17","created_at":"2026-11-16T16:51:31.000000Z","updated_at":"2026-11-17T10:20:00.000000Z","seo_title":"Diagnose GKE HPA Scaling Issues","seo_description":"Troubleshoot GKE HorizontalPodAutoscaler scaling problems with metric errors, slow recalculation, and configuration issues. Get actionable fixes for HPA failures.","seo_keywords":["GKE HPA scaling issues","HPA metric errors troubleshooting","GKE HPA slow recalculation","HPA configuration errors","GKE HPA scaling failure"]}}