How to fix failed to get cpu utilization: unable to get metrics in Kubernetes

KubernetesINTERMEDIATEMEDIUMUpdated Dec 6, 2025· 235 views

The HPA (Horizontal Pod Autoscaler) error about unable to get CPU metrics indicates the Metrics Server is not installed, misconfigured, or pods lack resource requests. Without metrics, HPA cannot determine if pods need more replicas.

Quick fix

Fixes failed to get cpu utilization: unable to get metrics

kubectl get deployment -n kube-system metrics-server
kubectl get pods -n kube-system | grep metrics-server
  1. Check if Metrics Server is installed
  2. Add resource requests to pod specifications
  3. Verify pods are in Ready state
  4. Test metrics API directly
kubernetes — error
kubectl get deployment -n kube-system metrics-server
kubectl get pods -n kube-system | grep metrics-server
failed to get cpu utilization: unable to get metrics

What this error means

HPA relies on the Metrics Server to collect CPU and memory metrics from the kubelet on each node. These metrics are then used to determine if pods need scaling. The "unable to get metrics" error means either: 1. Metrics Server is not installed in the cluster 2. Pods lack CPU resource requests (HPA uses requests to calculate percentages) 3. Metrics API is unreachable or misconfigured 4. Pods are not in Ready state (metrics only available for running pods) Without metrics, HPA cannot make scaling decisions and remains in "Waiting for metrics" state indefinitely.

Typical symptoms

  • HPA events show: "failed to get cpu utilization: unable to get metrics for resource cpu"
  • kubectl top pods/nodes returns "error: metrics not available yet"
  • HPA remains in "Waiting for metrics" state despite running pods
  • Pods don't auto-scale despite high CPU usage
  • Dashboard shows no CPU/memory graphs for pods
  • Error: "failed to get cpu utilization: missing request for cpu in container X"
  • Message: "did not receive metrics for targeted pods (pods might be unready)"

Common causes

  1. Metrics Server not installed in the cluster
  2. Pods lack CPU resource requests in spec (HPA needs requests to calculate utilization %)
  3. Metrics API communication failure (network, RBAC, or API server issues)
  4. Kubelet metrics endpoint unavailable (port 10250 unreachable)
  5. Pods not in Ready state (metrics only available for running pods)
  6. Metrics Server pods not running or crashing
  7. Incorrect RBAC permissions for Metrics Server

How to fix "failed to get cpu utilization: unable to get metrics"

1Check if Metrics Server is installed

Verify Metrics Server is running:

bash
kubectl get deployment -n kube-system metrics-server
kubectl get pods -n kube-system | grep metrics-server

If not found, install it:

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

Wait 30-60 seconds for the pod to start, then verify:

bash
kubectl get pods -n kube-system metrics-server -o wide
kubectl logs -n kube-system deployment/metrics-server
2Add resource requests to pod specifications

HPA requires resource requests to calculate CPU utilization. Update your deployment:

yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  template:
    spec:
      containers:
      - name: app
        image: myapp:latest
        resources:
          requests:
            cpu: 100m        # Required for HPA
            memory: 128Mi    # Optional but recommended
          limits:
            cpu: 500m
            memory: 512Mi

Apply:

bash
kubectl apply -f deployment.yaml

Metrics should be available 15-60 seconds after pod startup.

3Verify pods are in Ready state

HPA only metrics for Ready pods. Check status:

bash
kubectl get pods
kubectl describe pod <pod-name>

If pods are not Ready, fix the underlying issues first (image pull errors, health check failures, resource constraints). Once pods are Running and Ready:

bash
kubectl top pods  # Should show CPU/memory now
4Test metrics API directly

Verify the Metrics API is working:

bash
kubectl get --raw /apis/metrics.k8s.io/v1beta1/nodes
kubectl get --raw /apis/metrics.k8s.io/v1beta1/namespaces/default/pods

If this returns valid JSON with metrics, the API is working. If it returns errors, check Metrics Server logs:

bash
kubectl logs -n kube-system deployment/metrics-server

Common errors:
- "Unauthorized" or "Forbidden": RBAC permissions issue
- "Connection refused": Metrics Server not running or API unavailable

