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

Manage Kubernetes cluster nodes day to day

By updated

Improve this page

Logo Kubernetes

To administer a Kubernetes cluster, you need to know how to list, inspect, label and taint your nodes. This guide covers the everyday operations: checking their state, organizing your fleet with labels, using role labels for readability, controlling Pod placement with taints, and cleanly replacing a failing node.

What you will learn

  • List and inspect the nodes of a cluster with kubectl
  • Assign labels to organize your nodes (environment, zone, workload type)
  • Use the node-role.kubernetes.io/ role labels for readability
  • Apply taints to control which pods can run on a node
  • Replace a failing node with the complete workflow

Prerequisites

How does Kubernetes manage nodes?

A node is a machine (physical or virtual) that runs pods. Each node runs a kubelet (the Kubernetes agent) and a container runtime (containerd, CRI-O). The kubelet registers itself automatically with the control plane at startup, then regularly sends a heartbeat to report that it is available.

The control plane maintains a Node object for each machine. This object contains:

InformationWhat it describes
ConditionsNode state: Ready, MemoryPressure, DiskPressure, PIDPressure
Capacity / AllocatableTotal resources vs resources available for pods
LabelsKey-value metadata to organize and target nodes
TaintsRestrictions that repel certain pods
AnnotationsInternal metadata (used by controllers, the CNI, etc.)

How do I list and inspect nodes?

To diagnose a node, start with the overview, which shows which nodes are unwell, then look at the detail of a single one, which tells you why. Doing it the other way round means closely inspecting a healthy node while another one is down.

How do I list all nodes?

Terminal window
kubectl get nodes
NAME STATUS ROLES AGE VERSION
ks-cp1 Ready control-plane 42h v1.37.0
ks-worker1 Ready <none> 42h v1.37.0
ks-worker2 Ready <none> 42h v1.37.0

The ROLES column displays the content of the node-role.kubernetes.io/ label. It is common for only the control plane nodes to have an explicit role, while workers show up with ROLES=<none> depending on the deployment tool used.

How do I show more details?

The -o wide option adds the internal IP, the OS, the container runtime and the architecture:

Terminal window
kubectl get nodes -o wide

How do I inspect a node in detail?

Terminal window
kubectl describe node ks-worker1

This command displays:

  • The node's conditions (Ready, pressures)
  • The labels and annotations
  • The active taints
  • The capacity and the allocated resources
  • The list of pods running on this node
  • The recent events

Do not confuse the two blocks that describe displays: the capacity is what the machine has, the allocated resources are what the pods' requests have already reserved.

The second figure is the one that decides future placements. A node can therefore refuse a pod while looking idle, when its reservations are high and its real consumption is low.

How do I see a node's labels?

Terminal window
kubectl get nodes --show-labels

The output can be very long. To filter on a particular label:

Terminal window
kubectl get nodes -l node-role.kubernetes.io/control-plane

How do I organize nodes with labels?

Labels are key-value pairs attached to Kubernetes objects. On nodes, they serve to organize your fleet and to control pod placement through nodeSelectors and node affinity.

How do I add a label?

A label is set on a node that is already in service, without restarting it or interrupting what runs on it. This is what makes the operation safe: it does not change the placement of existing Pods, only future decisions.

Terminal window
kubectl label node ks-worker1 env=production

Check that the label is set:

Terminal window
kubectl get node ks-worker1 --show-labels | grep env=

How do I change an existing label?

Add --overwrite to change the value of a label that is already present:

Terminal window
kubectl label node ks-worker1 env=staging --overwrite

How do I remove a label?

Add a - after the label name:

Terminal window
kubectl label node ks-worker1 env-

Which labels are common for nodes?

LabelExampleUsage
envproduction, stagingSeparate workloads by environment
disktypessd, hddPlace I/O-hungry pods on SSD
zoneeu-west-1a, rack-3Spread replicas across several zones
teambackend, dataIsolate workloads by team

Kubernetes itself sets a series of labels on every node when it joins, notably kubernetes.io/hostname, kubernetes.io/arch and kubernetes.io/os. These labels are reliable without any intervention: a nodeSelector on kubernetes.io/arch works on any cluster, whereas your own labels assume that someone remembered to set them.

How do I use a label to place a pod?

Once the label is set, add a nodeSelector to your pod or deployment to target that node:

spec:
nodeSelector:
env: production

For finer placement rules (preference rather than obligation), see the guide Affinity, taints and tolerations.

How do I use role labels for readability?

The ROLES column of kubectl get nodes reflects the node-role.kubernetes.io/... labels. These labels improve readability and can be used by your conventions and your tools, but they are not a placement or security mechanism on their own.

How do I assign a role?

Terminal window
kubectl label node ks-worker1 node-role.kubernetes.io/worker=

The value is empty by convention, only the label name matters.

Check that the ROLES column shows the new role:

