kubernetes resource_error ai_generated true

错误:无法获取CPU利用率:无法获取资源CPU的指标:无法从资源指标API获取指标

Error: failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API

ID: kubernetes/hpa-missing-metrics-server

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

版本兼容性

版本状态引入弃用备注
metrics-server v0.6.4 active
Kubernetes v1.28.3 active
Kubernetes v1.29.0 active

根因分析

水平Pod自动缩放器(HPA)无法查询CPU/指标,因为metrics-server未部署或运行不正常。

English

Horizontal Pod Autoscaler (HPA) cannot query CPU/metrics because the metrics-server is not deployed or is not functioning correctly.

generic

官方文档

https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis

解决方案

  1. Deploy metrics-server using the official manifest: `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml`
  2. Check metrics-server pod logs: `kubectl logs -n kube-system deployment/metrics-server` and verify it can connect to kubelets. Common fix: add --kubelet-insecure-tls flag if using self-signed certs.

无效尝试

常见但无效的做法:

  1. Install a custom Prometheus adapter instead of metrics-server 70% 失败

    HPA requires the resource metrics API, which is typically served by metrics-server. Prometheus adapter serves custom metrics, not resource metrics.

  2. Set --horizontal-pod-autoscaler-use-rest-clients=false on kube-controller-manager 90% 失败

    This flag is deprecated and removed in recent Kubernetes versions (1.23+). It no longer affects HPA behavior.