Skip to main content
This lab demonstrates how Kubernetes taints and tolerations control pod scheduling. You’ll inspect nodes, add a taint, attempt to schedule pods, add a toleration to a pod manifest so it can be scheduled onto a tainted node, and finally remove a taint from the control plane. Prerequisites:
  • kubectl configured to communicate with the cluster
  • A two-node cluster (control plane + worker)

1) Count the nodes in the cluster

Run:
Answer: 2 nodes — controlplane and node01.

2) Check if node01 has any taints

Describe the node:
Conclusion: node01 currently has no taints (Taints: <none>).

3) Add a taint to node01

Taint node01 with key spray, value mortein, effect NoSchedule:
Example session:
Verify the taint:

4) Create a pod (mosquito) and observe scheduling failure

Create the pod:
Describe the pod to see scheduling status:
The pod remains in Pending because it doesn’t tolerate the taints on either node:
  • The control plane has the built-in node-role.kubernetes.io/master:NoSchedule taint.
  • node01 now has spray=mortein:NoSchedule.
A taint prevents pods from being scheduled onto a node unless the pod includes a matching toleration in its pod spec. Tolerations do not grant scheduling; they only allow the scheduler to consider the node.

5) Create a pod (bee) that tolerates spray=mortein:NoSchedule

You cannot add a toleration via the simple kubectl run flags, so generate a base YAML and edit it:
The generated YAML:
Refer to the Kubernetes docs for toleration syntax: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/
A screenshot of a Kubernetes website search results page for the query "taints tolerations," showing links like "Taints and Tolerations | Kubernetes" and other related docs. A blue banner at the top notes the Dockershim removal for Kubernetes 1.24.
Example toleration formats:
Add the toleration to bee.yaml so it tolerates spray=mortein:NoSchedule:
Apply the manifest:
Check pod placement:
Result: bee is scheduled to node01 because it tolerates the spray=mortein:NoSchedule taint. mosquito remains Pending.

6) Inspect control plane taints and remove the master taint

Check taints on the control plane:
Warning: In production clusters, removing the control plane/master taint allows regular pods to be scheduled on control plane nodes. This is generally discouraged unless you understand the operational implications.
Removing the control plane/master taint may result in workloads running on control plane components. Only untaint control plane nodes if you intend to schedule workloads there (e.g., in single-node or small test clusters).
Remove the master taint (note the trailing - to delete the taint):
After this, the scheduler can place pods on the control plane node.

7) Verify pods are scheduled

Now mosquito runs on controlplane (because the master taint was removed), and bee stays on node01 (because it tolerates the spray=mortein:NoSchedule taint).

Quick reference: common taint/toleration commands


Summary

  • Taints repel pods from nodes unless pods include matching tolerations.
  • Tolerations are specified in the pod spec (YAML) and must match the taint key/value/effect (depending on operator) to allow scheduling.
  • Use kubectl taint to add and remove taints; append a trailing - to remove a taint.
  • Be cautious when removing control plane taints — running workloads on control plane nodes is typically not recommended for production clusters.
Further reading:

Watch Video