Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Terminal on a fresh minikube cluster
kubectl top says metrics aren't available. Your cluster is fine. Look at the terminal: kubectl get pods shows web-7d4b9 Running, one of one ready, zero restarts. Yet kubectl top pods fails with Metrics API not available. The pod is healthy, so something else is missing.
$ kubectl get pods
NAME READY STATUS RESTARTS
web-7d4b9 1/1 Running 0
$ kubectl top pods
error: Metrics API not availableBefore and after: who collects the numbers?
kubectl top doesn't measure anything itself. It only reads numbers. On the left, it points at an empty slot, because nothing is collecting usage. metrics-server, a small add-on, fills that slot by gathering CPU and memory from your nodes. Many fresh clusters ship without it.
Fix on minikube
On minikube, enable the addon with minikube addons enable metrics-server. Give it about a minute to collect its first numbers, then rerun kubectl top pods. Now you get a table. 3m means three millicores of CPU, and 42Mi is memory in mebibytes. These numbers are illustrative. Other clusters install metrics-server differently.
$ minikube addons enable metrics-server
# wait about a minute for first collection
$ kubectl top pods
NAME CPU(cores) MEMORY(bytes)
web-7d4b9 3m 42Mikubectl top can't read numbers no one is collecting.
kubectl top can't read numbers no one is collecting. Whenever it errors, check whether metrics-server is installed and running first.
