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:2. Checking for Taints on node01
To verify if there are any taints on node01, list the nodes again: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
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:{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 thekubectl run command, generate a YAML manifest with a dry run and edit it accordingly.
Generate the YAML manifest:
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: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.