5Check Metrics Server logs for errors

Get detailed error information:

bash
kubectl logs -n kube-system deployment/metrics-server -f
kubectl describe pod -n kube-system -l k8s-app=metrics-server

Common issues:
- "Unable to connect to Kubelet": Firewall blocking port 10250, or Kubelet not running
- "Forbidden": RBAC permissions missing for Metrics Server
- "CrashLoopBackOff": Pod startup failure (check earlier logs)

If Metrics Server is crashing, check available resources and restart it:

bash
kubectl rollout restart deployment -n kube-system metrics-server
6Verify Kubelet metrics endpoint is accessible

From the control plane, test kubelet metrics port:

bash
kubectl get nodes -o wide  # Get node IPs
curl -k --cert /var/run/kubernetes/client-admin.crt \
  --key /var/run/kubernetes/client-admin.key \
  https://<node-ip>:10250/metrics

If this fails with connection refused, kubelet isn't exposing metrics. Verify kubelet is running on the node:

bash
ssh <node-ip>
sudo systemctl status kubelet
netstat -tlnp | grep 10250
7Create a test HPA and verify it scales

Once metrics are available, test with a simple HPA:

bash
# Create a test deployment with metrics
kubectl create deployment hpa-test --image=nginx --replicas=1 -- sleep 3600
kubectl set resources deployment hpa-test --requests=cpu=100m

# Create HPA
kubectl autoscale deployment hpa-test --min=1 --max=3 --cpu-percent=50

# Check HPA status
kubectl get hpa -w
kubectl describe hpa hpa-test

Once metrics become available (15-60 seconds), HPA should show CPU percentage instead of "unknown".

8Wait for metrics stabilization

Metrics are not immediately available after pod creation:

bash
# Right after pod start:
kubectl top pod <pod-name>  # May return "no metrics"

# Wait 15-60 seconds:
watch kubectl top pod <pod-name>

Metrics become available once the kubelet has collected data from the container runtime. Be patient—metrics typically appear within 1-2 minutes for healthy pods.

9Verify RBAC permissions for Metrics Server (if using custom RBAC)

If Metrics Server cannot access Kubelet metrics, RBAC may be too strict. Verify:

bash
kubectl get clusterrole system:metrics-server -o yaml
kubectl get clusterrolebinding system:metrics-server -o yaml

Metrics Server needs permissions to:
- Get nodes and node metrics
- Access kubelet stats endpoints
- List pods in all namespaces

If using restrictive RBAC, ensure the Metrics Server ClusterRole includes these permissions.

Advanced notes

Metrics Server is essential for HPA to function—it's not optional. In Minikube, use minikube addons enable metrics-server. In Docker Desktop, Metrics Server must be installed manually. Cloud providers (EKS, AKS, GKE) often don't include Metrics Server by default—check provider docs. Resource requests are mandatory for HPA; without them, HPA cannot calculate CPU percentage (e.g., 50% of what?). Metrics have a 1-2 minute lag, so HPA scaling decisions are delayed. For real-time scaling needs, consider custom metrics via Prometheus. In resource-constrained clusters, Metrics Server itself may be the bottleneck—ensure it has sufficient CPU/memory. High-frequency metric collection (low --metric-resolution) increases kubelet load; adjust if needed.

Frequently asked questions

What does "failed to get cpu utilization: unable to get metrics" mean?
HPA relies on the Metrics Server to collect CPU and memory metrics from the kubelet on each node. These metrics are then used to determine if pods need scaling. The "unable to get metrics" error means either: 1.
How do I fix "failed to get cpu utilization: unable to get metrics"?
The HPA (Horizontal Pod Autoscaler) error about unable to get CPU metrics indicates the Metrics Server is not installed, misconfigured, or pods lack resource requests. Without metrics, HPA cannot determine if pods need more replicas.
What causes "failed to get cpu utilization: unable to get metrics"?
Metrics Server not installed in the cluster Pods lack CPU resource requests in spec (HPA needs requests to calculate utilization %) Metrics API communication failure (network, RBAC, or API server issues)
Is the "failed to get cpu utilization: unable to get metrics" error serious?
It is a medium-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading