kubernetes resource_error ai_generated true

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-unable-to-get-metrics

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2023-11-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Metrics Server v0.6.4 active — — —
Kubernetes v1.28.0 active — — —
Kubernetes v1.29.0 active — — —

Root Cause

Metrics Server is not deployed or not functioning, so the Horizontal Pod Autoscaler cannot retrieve CPU/memory metrics.

generic

中文

Metrics Server 未部署或未正常运行,导致 Horizontal Pod Autoscaler 无法获取 CPU/内存指标。

Official Documentation

https://kubernetes.io/docs/tasks/debug/debug-cluster/resource-metrics-pipeline/

Workarounds

  1. 90% success Deploy Metrics Server: `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`.
    Deploy Metrics Server: `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`.
  2. 80% success If Metrics Server is installed but not working, check its logs: `kubectl logs -n kube-system deployment/metrics-server`. Common issues include TLS or node name resolution problems.
    If Metrics Server is installed but not working, check its logs: `kubectl logs -n kube-system deployment/metrics-server`. Common issues include TLS or node name resolution problems.
  3. 85% success For Minikube or kind clusters, enable metrics-server addon: `minikube addons enable metrics-server` or use kind's config to deploy it.
    For Minikube or kind clusters, enable metrics-server addon: `minikube addons enable metrics-server` or use kind's config to deploy it.

中文步骤

  1. 部署 Metrics Server:`kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`。
  2. 如果 Metrics Server 已安装但无法工作,检查其日志:`kubectl logs -n kube-system deployment/metrics-server`。常见问题包括 TLS 或节点名称解析问题。
  3. 对于 Minikube 或 kind 集群,启用 metrics-server 插件:`minikube addons enable metrics-server` 或使用 kind 的配置部署它。

Dead Ends

Common approaches that don't work:

  1. Increasing HPA target thresholds or replica limits 95% fail

    HPA still needs metrics to function; changing thresholds won't fix the missing metrics source.

  2. Restarting the HPA controller manager 80% fail

    The HPA controller is healthy; the issue is the metrics API backend, not the controller.