Terminal window
kubectl get nodes
NAME STATUS ROLES AGE VERSION
ks-cp1 Ready control-plane 42h v1.37.0
ks-worker1 Ready worker 42h v1.37.0
ks-worker2 Ready <none> 42h v1.37.0

How do I assign several roles?

A node can have several roles. Simply add a second label:

Terminal window
kubectl label node ks-worker1 node-role.kubernetes.io/monitoring=

The node will display monitoring,worker in the ROLES column: kubectl sorts the roles in alphabetical order, not in the order you added them. So do not look for meaning in their position.

How do I remove a role?

Removal follows the same syntax as for any label, a trailing dash. The node keeps working exactly as before: only the ROLES column changes, since these labels do not drive any placement.

Terminal window
kubectl label node ks-worker1 node-role.kubernetes.io/worker-

How do I control placement with taints?

A taint is a restriction placed on a node that repels pods. Only pods that declare a matching toleration can be scheduled on a tainted node.

Which effects are available?

There are three effects, and the difference between them comes down to one question: what happens to the pods already in place? Two of them do not touch them, the third, NoExecute, evicts them. A NoExecute set by mistake on a production node therefore drives its pods away.

EffectBehavior
NoSchedulePrevents new pods (without a toleration) from being scheduled on the node. Pods already present are not affected.
PreferNoScheduleThe scheduler avoids this node but may place a pod there if there is no alternative.
NoExecutePrevents scheduling and evicts existing pods that do not have the toleration.

How do I add a taint?

Terminal window
kubectl taint nodes ks-worker1 maintenance=planned:NoSchedule

This means: "do not schedule any new pod on ks-worker1, unless it tolerates the maintenance=planned taint".

Check that the taint is set:

Terminal window
kubectl describe node ks-worker1 | grep -A 5 Taints

How do I remove a taint?

Removal frees the node for future placements immediately, but it does not bring back the pods that a NoExecute would have evicted: those were rescheduled elsewhere and stay there. Add a - at the end:

Terminal window
kubectl taint nodes ks-worker1 maintenance=planned:NoSchedule-

The short form key- removes all the taints of that key at once, whatever their effect. On a node carrying gpu=true:NoSchedule and gpu=true:NoExecute, kubectl taint nodes ks-worker1 gpu- empties the list, and a second run answers error: taint "gpu" not found.

Which taints does the control plane carry automatically?

By default, control-plane nodes have the node-role.kubernetes.io/control-plane:NoSchedule taint. This taint prevents application pods from being scheduled on the control plane.

Terminal window
kubectl describe node ks-cp1 | grep Taints
Taints: node-role.kubernetes.io/control-plane:NoSchedule

Which taints does Kubernetes add when a node has problems?

Kubernetes itself sets certain taints, tied to the node's state. If a node refuses Pods or evicts them without human intervention, look for them in kubectl describe node.

Automatic taintSet whenEffect
node.kubernetes.io/not-readyThe node's Ready condition is FalseNoSchedule and NoExecute
node.kubernetes.io/unreachableThe control plane no longer receives the kubelet heartbeatNoSchedule and NoExecute
node.kubernetes.io/memory-pressureNot enough memoryNoSchedule
node.kubernetes.io/disk-pressureNot enough disk spaceNoSchedule
node.kubernetes.io/pid-pressureToo many processesNoSchedule
node.kubernetes.io/unschedulableCordoned node (kubectl cordon)NoSchedule

Tested on kind by stopping a worker with docker stop: the node goes NotReady after about 50 seconds, with the two taints unreachable:NoSchedule and unreachable:NoExecute. The Pods that ran on it nevertheless stay displayed as Running once the node is lost, and the reason can be read in their own spec:

Terminal window
kubectl get pod <pod> -o jsonpath='{range .spec.tolerations[*]}{.key} {.effect} {.tolerationSeconds}{"\n"}{end}'
node.kubernetes.io/not-ready NoExecute 300
node.kubernetes.io/unreachable NoExecute 300

These two 300-second tolerations are added automatically to every Pod that does not declare its own. They avoid evicting a whole workload because of a network cut lasting a few seconds, at the price of five minutes before the Pods of a really lost node are recreated elsewhere. A Pod can declare its own, shorter tolerationSeconds if it must leave faster (see Affinity, taints and tolerations).

How do I replace a failing node?

