Skip to main content
In this lesson, you will learn how to work with taints and tolerations in Kubernetes. The walkthrough covers checking the cluster’s nodes, examining and modifying taints on a node, deploying pods with and without tolerations, and finally, removing a taint from the control plane node.

1. Counting the Nodes

First, determine the total number of nodes (including the control plane) in your cluster. Run the following command to view the nodes:
As shown, the cluster contains two nodes: one control plane node and one worker node (node01).

2. Checking for Taints on node01

To verify if there are any taints on node01, list the nodes again:
Next, inspect node01 in detail:
Since the “Taints” field shows <none>, node01 currently does not have any taints.

3. Adding a Taint to node01

Now, add a taint to node01 that prevents pods without the necessary toleration from being scheduled there. Use the following parameters:
  • Key: spray
  • Value: moreteam
  • Effect: NoSchedule
Execute this command:
After running this command, node01 now has the taint. Pods that do not tolerate this taint will not be scheduled on node01.

4. Creating the “mosquito” Pod (Without Tolerations)

Next, create a pod named “mosquito” that uses the nginx image. Since this pod lacks a toleration for the taint on node01, it will remain in a pending state:
Verify the pod’s status:
Inspect the pod details to confirm the scheduling issue:
The error indicates that the pod did not tolerate the {spray: moreteam:NoSchedule} taint on node01.

5. Creating the “bee” Pod with a Toleration

To schedule a pod with a toleration for the taint on node01, create a new pod called “bee” using the nginx image. Since you cannot specify tolerations directly with the kubectl run command, generate a YAML manifest with a dry run and edit it accordingly. Generate the YAML manifest:
Redirect the output to a file:
Open the generated file (bee.yaml) and add the following “tolerations” section under the spec:
Save the changes and apply the manifest:
Monitor the creation process:
Finally, confirm that the “bee” pod is running on node01:

6. Removing the Control Plane Taint

The control plane node initially had a taint that prevented regular pods from being scheduled on it. To allow the “mosquito” pod to run, remove this taint. First, check the taint on the control plane:
Remove the taint with the following command:
Verify that the taint has been removed:
Once the taint is removed, the “mosquito” pod, which was pending earlier, is automatically scheduled on the control plane node. Confirm its status:

7. Summary

This lesson demonstrated the following steps: This concludes the lesson on taints and tolerations in Kubernetes. For more information, please refer to the Kubernetes Documentation.

Watch Video