hpa-debug
Skill235 starsChanged 6 months agoApache-2.0View on GitHub
Diagnose HorizontalPodAutoscaler failures (not scaling, metrics unavailable, target mismatch). Checks HPA status, metrics-server health, and scaling events to identify why autoscaling is not working.
In this repository30 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- kbc/CLAUDE.mdCLAUDE.md
- cluster-eventsSkill
- deployment-rollout-debugSkill
- dns-debugSkill
- gateway-diagnosticsSkill
- http-log-statsSkill
- image-pull-debugSkill
- ingress-debugSkill
- job-debugSkill
- networkpolicy-debugSkill
- node-health-checkSkill
- node-logsSkill
- pod-crash-debugSkill
- pod-pending-debugSkill
- pvc-debugSkill
- quota-debugSkill
- service-debugSkill
- statefulset-debugSkill
- volcano-diagnose-podSkill
- volcano-gang-schedulingSkill
- volcano-job-diagnoseSkill
- volcano-node-resourcesSkill
- volcano-queue-diagnoseSkill
- volcano-resource-insufficientSkill
- volcano-scheduler-configSkill
- volcano-scheduler-logsSkill
- manage-skillSkill
- skill-authoringSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
When a HorizontalPodAutoscaler is not scaling as expected — stuck at min/max replicas, showing <unknown> metrics, or not responding to load …
- Distinctive: line 44
If no pods are found, try:
- Distinctive: line 50
Verify metrics-server is serving data:
- Very specific: line 56
If kubectl top returns error: Metrics API not available, metrics-server is not working.
- Distinctive: line 66
If requests are not set, the HPA cannot calculate utilization percentages.
- Very specific: line 90
Check the reason in kubectl describe hpa:
- Very specific: line 106
If the HPA is stuck at maxReplicas and load is still high, advise the user to increase maxReplicas or investigate why the application needs …
- Distinctive: line 114
Check the events for rapid scale-up/scale-down cycles.
- Distinctive: line 132
Verify the actual pod resource usage:
- Distinctive: line 146
Only one HPA should target a given Deployment/StatefulSet.
- Very specific: line 152
Check if multiple HPAs reference the same scaleTargetRef.
- Very specific: line 159
If the target Deployment is managed by ArgoCD or Helm, the HPA replica count may be overwritten on sync — check if the Deployment's …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
HPA Autoscaling Failure Diagnosis
When a HorizontalPodAutoscaler is not scaling as expected — stuck at min/max replicas, showing <unknown> metrics, or not responding to load — follow this flow to identify the root cause.
Scope: This skill is for diagnosis only. Once you identify the root cause, report it to the user and stop. Do NOT attempt to modify HPA settings, resource requests, or metrics configuration — that should be left to the user.
Diagnostic Flow
1. Check HPA status
kubectl get hpa <hpa-name> -n <ns>Note:
- TARGETS — current value vs target (e.g.,
80%/50%). If showing<unknown>/50%, metrics are unavailable. - MINPODS / MAXPODS — scaling bounds
- REPLICAS — current replica count
2. Describe the HPA
kubectl describe hpa <hpa-name> -n <ns>Focus on:
- Conditions — look for
AbleToScale,ScalingActive, andScalingLimitedwith their status and reason - Events — scaling decisions, metric fetch errors, or rate-limiting messages
- Metrics — each metric's current value, target, and type (resource, custom, external)
3. Check metrics-server health
kubectl get pods -n kube-system -l k8s-app=metrics-server -o wideIf no pods are found, try:
kubectl get deployment -n kube-system metrics-serverVerify metrics-server is serving data:
kubectl top pods -n <ns>If kubectl top returns error: Metrics API not available, metrics-server is not working.
4. Check target resource requests
HPA with CPU/memory percentage targets requires resources.requests to be set on the target containers.
kubectl get deployment <target-name> -n <ns> -o jsonpath='{range .spec.template.spec.containers[*]}{.name}: cpu={.resources.requests.cpu} memory={.resources.requests.memory}{"\n"}{end}'If requests are not set, the HPA cannot calculate utilization percentages.
5. Match patterns and conclude
<unknown> metrics — Metrics not available
The HPA cannot fetch metrics for one or more targets.
Common causes:
- metrics-server not installed or not running — check step 3
- metrics-server not ready yet — it may take a few minutes after startup to collect data
- No resource requests set — CPU/memory percentage targets require
resources.requestson the target pods (step 4) - Custom metrics adapter missing — if the HPA uses custom or external metrics, the corresponding adapter (e.g., Prometheus adapter) must be installed
Advise the user to check metrics-server health and ensure resource requests are set.
ScalingActive: False — HPA cannot scale
The HPA has been disabled or cannot function.
Check the reason in kubectl describe hpa:
FailedGetResourceMetric— cannot fetch resource metrics (metrics-server issue)FailedGetExternalMetric— cannot fetch external metrics (adapter issue)InvalidMetricSourceType— the metric source type is not recognized
ScalingLimited: True — At min or max replicas
The HPA wants to scale but is constrained by minReplicas or maxReplicas.
Check the reason:
TooFewReplicas— HPA wants to scale down belowminReplicasTooManyReplicas— HPA wants to scale up abovemaxReplicasDesiredWithinRange— current replicas are within bounds (normal)
If the HPA is stuck at maxReplicas and load is still high, advise the user to increase maxReplicas or investigate why the application needs so many replicas (possible performance issue).
HPA flapping (scaling up and down repeatedly) — Unstable metrics
The HPA keeps oscillating between replica counts.
Check the events for rapid scale-up/scale-down cycles. Common causes:
- Metric target too close to normal usage — small load changes trigger scaling
- Application slow to start — new pods take time to become effective, causing the HPA to scale up further before they help
The HPA has a default stabilization window (5 minutes for scale-down). Check if custom behavior is set:
kubectl get hpa <hpa-name> -n <ns> -o jsonpath='{.spec.behavior}'Advise the user to adjust the stabilization window or the target utilization.
HPA not scaling up under load — Target not reached
The HPA sees metrics below the target threshold, so it does not scale.
Verify the actual pod resource usage:
kubectl top pods -n <ns> -l <selector>Compare with the HPA target. If actual usage is below the target even under load:
- The resource requests may be set too high (actual usage is a low percentage of requests)
- The metric source may not reflect actual load
Multiple HPAs targeting the same workload — Conflicting autoscalers
Only one HPA should target a given Deployment/StatefulSet. Multiple HPAs on the same target cause unpredictable behavior.
kubectl get hpa -n <ns>Check if multiple HPAs reference the same scaleTargetRef. Advise the user to consolidate into a single HPA with multiple metrics.
Notes
- HPA evaluates metrics every 15 seconds by default (controlled by
--horizontal-pod-autoscaler-sync-periodon the controller manager). - Scale-down has a default stabilization window of 5 minutes to prevent flapping. Scale-up defaults to 0 (immediate).
- For HPAs using
autoscaling/v2, multiple metrics can be specified. The HPA scales to the highest recommended replica count across all metrics. - If the target Deployment is managed by ArgoCD or Helm, the HPA replica count may be overwritten on sync — check if the Deployment's
replicasfield is managed externally.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

