Gke Workload Scaling Troubleshooting
GoogleOfficialPublished by Google
- Skill
- Review and audit
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a systematic, non-interactive diagnostic workflow for troubleshooting GKE HorizontalPodAutoscaler (HPA) failures. It helps identify root causes for common issues such as unknown metrics, failed API calls, misconfigured resource requests, and unexpected scaling behavior. The skill enforces a read-only diagnostics boundary, ensuring that all proposed fixes are presented as reviewable GitOps changes rather than direct live mutations.
What it does
- Analyzes HPA status, conditions, and events to classify scaling failures.
- Diagnoses custom and external metrics pipeline connectivity and availability.
- Identifies missing resource requests that prevent HPA from calculating utilization.
- Detects configuration mismatches between HPA objects and target workloads.
- Troubleshoots scale-to-zero and scale-from-zero logic for GKE 1.37+.
- Provides actionable remediation steps for GitOps-based implementation.
When to use it
- When an HPA reports metrics as unknown or displays FailedGet events.
- When a workload fails to scale up or down despite HPA configuration.
- When custom or external metrics are not being retrieved by the HPA.
- When investigating slow HPA reaction times on large clusters.
- When troubleshooting scale-to-zero issues in supported GKE versions.
Advantages
- Enforces a safe read-only diagnostic boundary to prevent accidental changes.
- Provides clear, branch-based troubleshooting paths for specific error signals.
- Integrates with existing GitOps workflows by proposing manifest-ready corrections.
- Reduces mean time to resolution for complex metrics pipeline issues.
Usage examples
- “My HPA for the frontend deployment is showing unknown for CPU metrics, please help.”
- The agent will inspect the HPA status, verify if the pod spec includes resource requests, and check for metrics pipeline errors.
- “The HPA is not scaling my workload to zero, what is wrong?”
- The agent will verify if the cluster version is 1.37+, check for minReplicas settings, and confirm if external metrics are configured correctly.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/google/gke-workload-scaling-troubleshooting/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip gke-workload-scaling-troubleshooting.zip -d .agents/skills
Documentation by Google
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-scalingskill 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
Parameter Extraction: Extract required context (
project_id,cluster_name,cluster_location,hpa_name,workload_name,workload_namespace) non-interactively from the user prompt, activeSETTINGS.md, or environment defaults:Default
workload_namespacetodefaultif omitted.Infer missing cluster parameters from the active environment (
kubectl config current-contextorgcloud config get-value project).
Cluster Credentials & Fallback Mode:
Attempt credential fetch:
gcloud container clusters get-credentials {cluster_name} --location {cluster_location} --project {project_id}.Fallback / Dry-Run Mode: If the cluster is unreachable, non-existent, or live command execution fails (such as in sandboxed evaluations, dry-run mode, or offline analysis):
Limit retry attempts to avoid resource exhaustion and context overflow.
Immediately present the exact
kubectl/gclouddiagnostic commands for the human operator to run.Synthesize the root-cause analysis and output the proposed GitOps 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 yamlFor 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:
FailedGetScale,FailedComputeMetricsReplicas,Error 400 ... label is not allowed, or fluctuating replicas from competing HPAs → Branch A (Configuration Errors).FailedGetResourceMetric,unable to fetch pod metrics, ormultiple services selecting the same target→ Branch B (Workload & Service Errors).<unknown>custom/external metric,FailedGetExternalMetric/FailedGetCustomMetric, orno known available metric versions found→ Branch C (Metrics API & Data Availability).Conditions all
True/ no errors but the workload won't scale up or down → Branch D (Healthy but Unexpected Scaling).Workload configured with
minReplicas: 0won't scale to or from zero → Branch E (Scale To / From Zero).Correct HPA but slow reaction on a cluster with many HPA objects → 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
FailedGetScale—unable to get the target's current scale: ... "TARGET" not found: thescaleTargetRefdoesn't resolve to an existing scalable workload.Verify the
scaleTargetRefname,kind, andapiVersionexactly match the target workload's metadata.Confirm the target workload exists in the same namespace as the HPA (a missing
-nputs objects indefault, causing a mismatch).The target must be a scalable kind (Deployment, StatefulSet, ReplicaSet) — you cannot autoscale a DaemonSet.
FailedComputeMetricsReplicas—invalid metrics (1 invalid out of 1): the metrictypeandtargetdon't match.If
type: Utilization, the target must beaverageUtilization.If
type: AverageValue, the target must beaverageValue.
unable to fetch metrics from external metrics API: googleapi: Error 400: Metric label: 'LABEL' is not allowed: an invalid key inmetric.selector.matchLabels.Remove or correct the disallowed label; find valid filterable labels in the Cloud Monitoring metric documentation.
Replica count fluctuates / contradictory
SuccessfulRescaleevents from different HPAs: more than one HPA targets the same workload viaspec.scaleTargetRef, and they compete. There is no dedicated condition for this — confirm withkubectl get hpa -n {workload_namespace} -o yamland look for duplicatescaleTargetRefvalues.Consolidate all metrics into one HPA object (it takes the highest of its
spec.metrics) and delete the duplicates.
Branch B: Workload & Service Errors
ScalingActive: False, reasonFailedGetResourceMetric, messageunable to compute the replica count(or a persistentunable 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 aresources.requestsentry for the scaled resource (cpuormemory).Add
resources.requestsfor the scaled resource to every container in the Pod spec (including sidecars). A briefunable to fetch pod metricsright after the metrics server starts is normal and self-heals.
multiple services selecting the same target of HPA_NAME: SERVICE: traffic-based autoscaling requires a one-to-one Service↔workload relationship, but more than one Service's selector matches the workload's Pods.Make the intended Service's selector unique (add a distinct label to the 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.
Is the adapter registered and available?
kubectl get apiservice | grep -E 'NAME|metrics.k8s.io'Expect
v1beta1.custom.metrics.k8s.ioand/orv1beta1.external.metrics.k8s.iowithAVAILABLE: True. IfFalse/missing, the adapter is crashed or misconfigured — inspect its Pod logs in thecustom-metricsorkube-systemnamespace for permission, connectivity, or "metric not found" errors.Query the metrics API directly (bypasses the HPA to test the whole pipeline;
jqoptional):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 .Interpret the result:
Valid JSON with a value → the pipeline works; the fault is in the HPA manifest (metric-name typo or wrong
matchLabels).Error from server (Service Unavailable)→ network isolation is blocking the control plane from reaching the adapter. Add the adapter'stargetPortto the control-plane firewall rule (in addition to the existingtcp:443andtcp:10250). Identify the rule withgcloud compute firewall-rules list --filter="name~gke-{cluster_name}-[0-9a-z]*-master", and also confirm no NetworkPolicy blocks ingress to the adapter Pods.Empty list
[]→ the adapter runs but can't retrieve the metric. Inspect the adapter Pod logs, and confirm in Metrics Explorer that the metric actually exists in the source with the expected name and labels.
unable to fetch metrics from custom metrics API: no known available metric 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 areRunningwith no restarts (kubectl get pods -n custom-metrics,kube-system -o wide), and re-verify the APIServices areAVAILABLE: True. Often transient.googleapi: Error 400: The supplied filter ... will not return any time series: the query is valid but no data matched (different from a value of0) — 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 True and it shows no errors, but scaling doesn't
happen as expected.
Won't scale up — check, in order:
Replica limits:
currentReplicasis already atminReplicas/maxReplicas(see theScalingLimitedcondition); adjust the bounds.Tolerance window: Kubernetes ignores changes while the current/target ratio stays within
0.9–1.1(default 10% tolerance). Example: target 85% CPU, current 93% → ratio ≈ 1.094 < 1.1, so no scale-up. Wait for the metric to move outside the band, or configure a different tolerance.Unready Pods:
Pending/not-ReadyPods are excluded from the calculation — resolve the underlying scheduling/probe issue.Sync delay: a 15–30s delay between threshold crossing and action is normal.
Won't scale down — check, in order:
Multiple metrics: the HPA uses the metric demanding the most replicas, so it won't scale down unless all metrics agree.
Unavailable metric halts scale-down: if any metric goes
<unknown>the HPA conservatively refuses to scale down. Common with rate-based custom metrics that stop reporting at zero traffic. Prefer gauge metrics (for examplenum_undelivered_messages) or make the source publish0during inactivity rather than sending no data.Scale-down stabilization window: the default
behavior.scaleDown.stabilizationWindowSecondsis 300s (5 min). Lower it if scale-down must be faster.
Branch E: Scale To / From Zero (GKE 1.37+)
Scaling a workload to and from zero replicas with HPA (minReplicas: 0) is
supported on GKE 1.37 or later.
Won't scale to zero:
minReplicas: 0must be set.The HPA cannot scale to zero using only
Resource(CPU/memory) metrics — configure at least oneExternalorObjectmetric.With multiple metrics, all must evaluate to zero.
GKE waits the 5-minute scale-down stabilization window at zero demand before going from 1→0.
Any metric showing
<unknown>pauses scale-down (see Branch D).
Won't scale up from zero: run
kubectl describe hpa {hpa_name}and check:Metrics: the value must be
> 0and not<unknown>; if missing, confirm the external source (for example Pub/Sub) is publishing and Cloud Monitoring is receiving.Conditions: a healthy idle state shows
AbleToScale: True,ScalingActive: True,ScaledToZero: True. IfScalingActive: Falsewith reasonScalingDisabledExternalScaleToZeroorScalingDisabledReplicaCountZero, the workload was manually scaled to zero (for examplekubectl scale), which pauses autoscaling. Resume it by scaling the Deployment back to--replicas=1.Cold-start latency from node provisioning can add delay; Capacity Buffers keep standby capacity ready.
Branch F: Slow HPA Recalculation on Large Clusters
If HPAs are correct but react slowly, the cluster may exceed the HPA object count the standard controller keeps within a 15-second recalculation period.
Standard controller: within 15s for up to 300 HPA objects (GKE 1.22+).
Performance HPA profile: within 15s for up to 1,000 HPA objects (GKE 1.31+) or 5,000 HPA objects (GKE 1.33+, where it is enabled by default on eligible clusters).
Enable it on an eligible cluster (this is a cluster mutation — present it for the operator to run, don't execute it):
gcloud container clusters update {cluster_name} \
--location {cluster_location} --project {project_id} \
--hpa-profile=performanceScaling on many metrics per HPA and slow (>~50 ms) custom-metric adapters also lengthen the recalculation period. For visibility into scaling decisions, enable HPA event logging and review the structured HPA decision logs.
Step 3: Propose the GitOps Correction
Enforce the read-only diagnostics boundary: do not apply live mutations. This
includes cluster/manifest changes (kubectl edit, kubectl patch, kubectl apply, kubectl scale, kubectl delete) and Google Cloud / gcloud changes
(cluster updates such as --hpa-profile, and gcloud compute firewall-rules
updates). Instead, present the corrected HorizontalPodAutoscaler, PodSpec
(resources.requests), Service selector, workload autoscaling
configuration, or the gcloud command as a reviewable patch/command to be
applied through the user's GitOps pipeline (for example Config Sync, Argo CD, or
Flux) or by an authorized operator.
References
Files
- ATTRIBUTION.mdAdded by AutoGineer890 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md17.5 KiB
- references/attribution.md1.9 KiB
LICENSE
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs a command-line tool, Needs Node.js
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- Publisher
- Google (Official)
- Source
- google/skills · skills/cloud/gke-workload-scaling-troubleshooting · commit 2194d3b
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google or Google.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download gke-workload-scaling-troubleshooting.zip