{
  "id": "kubernetes/horizontal-pod-autoscaler-missing-metrics",
  "signature": "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)",
  "signature_zh": "无法获取 CPU 利用率：无法获取资源 CPU 的指标：无法从资源指标 API 获取指标：服务器找不到请求的资源（get pods.metrics.k8s.io）",
  "regex": "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\\)",
  "domain": "kubernetes",
  "category": "runtime_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "metrics-server（或自定义指标适配器）未安装或未正常运行，导致 Horizontal Pod Autoscaler 无法检索 CPU/内存指标。",
  "versions": [
    {
      "version": "kubernetes 1.27",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "metrics-server 0.6",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "metrics-server 0.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Changing the target doesn't fix the missing metrics API; the HPA still can't get any data.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The HPA controller is not the source of metrics; it relies on the metrics API which is unavailable.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Conflicting adapters can cause API registration issues; the correct approach is to ensure only one metrics provider is active.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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`.",
      "success_rate": 0.95,
      "how": "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`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.85,
      "how": "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.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 `kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml` 部署 metrics-server。验证其运行：`kubectl get pods -n kube-system | grep metrics-server`。检查日志错误：`kubectl logs -n kube-system deployment/metrics-server`。",
    "运行 `kubectl get apiservices.apiregistration.k8s.io | grep metrics` 查看 `v1beta1.metrics.k8s.io` 或 `v1beta1.custom.metrics.k8s.io` 是否可用。如果不可用，确保 metrics-server 部署健康且其服务端点可达。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#support-for-metrics-apis",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2023-11-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}