# failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)

- **ID:** `kubernetes/horizontal-pod-autoscaler-missing-metrics`
- **Domain:** kubernetes
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The metrics-server (or custom metrics adapter) is not installed or not functioning, so the Horizontal Pod Autoscaler cannot retrieve CPU/memory metrics.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| kubernetes 1.27 | active | — | — |
| metrics-server 0.6 | active | — | — |
| metrics-server 0.7 | active | — | — |

## Workarounds

1. **Deploy metrics-server using `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`. Verify it's running: `kubectl get pods -n kube-system | grep metrics-server`. Check logs for errors: `kubectl logs -n kube-system deployment/metrics-server`.** (95% success)
   ```
   Deploy metrics-server using `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`. Verify it's running: `kubectl get pods -n kube-system | grep metrics-server`. Check logs for errors: `kubectl logs -n kube-system deployment/metrics-server`.
   ```
2. **Run `kubectl get apiservices.apiregistration.k8s.io | grep metrics` to see if `v1beta1.metrics.k8s.io` or `v1beta1.custom.metrics.k8s.io` is available. If not, ensure the metrics-server deployment is healthy and its service endpoints are reachable.** (85% success)
   ```
   Run `kubectl get apiservices.apiregistration.k8s.io | grep metrics` to see if `v1beta1.metrics.k8s.io` or `v1beta1.custom.metrics.k8s.io` is available. If not, ensure the metrics-server deployment is healthy and its service endpoints are reachable.
   ```

## Dead Ends

- **** — Changing the target doesn't fix the missing metrics API; the HPA still can't get any data. (95% fail)
- **** — The HPA controller is not the source of metrics; it relies on the metrics API which is unavailable. (90% fail)
- **** — Conflicting adapters can cause API registration issues; the correct approach is to ensure only one metrics provider is active. (50% fail)
