How to fix unable to get metrics for resource cpu: no metrics returned from resource metrics API in Kubernetes

KubernetesINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 180 views

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.

Quick fix

Fixes unable to get metrics for resource cpu: no metrics returned from resource metrics API

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-server
  1. Verify Metrics Server is running
  2. Test metrics availability
  3. Add resource requests to all containers
  4. Verify pods are Ready
kubernetes โ€” error
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-server
unable to get metrics for resource cpu: no metrics returned from resource metrics API

What this error means

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.

Typical symptoms

  • HPA status shows `<unknown>` or `0/50` in TARGETS column
  • kubectl describe hpa shows "FailedGetResourceMetric" event
  • Pods stuck at minReplicas, no automatic scale-up during load
  • Replicas unchanged despite high CPU/memory usage
  • Events: "the HPA was unable to compute the replica count"
  • ScalingActive condition shows False

Common causes

  1. Metrics Server not installed or not running
  2. Containers missing resource requests (HPA requires requests to calculate %)
  3. Unready pods ignored (metrics only counted from Ready pods)
  4. etcd or API server issues preventing metric retrieval
  5. Custom metrics API misconfigured or unavailable
  6. Nodes in NotReady state, unable to report metrics

How to fix "unable to get metrics for resource cpu: no metrics returned from resource metrics API"

1Verify Metrics Server is running

Check if Metrics Server is deployed:

bash
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-server

If not found, install:

bash
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
2Test metrics availability

Verify metrics can be retrieved:

bash
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.

3Add resource requests to all containers

HPA requires resource requests to calculate utilization percentage:

yaml
resources:
  requests:
    cpu: 100m           # REQUIRED for HPA
    memory: 128Mi       # REQUIRED for HPA
  limits:
    cpu: 500m
    memory: 512Mi

Apply to main app container AND all sidecars (Istio, etc.).

4Verify pods are Ready

HPA ignores unready pods:

bash
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.

5Check HPA configuration

Verify HPA targets valid metrics:

bash
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%)

6Monitor scaling in real-time

Watch HPA behavior:

bash
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> --watch
7For custom metrics, configure Custom Metrics API

If using custom metrics (not CPU/memory):

bash
# 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" | jq

Ensure adapter is installed and configured for your metrics provider.

Advanced notes

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.

Frequently asked questions

What does "unable to get metrics for resource cpu: no metrics returned from resou" mean?
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.
How do I fix "unable to get metrics for resource cpu: no metrics returned from resou"?
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.
What causes "unable to get metrics for resource cpu: no metrics returned from resou"?
Metrics Server not installed or not running Containers missing resource requests (HPA requires requests to calculate %) Unready pods ignored (metrics only counted from Ready pods)
Is the "unable to get metrics for resource cpu: no metrics returned from resou" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading