Skip to content
Français
Sync not enabled: your progress stays in this browser My learning
Select theme
Français

Check Kubernetes cluster health with 5 commands

By updated

Improve this page

Logo Kubernetes

Five kubectl commands let you tell whether a Kubernetes cluster is healthy. This guide shows you how to check node status, detect resource pressure, read CPU and memory usage and browse the cluster events. You can then spot a problem before it affects your applications.

What you will learn

  • Check that all nodes are Ready and interpret their conditions
  • Read the allocated resources vs capacity of a node
  • Install metrics-server to enable kubectl top
  • Monitor CPU and memory usage in real time
  • Analyze events to spot anomalies

Prerequisites

  • A working Kubernetes cluster (v1.37)
  • kubectl configured and connected to the cluster
  • Read access to the cluster's nodes, pods, events and metrics
  • Basic knowledge of Pods and Kubernetes nodes

How does Kubernetes monitor node health?

The kubelet (the agent that runs on every node) updates the node's status and regularly renews a Lease object in the kube-node-lease namespace. If the control plane stops receiving these signals, it can mark the node as unreachable (Ready: Unknown) after about 40 seconds by default, then wait 5 minutes before starting the first eviction of the node's pods.

Concretely, the kubelet updates two things:

  • The node status (.status.conditions): several conditions that report resource pressure, notably Ready, MemoryPressure, DiskPressure, PIDPressure and, depending on the context, NetworkUnavailable
  • A Lease object in kube-node-lease: a lightweight "I am alive" signal that serves as a fast heartbeat

When a condition turns True, the node is reporting a problem. The only exception is Ready, which must stay True. And when Ready turns Unknown, the control plane has lost contact.

ConditionHealthy stateWhat it means when abnormal
ReadyTrueFalse = failing kubelet or node; Unknown = unreachable node
MemoryPressureFalseAvailable memory is below the eviction thresholds
DiskPressureFalsePressure on nodefs, imagefs or inodes, depending on the kubelet configuration
PIDPressureFalseNot enough PIDs available
NetworkUnavailableFalseNode network not ready, depending on the provider/CNI

Step 1: check node status

The first command to run is kubectl get nodes. It gives a quick overview of every node in the cluster:

Terminal window
kubectl get nodes

All nodes must show Ready in the STATUS column:

NAME STATUS ROLES AGE VERSION
ks-cp1 Ready control-plane 41h v1.37.0
ks-worker1 Ready <none> 41h v1.37.0
ks-worker2 Ready <none> 41h v1.37.0

For more detail (IP, runtime, OS), add -o wide:

Terminal window
kubectl get nodes -o wide
Status in the outputMeaningAction
ReadyThe node works normallyNone
NotReadyThe Ready condition is not True; the cause is read in step 2Display the node conditions with kubectl describe node
SchedulingDisabledThe node is cordonedNormal during planned maintenance

A NotReady status does not explain the failure. The next step looks for its cause.

Step 2: inspect a node's conditions

Step 1 tells you whether a node is ready. The node conditions, which kubectl describe node displays, tell you what is wrong when it is not.

What does the NotReady status really say?

The NotReady status means that the node's Ready condition is not True: the node is not ready to accept pods. It does not say why. To look for the cause, display the node details with kubectl describe node:

Terminal window
kubectl describe node ks-worker1

The output is long. On a NotReady node, look at the Ready line of the Conditions section: its Reason and Message columns give the first lead. When the kubelet stops giving any sign of life, Ready is Unknown and the message reads Kubelet stopped posting node status.

Does a healthy node have all its conditions at True?

No. On a healthy node, only Ready is True: the other conditions signal a problem when they turn True, so they must stay False. Here is the Conditions section of a healthy node:

Conditions:
Type Status Reason Message
---- ------ ------ -------
NetworkUnavailable False CalicoIsUp Calico is running on this node
MemoryPressure False KubeletHasSufficientMemory kubelet has sufficient memory available
DiskPressure False KubeletHasNoDiskPressure kubelet has no disk pressure
PIDPressure False KubeletHasSufficientPID kubelet has sufficient PID available
Ready True KubeletReady kubelet is posting ready status

Each line of this table reads as follows:

  • Ready: True = the kubelet works and accepts pods
  • MemoryPressure: False = memory is sufficient
  • DiskPressure: False = enough disk space
  • PIDPressure: False = number of processes within limits

How do I check allocated resources?

Further down in the describe node output, the Allocated resources section adds up the requests and the limits of the pods on this node that have not terminated, and reports them against the node's allocatable capacity:

Allocated resources:
Resource Requests Limits
-------- -------- ------
cpu 455m (32%) 7 (500%)
memory 432730Ki (38%) 4501513472 (390%)

Requests represent what the pods have reserved. Limits are the maximum they can use. When Requests approach the allocatable capacity, the node can no longer accept new pods. An alert threshold around 80% is common, to be adapted to your cluster.

Limits that add up to more than 100% of the capacity are normal: this is not a configuration defect. The pods could exceed the node's capacity if they all used their ceiling at the same time, which rarely happens. Watch the Requests instead, since they are what the scheduler reserves.

Step 3: check control plane health

The control plane (API server, scheduler, controller-manager, etcd) drives the cluster. The API server exposes two dedicated health endpoints.

What are the /readyz and /livez endpoints?

Since Kubernetes v1.16, two endpoints replace the old /healthz:

  • /livez: is the API server process alive?
  • /readyz: is the API server ready to serve requests?
Terminal window
kubectl get --raw='/readyz?verbose' | head -20

Each [+] line confirms a working subsystem:

[+]ping ok
[+]log ok
[+]etcd ok
[+]poststarthook/start-apiserver-admission-initializer ok
[+]poststarthook/generic-apiserver-start-informers ok
...

If a line shows [-], the matching subsystem is failing.

To check liveness as well:

Terminal window
kubectl get --raw='/livez?verbose' | head -20

How do I check the control plane pods?

To see concretely whether the control plane components are running:

Terminal window
kubectl get pods -n kube-system -o wide

Check that the etcd, kube-apiserver, kube-controller-manager and kube-scheduler pods are Running with RESTARTS at 0.

Two commands from older runbooks are to be dropped: /healthz, deprecated since v1.16 in favor of /readyz and /livez, and kubectl get componentstatuses, deprecated since v1.19. They still answer on many clusters, but they give an answer without guaranteeing that it reflects the real state.

Step 4: monitor usage with metrics-server

The kubectl top command displays CPU and memory usage in real time. It requires metrics-server, a component that collects metrics from each kubelet and feeds the Metrics API used, among others, by the autoscalers (HPA/VPA).

If kubectl top nodes answers error: Metrics API not available, the most common cause is that metrics-server is not installed. It is not a component shipped with Kubernetes, and it is missing on most test clusters, kind included. The next section shows how to add it.

How do I install metrics-server (lab only)?

Expand the installation steps
  1. Apply the official manifest:

    Terminal window
    kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.9.1/components.yaml
  2. On a cluster without a TLS certificate (such as a lab), add the --kubelet-insecure-tls flag:

    Terminal window
    kubectl -n kube-system patch deployment metrics-server --type=json \
    -p='[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]'
  3. Wait until metrics-server is ready:

    Terminal window
    kubectl -n kube-system rollout status deployment/metrics-server --timeout=90s
  4. Check that the Metrics API is available:

    Terminal window
    kubectl get apiservices | grep metrics

    Expected result:

    v1beta1.metrics.k8s.io kube-system/metrics-server True 59s

How do I read node usage?

Once metrics-server is installed, the kubectl top nodes command displays real usage:

Terminal window
kubectl top nodes
NAME CPU(cores) CPU(%) MEMORY(bytes) MEMORY(%)
ks-cp1 131m 9% 1129Mi 102%
ks-worker1 72m 5% 833Mi 75%
ks-worker2 74m 5% 935Mi 85%

The four columns read as follows:

  • CPU(cores): instantaneous consumption in millicores (1000m = 1 CPU)
  • CPU%: percentage of the allocatable capacity
  • MEMORY(bytes): memory actually used (working set)
  • MEMORY%: percentage of the allocatable memory

How do I read pod usage?

Terminal window
kubectl top pods -A --sort-by=cpu | head -15

This command sorts all pods by decreasing CPU usage and quickly shows which one consumes too much.

For a specific namespace:

Terminal window
kubectl top pods -n kube-system

metrics-server collects measurements at a regular interval, every 60 seconds by default (the --metric-resolution option). A freshly created Pod can therefore take more than a minute to appear in kubectl top. A Pod missing from the output is therefore not necessarily a failing Pod.

kubectl top gives a snapshot, with no history and no alerting: it is for sorting quickly, not for understanding a drift. To find out since when a pod consumes too much, or whether the situation is getting worse, you need a complete observability stack, Prometheus and Grafana for example.

Step 5: read the cluster events

Kubernetes events record what happens in the cluster: creations, scheduling errors, restarts, evictions.

How long does Kubernetes keep events?

