Home / Market / gke workload scaling troubleshooting

gke workload scaling troubleshooting

Diagnoses GKE HorizontalPodAutoscaler (HPA) failures — metrics showing as , FailedGetResourceMetric / FailedGetScale / FailedComputeMetricsReplicas events, missing Pod resource requests, custom/external metrics-pipeline breakage (FailedGetExternalMetric / FailedGetCustomMetric, unavailable metrics adapter, control-plane firewall blocking the adapter), HPA that won't scale up or down (tolerance / stabilization window / unavailable rate metrics), scale-to/from-zero problems, and slow HPA

skill★ 255770 dlgithubApache-2.0Install in CosmosUpstream Source

Documentation & Preview

--- name: gke-workload-scaling-troubleshooting metadata: version: "1.0.1" category: Containers description: >- Diagnoses GKE HorizontalPodAutoscaler (HPA) failures — metrics showing as <unknown>, FailedGetResourceMetric / FailedGetScale / FailedComputeMetricsReplicas events, missing Pod resource requests, custom/external metrics-pipeline breakage (FailedGetExternalMetric / FailedGetCustomMetric, unavailable metrics adapter, control-plane firewall blocking the adapter), HPA that won't scale up or down (tolerance / stabilization window / unavailable rate metrics), scale-to/from-zero problems, and slow HPA reaction on large clusters. Use when an HPA isn't scaling a workload as expected or reports metric errors. Don't use for configuring or authoring new HPA/VPA objects or scaling best practices (see the gke-workload-scaling skill), or for Cluster Autoscaler / node-pool sizing.

---

GKE Workload Scaling Troubleshooting Skill

Use this skill to systematically diagnose and resolve HorizontalPodAutoscaler (HPA) failures on GKE — metrics reported as <unknown>, FailedGet* events, missing resource requests, custom/external metrics-pipeline breakage, HPA that refuses to scale up or down, scale-to/from-zero issues, and slow HPA reaction on large clusters. This skill operates non-interactively and enforces a read-only diagnostics boundary before proposing manifest or configuration corrections.

> For configuring HPA/VPA objects and scaling best practices, use the > gke-workload-scaling skill instead. This skill focuses on failure > diagnosis.

Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), 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.

🔍 Diagnosis & Resolution Workflow

Step 0: Non-Interactive Context Discovery & Dry-Run Fallback

  1. Parameter Extraction: Extract required context (project_id,

cluster_name, cluster_location, hpa_name, workload_name, workload_namespace) non-interactively from the user prompt, active SETTINGS.md, or environment defaults:

config current-context or gcloud config get-value project`).

  1. Cluster Credentials & Fallback Mode:

{cluster_name} --location {cluster_location} --project {project_id}`.

non-existent, or live command execution fails (such as in sandboxed evaluations, dry-run mode, or offline analysis):

overflow.

commands for the human operator to run.

correction based on the reported symptoms.

--------------------------------------------------------------------------------

Step 1: Inspect the HPA and Classify the Symptom

Start every investigation with kubectl describe hpa, then route to the matching branch. The three key sections are Metrics (an <unknown> value means the HPA hasn't fetched the metric or the pipeline is broken), Conditions (AbleToScale, ScalingActive, ScalingLimited — a False status marks a failure), and Events (specific reasons such as FailedGetScale or FailedGetResourceMetric).

Diagnostic Commands:

kubectl describe hpa {hpa_name} -n {workload_namespace}
kubectl get hpa {hpa_name} -n {workload_namespace} -o yaml

For historical events, query Cloud Logging (the HPA events survive after the live Events list rolls over):

resource.type="k8s_cluster"
resource.labels.cluster_name="{cluster_name}"
resource.labels.location="{cluster_location}"
logName="projects/{project_id}/logs/events"
jsonPayload.involvedObject.kind="HorizontalPodAutoscaler"

Route by signal:

is not allowed`, or fluctuating replicas from competing HPAs → Branch A** (Configuration Errors).

services selecting the same target` → Branch B** (Workload & Service Errors).

FailedGetCustomMetric, or no known available metric versions found** →

Branch C (Metrics API & Data Availability).

→ Branch D (Healthy but Unexpected Scaling).

Branch E (Scale To / From Zero).

Branch F (Slow Recalculation on Large Clusters).

--------------------------------------------------------------------------------

Step 2: Resolution — Route to the Matching Branch

Based on the signal you classified in Step 1, jump to one of the mutually-exclusive branches below (A–F). These are alternatives — you do not run them in sequence. After applying the branch's fix, go to Step 3 to present it as a reviewable GitOps change.

Branch A: HorizontalPodAutoscaler Configuration Errors

not found**: the scaleTargetRef` doesn't resolve to an existing scalable workload.

match the target workload's metadata.

(a missing -n puts objects in default, causing a mismatch).

ReplicaSet) — you cannot autoscale a DaemonSet.

the metric type and target don't match.

Metric label: 'LABEL' is not allowed**: an invalid key in metric.selector.matchLabels`.

the Cloud Monitoring metric documentation.

different HPAs**: more than one HPA targets the same workload via spec.scaleTargetRef, and they compete. There is no dedicated condition for this — confirm with kubectl get hpa -n {workload_namespace} -o yaml and look for duplicate scaleTargetRef values.

its spec.metrics) and delete the duplicates.

