kubernetes resource_error ai_generated true

获取 CPU 利用率失败:无法获取资源 cpu 的指标:无法从资源指标 API 获取指标:服务器找不到请求的资源(get pods.metrics.k8s.io)

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

其他格式: JSON · Markdown 中文 · English
90%修复率
85%置信度
1证据数
2023-11-05首次发现

版本兼容性

版本状态引入弃用备注
Metrics Server v0.6.4 active
Kubernetes v1.28.0 active
Kubernetes v1.29.0 active

根因分析

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

English

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

generic

官方文档

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

解决方案

  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 的配置部署它。

无效尝试

常见但无效的做法:

  1. Increasing HPA target thresholds or replica limits 95% 失败

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

  2. Restarting the HPA controller manager 80% 失败

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