metrics-server Unavailable and kubectl top Failure Debug Prompt
Fix 'metrics not available' / 'error: Metrics API not available' when kubectl top and HPAs stop working — diagnose the APIService, TLS/kubelet connectivity, and metrics-server flags instead of restarting blindly.
- Target user
- Cluster operators and SREs
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior cluster operator debugging why the Metrics API is unavailable. Reason from the APIService status and metrics-server logs, not guesswork. I will provide some of: - The failing command output (`kubectl top nodes`, `kubectl top pods`, or an HPA showing `<unknown>` targets) - `kubectl get apiservice v1beta1.metrics.k8s.io -o yaml` (Available condition) - `kubectl -n kube-system logs deploy/metrics-server` - The metrics-server args and the cluster's CNI/kubelet cert setup Walk this decision tree: 1. **Is the APIService Available?** — read the `v1beta1.metrics.k8s.io` APIService condition. `FailedDiscoveryCheck` means the aggregator cannot reach the metrics-server Service; `MissingEndpoints` means the pod is not Ready. 2. **Is the pod healthy?** — check that the metrics-server Deployment is Running and Ready; if it crash-loops, read logs for the real cause. 3. **Can it scrape kubelets?** — the classic failure is TLS: logs show `x509: cannot validate certificate ... because it doesn't contain any IP SANs` or `unable to fully scrape metrics`. Decide between approving kubelet serving certs vs the `--kubelet-insecure-tls` stopgap, and set `--kubelet-preferred-address-types` correctly. 4. **Network path** — confirm the aggregator (API server) can reach the metrics-server Service port and that no NetworkPolicy blocks kube-system. 5. **Freshness** — remember metrics need ~15s of scrape history; a just-started server legitimately returns "metrics not yet available". Output: (a) which stage is broken with the evidence line, (b) the root cause, (c) the exact fix (flag change, cert approval, or NetworkPolicy edit), (d) verification (`kubectl top nodes` returning values). If a diagnostic is missing, name the command.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
kubectl port-forward Connection Failure Debug Prompt
Diagnose why kubectl port-forward drops, refuses, or hangs — pod not Ready, wrong target port, SPDY/websocket proxy issues, or an app bound to localhost inside the container — instead of guessing.
-
CrashLoopBackOff Triage From Describe and Logs Prompt
Walk a CrashLoopBackOff pod from kubectl describe, previous-container logs, and exit codes to a precise root cause and fix, instead of blindly restarting it.
-
Pending Pod Scheduling Diagnosis Prompt
Diagnose why a pod is stuck Pending by reading scheduler events, node capacity, and the pod's scheduling constraints, then propose the minimal change to get it scheduled.
-
Resource Requests, Limits and HPA Right-Sizing Prompt
Right-size cpu/memory requests and limits from observed usage and pair them with a sane HPA so a workload scales on the correct signal without thrashing or OOMing.
More Kubernetes & Helm prompts & error guides
Browse every Kubernetes & Helm prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.