HPA (Horizontal Pod Autoscaler) cannot scale pods because metrics are unavailable, pods lack resource requests, or scaling constraints prevent replica changes. The HPA reports "FailedGetResourceMetric" error when Metrics Server is missing or metrics data is unavailable. Fix by installing Metrics Server, adding resource requests, or ensuring pods are ready.
HPA requires Metrics Server to collect resource metrics (CPU, memory) from pods and nodes. Without metrics, HPA cannot calculate desired replica count. Even when Metrics Server is running, unready pods or missing resource requests cause metrics unavailable errors.
Check if Metrics Server is deployed:
kubectl get deployment metrics-server -n kube-system
kubectl get pods -n kube-system -l k8s-app=metrics-server
kubectl logs -n kube-system -l k8s-app=metrics-serverIf not found, install:
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yamlVerify metrics can be retrieved:
kubectl top nodes
kubectl top pods -n <namespace>If these fail with "metrics not found", Metrics Server issue. Check logs for TLS certificate or kubelet connectivity errors.
HPA requires resource requests to calculate utilization percentage:
resources:
requests:
cpu: 100m # REQUIRED for HPA
memory: 128Mi # REQUIRED for HPA
limits:
cpu: 500m
memory: 512MiApply to main app container AND all sidecars (Istio, etc.).
HPA ignores unready pods:
kubectl get pods -n <namespace> -o wide
kubectl describe pod <pod-name> -n <namespace> | grep -A5 "Conditions"All pods must be Running and Ready. Check readiness probe configuration.
Verify HPA targets valid metrics:
kubectl get hpa -n <namespace>
kubectl describe hpa <hpa-name> -n <namespace>Ensure:
- minReplicas < maxReplicas
- Metric names are valid (cpu, memory)
- Target utilization is reasonable (30-80%)
Watch HPA behavior:
kubectl get hpa <hpa-name> -n <namespace> --watch
# Generate load for testing
kubectl run -it --rm load -- busybox sh -c "while true; do wget -q -O- http://<service>; done"
# Monitor pod creation
kubectl get pods -n <namespace> --watchIf using custom metrics (not CPU/memory):
# Verify custom metrics adapter is running
kubectl get deployment -n custom-metrics
# Test custom metric availability
kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1" | jqEnsure adapter is installed and configured for your metrics provider.
HPA with unready pods takes conservative approach: assumes 100% utilization, preventing scale-down. Add startupProbe with long failureThreshold (30-90) for slow-starting apps. For sidecars (Istio, Linkerd), use ContainerResource metric type (Kubernetes 1.27+) to scale based on main container only. Pod evictions count as replicas; monitor for involuntary disruptions.
No subnets found for EKS cluster
How to fix "eks subnet not found" in Kubernetes
unable to compute replica count
How to fix "unable to compute replica count" in Kubernetes HPA
error: context not found
How to fix "error: context not found" in Kubernetes
default backend - 404
How to fix "default backend - 404" in Kubernetes Ingress
serviceaccount cannot list resource
How to fix "serviceaccount cannot list resource" in Kubernetes