One hour by default. The API server keeps them only for that time, which you can change with the --event-ttl option of kube-apiserver: an older incident no longer appears in the list. The absence of an event therefore proves nothing: a pod that crashed two hours ago has no trace left here, and that does not mean everything was fine. Beyond one hour, your monitoring and the kubelet logs keep the trace. Check the events as soon as you notice a problem.

How do I display recent events?

Since Kubernetes v1.26, the kubectl events subcommand offers a more readable display with native filtering options. To see recent warnings:

Terminal window
kubectl events -A --types=Warning

The classic kubectl get events command remains available for sorting (--sort-by) and for finer filtering (--field-selector). The guide Analyze Kubernetes events covers these options in detail:

Terminal window
kubectl get events -A --sort-by=.metadata.creationTimestamp | tail -20

Filtering by resource is often more direct than reading the whole list:

Terminal window
kubectl events -A --for=node/ks-worker1
kubectl events -n default --for=pod/mon-pod

The event type separates normal operation from anomalies:

Event typeExamplesMeaning
NormalPulling, Created, StartedNormal kubelet operations
WarningFailedScheduling, BackOff, UnhealthySomething is not working

Which common events should I watch?

Here are five frequent events. For each one, the table gives the likely cause and the first thing to do.

EventLikely causeAction
FailedSchedulingNot enough resources on the nodesCheck kubectl describe node, free up resources
BackOffThe container restarts in a loop, which kubectl get pods displays as CrashLoopBackOffCheck the logs: kubectl logs <pod>
FailedMountVolume not availableCheck the PVC and the StorageClass
UnhealthyThe probe failedCheck the probes configuration
EvictedNode under pressure (memory/disk)Check the node conditions

Summary: the 5 essential commands

Run these five commands in this order, from the widest check (node status) to the most precise (events). Each command rules out a family of causes before the next one. If all five pass, the cluster infrastructure is probably healthy and the problem is more likely on the application side.

#CommandWhat it checks
1kubectl get nodesAll nodes are Ready
2kubectl describe node <name>Detailed conditions and allocated resources
3kubectl get --raw='/readyz?verbose'Control plane health
4kubectl top nodes / kubectl top podsReal-time CPU/memory usage
5kubectl events -A --types=WarningRecent anomalies in the cluster

Going beyond the five commands: internal metrics

The five commands above are enough to triage quickly. When kubectl top is no longer enough, the kube-apiserver and the kubelet expose /metrics endpoints in Prometheus format.

What metrics does the kube-apiserver expose?

Prometheus collects these metrics, but nothing forces you to deploy Prometheus to read them: kubectl get --raw queries the endpoint directly and prints raw text. It is a quick way to check that a metric exists under the name you think it has, before writing a PromQL query.

Terminal window
# Global control plane metrics
kubectl get --raw /metrics | grep -E "^# HELP (apiserver|etcd_)" | head

A few useful metrics:

MetricWhat it indicates
apiserver_request_duration_secondsAPI request latency (by verb and resource)
apiserver_request_totalTotal number of API requests (useful to spot an activity spike)
etcd_request_duration_secondsLatency of calls to etcd
etcd_bookmark_totalNumber of etcd bookmarks emitted (renamed in 1.36, see below)

What metrics do the kubelet and cAdvisor expose?

The kubelet exposes its own metrics, separate from those of the API server. Everything about the node's containers and their resources comes from the kubelet, and is read through the API proxy.

Terminal window
NODE=$(kubectl get nodes -o jsonpath='{.items[0].metadata.name}')
# Kubelet's own metrics
kubectl get --raw "/api/v1/nodes/${NODE}/proxy/metrics" | grep -E "^# HELP" | head
# cAdvisor metrics (per container)
kubectl get --raw "/api/v1/nodes/${NODE}/proxy/metrics/cadvisor" | grep -E "^# HELP" | head

How do I measure node pressure with PSI (GA in 1.36)?

Since Kubernetes 1.36, PSI metrics (Pressure Stall Information) are GA. Through cgroup v2, they expose the time during which a container's tasks have waited or been blocked for lack of CPU, memory or IO. It is a finer indicator than simple average utilization.

Terminal window
kubectl get --raw "/api/v1/nodes/${NODE}/proxy/metrics/cadvisor" \
| grep -E "^container_pressure_(cpu|memory|io)_(stalled|waiting)"

The six exposed metrics:

MetricMeaning
container_pressure_cpu_waiting_seconds_totalTasks waiting for CPU
container_pressure_cpu_stalled_seconds_totalAll non-idle tasks blocked at the same time by the CPU
container_pressure_memory_waiting_seconds_totalMemory pressure (allocation/swap)
container_pressure_memory_stalled_seconds_totalAll non-idle tasks blocked at the same time by memory
container_pressure_io_waiting_seconds_totalIO wait
container_pressure_io_stalled_seconds_totalTotal IO stall

A *_stalled_seconds_total counter whose rate of increase goes up (the PromQL rate()) shows that the container spends more and more time blocked on the matching resource, with all its non-idle tasks at once. For memory, this can precede an OOMKill, but the Kubernetes documentation does not state it: read this counter as a sign of strain, not as a prediction.

Which metrics were renamed in 1.36?

If you have long-standing Grafana dashboards or Prometheus alert rules, two metrics were renamed in Kubernetes 1.36:

Before (≤ 1.35)After (1.36+)
volume_operation_total_errorsvolume_operation_errors_total
etcd_bookmark_countsetcd_bookmark_total

Adjust your PromQL queries and dashboards after a version upgrade: without that, they will show empty series, without any warning.

Pay attention to where you look: these two metrics are not exposed by the same component, and a metric searched on the wrong component returns an empty result, which looks like a vanished metric. etcd_bookmark_total comes from the API server, and is read like this:

Terminal window
kubectl get --raw /metrics | grep etcd_bookmark_total

The volume_operation_* metrics, on the other hand, come from the kube-controller-manager (the persistent volume controller), and cannot be found on the API server or on the kubelet. They are read on that component's /metrics endpoint, which Prometheus usually queries.

Troubleshooting

This table lists the symptoms you will meet when reading a cluster's health. Two of them do not signal any failure: a kubectl top that does not answer often means that metrics-server is not installed, and a missing metric often means that you are looking for it on the wrong component. Check these two causes before opening an investigation on a cluster that may well be fine.

SymptomLikely causeSolution
Node NotReadyKubelet, runtime or network plugin failing (False), or node unreachable (Unknown)Log in to the node, check systemctl status kubelet
MemoryPressure: TrueNot enough memoryIdentify the hungry pods with kubectl top pods, add memory or reduce the load
DiskPressure: TrueDisk full (images, logs)Clean unused images: crictl rmi --prune
kubectl top returns "Metrics API not available"metrics-server missingInstall metrics-server (see step 4)
/readyz shows [-]etcdetcd unavailableCheck the etcd pod: kubectl logs -n kube-system etcd-<name>
A metric stays missing (empty result)Wrong component queried, or pre-1.36 nameQuery the right /metrics endpoint (API server, kubelet or kube-controller-manager) and check the name (see "Which metrics were renamed in 1.36?")
Many Evicted eventsNode under prolonged pressureAdd nodes or reduce the workload

Hands-on practice

You have just read a cluster's health command by command. In this lab, the kubeadm cluster has no metrics-server, so kubectl top returns nothing. You install metrics-server from the pinned manifest provided and make it accept the kubelets' certificates. You then write a health report in the bulletin ConfigMap of the sante namespace, naming the Pod that uses the most memory and the node whose CPU is the most reserved by requests.

The validation checks three requirements: the Metrics API is available and kubectl top nodes answers, the report names the Pod of sante that uses the most memory as kubectl top measures it, and it names the node whose allocatable CPU is the most reserved by requests. If a requirement fails, go back to step 4 for kubectl top, or to step 2 for per-node reservations (Allocated resources).

Key takeaways

  • kubectl get nodes is your first reflex: all nodes must be Ready
  • The conditions of a node (Ready, MemoryPressure, DiskPressure, PIDPressure and, depending on the context, NetworkUnavailable) sum up its health
  • kubectl describe node reveals allocated resources vs capacity, so watch the Requests/Allocatable ratio
  • metrics-server is required for kubectl top, and Kubernetes does not install it by itself
  • Warning events report recent anomalies: Kubernetes keeps them for only one hour by default, so check them without delay
  • These commands give a snapshot; for continuous monitoring, deploy Prometheus and Grafana
  • A missing metric does not prove it disappeared: check that you are querying the right component and the new name after a version upgrade

Knowledge check

Seven questions cover three reading traps: the Ready condition, the only one that must be True, Limits above 100% that are not a defect, and a missing metric because you query the wrong component.

Knowledge check

Check what you have learned with this interactive quiz

7 questions
5 min
80% to pass

How it works

  • The timer starts when you click Start
  • Multiple choice, true/false and short answer questions
  • You can move between questions
  • Detailed results are shown at the end

Starts the quiz and the timer