When a node must be replaced, because of a hardware failure, end of life or a migration, follow this four-step procedure. It repeats the one from Prepare a maintenance.

  1. Drain the node: evacuate all the pods to other nodes.

    Terminal window
    kubectl drain ks-worker1 --ignore-daemonsets --delete-emptydir-data

    The drain starts with an automatic cordon, then evicts the pods while respecting the PodDisruptionBudgets. The two options get past two refusals. --ignore-daemonsets leaves the DaemonSet pods in place, which the drain cannot move and otherwise refuses to process. --delete-emptydir-data accepts losing the data of emptyDir volumes, which disappear with the pod.

    The drain assumes that the node still responds. On a machine that has really gone down, the kubelet can no longer confirm that the pods have stopped, and the drain may stay pending. Interrupt the command with Ctrl+C (the node stays cordoned) and check what still runs on it before moving on to the deletion.

  2. Check that the pods are rescheduled:

    Terminal window
    kubectl get pods -A -o wide | grep ks-worker1

    Only DaemonSet pods should remain on the node.

  3. Delete the Node object:

    Terminal window
    kubectl delete node ks-worker1

    The node disappears from kubectl get nodes. If the original machine comes back online with the same kubelet and the same identity, it can register again. If you are really replacing the instance, avoid reusing the same name without checking the consequences: Kubernetes assumes that a node with the same name is the same logical object.

  4. Add the new node: install the kubelet and the container runtime on the new machine. The kubelet registers itself automatically with the control plane. Check:

    Terminal window
    kubectl get nodes

    The new node appears with the Ready status after a few seconds. Reapply your labels and roles if needed.

What about annotations on nodes?

Node annotations mainly serve cluster components and administration tools. In practice, for day-to-day operations, focus first on conditions, labels and taints.

You can add your own annotations to store operational metadata:

Terminal window
kubectl annotate node ks-worker1 maintenance-contact="ops@example.com"

An annotation suits this kind of information better than a label. No selector ever reads an annotation, and its value accepts free text: an address, a sentence, a ticket number. A label value is limited to 63 characters (letters, digits, -, _ and .): the address above, with its @, would be rejected.

Some historical annotations still visible on a node, such as kubeadm.alpha.kubernetes.io/cri-socket or node.alpha.kubernetes.io/ttl, are deprecated: do not take them as a reference.

Troubleshooting

When a Pod does not land where you expect, the cause is often a restriction set on the node that was forgotten, or whose scope was misjudged. Before suspecting the cluster, re-read the taints and the labels of the node concerned: they are what decides placement. The other rows of the table cover adding, replacing and evacuating a node.

SymptomLikely causeSolution
Node NotReady after joiningkubelet does not start or cannot reach the API serverCheck the kubelet logs: journalctl -u kubelet -f
Node without a role (<none>)node-role.kubernetes.io/ label missingkubectl label node <name> node-role.kubernetes.io/worker=
Pod not scheduled despite available resourcesActive taint without a matching tolerationkubectl describe node <name> | grep Taints to identify the taint
Drain blocked by a PDBThe PodDisruptionBudget forbids evicting one more podCheck the PDBs (kubectl get pdb -A), then wait or fix the budget: --force changes nothing here
Drain refused for a pod without a controllerA pod created on its own (without a Deployment, Job or other controller) would never be recreated--force deletes this pod for good: only add the option after checking that the pod has no value
Labels gone after a restartLabels set through the CLI but not in the kubelet configConfigure --node-labels in the kubelet or the provisioning tool
kubectl cordon is not enoughExisting pods stay on the nodecordon only blocks scheduling. To evacuate, use drain.

Hands-on practice

The labels and taints taught above serve to reserve a node. In this lab, the data team takes over the k8s-w2.lab worker. You label the node for this team, make its role readable in kubectl get nodes, note by annotation who to call before a maintenance, then reserve it with a taint whose effect makes the Pods of the other teams already running there leave, without stopping them by hand.

The validation checks four requirements: k8s-w2.lab, and no other node, carries the equipe=data label; kubectl get nodes shows the data role of this node; the maintenance-contact annotation names the data team; and a NoExecute taint reserves the node, so that the entrepot Pod runs there while rapports has left it and still runs elsewhere. A NoSchedule taint is therefore not enough: it does not evict the Pods already in place.

Key takeaways

  • kubectl get nodes -o wide gives a quick view of all nodes with IP, OS and runtime.
  • Labels organize your fleet: environment, zone, disk type. Pods target them through nodeSelector or affinity.
  • Role labels (node-role.kubernetes.io/<role>=) improve cluster readability, but are not a placement or security mechanism on their own.
  • Taints repel pods. They have three effects: NoSchedule (blocks new scheduling), PreferNoSchedule (avoids if possible), NoExecute (evicts existing pods).
  • To replace a node, drain it with drain, delete the object with delete node, provision the new machine, then check that it registers.
  • Kubernetes adds automatic taints tied to the node's state: NoExecute for a not-ready or unreachable node, but every Pod tolerates these two for 300 seconds by default, hence five minutes before it is recreated elsewhere.
  • Automate custom labels through the kubelet configuration or your provisioning tool. For critical labels, apply a clear convention.

Knowledge check

Seven questions cover what decides the placement of Pods: role labels, the effects of a taint, and the difference between a node's capacity and what it has left.

Knowledge check

Check what you have learned with this interactive quiz

7 questions
7 min
70% 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