--------------------------------------------------------------------------------

Branch B: Workload & Service Errors

to compute the replica count** (or a persistent unable to fetch pod metrics`): the HPA computes utilization as a percentage of the container

resource request, but at least one container in the Pod is missing a resources.requests entry for the scaled resource (cpu or memory).

in the Pod spec (including sidecars). A brief unable to fetch pod metrics right after the metrics server starts is normal and self-heals.

traffic-based autoscaling requires a one-to-one Service↔workload relationship, but more than one Service's selector matches the workload's Pods.

workload and to that one Service), or tighten the other Services' selectors so they no longer match the workload's Pods.

--------------------------------------------------------------------------------

Branch C: Metrics API & Data Availability (Custom / External Metrics)

The custom/external pipeline is: HPA controller → Kubernetes metrics API server → metrics adapter (for example custom-metrics-stackdriver-adapter) → metric source (Cloud Monitoring / Prometheus). Symptoms are <unknown> metric values or FailedGetExternalMetric / FailedGetCustomMetric events.

  1. Is the adapter registered and available?
    kubectl get apiservice | grep -E 'NAME|metrics.k8s.io'

Expect v1beta1.custom.metrics.k8s.io and/or v1beta1.external.metrics.k8s.io with AVAILABLE: True. If False/missing, the adapter is crashed or misconfigured — inspect its Pod logs in the custom-metrics or kube-system namespace for permission, connectivity, or "metric not found" errors.

  1. Query the metrics API directly (bypasses the HPA to test the whole

pipeline; jq optional):

    kubectl get --raw "/apis/external.metrics.k8s.io/v1beta1/namespaces/{workload_namespace}/{metric_name}" | jq .
    kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/{workload_namespace}/pods/*/{metric_name}" | jq .
  1. Interpret the result:

manifest (metric-name typo or wrong matchLabels).

blocking the control plane from reaching the adapter. Add the adapter's targetPort to the control-plane firewall rule (in addition to the existing tcp:443 and tcp:10250). Identify the rule with gcloud compute firewall-rules list --filter="name~gke-{cluster_name}-[0-9a-z]*-master", and also confirm no NetworkPolicy blocks ingress to the adapter Pods.

Inspect the adapter Pod logs, and confirm in Metrics Explorer that the metric actually exists in the source with the expected name and labels.

versions found: a communication breakdown (control plane briefly unavailable during an upgrade/repair, or the adapter Pods are unhealthy or not registered) — not** a problem at the metric source. Check control-plane health/notifications, confirm the adapter Pods are Running with no restarts (kubectl get pods -n custom-metrics,kube-system -o wide), and re-verify the APIServices are AVAILABLE: True`. Often transient.

series**: the query is valid but no data matched (different from a value of 0`) — the application wasn't writing the metric during the window. Verify the metric name/labels match what the app emits, confirm the app had permission and was active, and check the app logs for metric-emission errors.

--------------------------------------------------------------------------------

Branch D: Healthy but Unexpected Scaling Behavior

The HPA's conditions are `Tr