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
- A working Kubernetes cluster (v1.37)
kubectlconfigured with enough permissions to manage nodes- Having followed the guide Check Kubernetes cluster health with 5 commands
- Basic knowledge of Pods and taints/tolerations
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:
| Information | What it describes |
|---|---|
| Conditions | Node state: Ready, MemoryPressure, DiskPressure, PIDPressure |
| Capacity / Allocatable | Total resources vs resources available for pods |
| Labels | Key-value metadata to organize and target nodes |
| Taints | Restrictions that repel certain pods |
| Annotations | Internal 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?
kubectl get nodesNAME STATUS ROLES AGE VERSIONks-cp1 Ready control-plane 42h v1.37.0ks-worker1 Ready <none> 42h v1.37.0ks-worker2 Ready <none> 42h v1.37.0The 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:
kubectl get nodes -o wideHow do I inspect a node in detail?
kubectl describe node ks-worker1This 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?
kubectl get nodes --show-labelsThe output can be very long. To filter on a particular label:
kubectl get nodes -l node-role.kubernetes.io/control-planeHow 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.
kubectl label node ks-worker1 env=productionCheck that the label is set:
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:
kubectl label node ks-worker1 env=staging --overwriteHow do I remove a label?
Add a - after the label name:
kubectl label node ks-worker1 env-Which labels are common for nodes?
| Label | Example | Usage |
|---|---|---|
env | production, staging | Separate workloads by environment |
disktype | ssd, hdd | Place I/O-hungry pods on SSD |
zone | eu-west-1a, rack-3 | Spread replicas across several zones |
team | backend, data | Isolate 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: productionFor 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?
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:
kubectl get nodesNAME STATUS ROLES AGE VERSIONks-cp1 Ready control-plane 42h v1.37.0ks-worker1 Ready worker 42h v1.37.0ks-worker2 Ready <none> 42h v1.37.0How do I assign several roles?
A node can have several roles. Simply add a second label:
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.
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.
| Effect | Behavior |
|---|---|
NoSchedule | Prevents new pods (without a toleration) from being scheduled on the node. Pods already present are not affected. |
PreferNoSchedule | The scheduler avoids this node but may place a pod there if there is no alternative. |
NoExecute | Prevents scheduling and evicts existing pods that do not have the toleration. |
How do I add a taint?
kubectl taint nodes ks-worker1 maintenance=planned:NoScheduleThis means: "do not schedule any new pod on ks-worker1, unless it tolerates
the maintenance=planned taint".
Check that the taint is set:
kubectl describe node ks-worker1 | grep -A 5 TaintsHow 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:
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.
kubectl describe node ks-cp1 | grep TaintsTaints: node-role.kubernetes.io/control-plane:NoScheduleWhich 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 taint | Set when | Effect |
|---|---|---|
node.kubernetes.io/not-ready | The node's Ready condition is False | NoSchedule and NoExecute |
node.kubernetes.io/unreachable | The control plane no longer receives the kubelet heartbeat | NoSchedule and NoExecute |
node.kubernetes.io/memory-pressure | Not enough memory | NoSchedule |
node.kubernetes.io/disk-pressure | Not enough disk space | NoSchedule |
node.kubernetes.io/pid-pressure | Too many processes | NoSchedule |
node.kubernetes.io/unschedulable | Cordoned 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:
kubectl get pod <pod> -o jsonpath='{range .spec.tolerations[*]}{.key} {.effect} {.tolerationSeconds}{"\n"}{end}'node.kubernetes.io/not-ready NoExecute 300node.kubernetes.io/unreachable NoExecute 300These 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.
-
Drain the node: evacuate all the pods to other nodes.
Terminal window kubectl drain ks-worker1 --ignore-daemonsets --delete-emptydir-dataThe drain starts with an automatic
cordon, then evicts the pods while respecting the PodDisruptionBudgets. The two options get past two refusals.--ignore-daemonsetsleaves the DaemonSet pods in place, which the drain cannot move and otherwise refuses to process.--delete-emptydir-dataaccepts losing the data ofemptyDirvolumes, 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. -
Check that the pods are rescheduled:
Terminal window kubectl get pods -A -o wide | grep ks-worker1Only DaemonSet pods should remain on the node.
-
Delete the Node object:
Terminal window kubectl delete node ks-worker1The 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. -
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 nodesThe new node appears with the
Readystatus 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:
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.
| Symptom | Likely cause | Solution |
|---|---|---|
Node NotReady after joining | kubelet does not start or cannot reach the API server | Check the kubelet logs: journalctl -u kubelet -f |
Node without a role (<none>) | node-role.kubernetes.io/ label missing | kubectl label node <name> node-role.kubernetes.io/worker= |
| Pod not scheduled despite available resources | Active taint without a matching toleration | kubectl describe node <name> | grep Taints to identify the taint |
| Drain blocked by a PDB | The PodDisruptionBudget forbids evicting one more pod | Check the PDBs (kubectl get pdb -A), then wait or fix the budget: --force changes nothing here |
| Drain refused for a pod without a controller | A 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 restart | Labels set through the CLI but not in the kubelet config | Configure --node-labels in the kubelet or the provisioning tool |
kubectl cordon is not enough | Existing pods stay on the node | cordon 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 widegives a quick view of all nodes with IP, OS and runtime.- Labels organize your fleet: environment, zone, disk type. Pods target them through
nodeSelectoror 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 withdelete node, provision the new machine, then check that it registers. - Kubernetes adds automatic taints tied to the node's state:
NoExecutefor anot-readyorunreachablenode, 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
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
Review
(0/0)Result saved on this device. It will be sent to your account at the next sync. Sync now
Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Upgrade a Kubernetes cluster without downtime
A new full quiz with random questions
Work again only on the questions you missed