Learn to manage taints and tolerations in Kubernetes, including checking nodes, modifying taints, and deploying pods with or without tolerations.
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.
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:
Copy
Ask AI
root@controlplane:~# kubectl run mosquito --image=nginxpod/mosquito createdroot@controlplane:~#
Verify the pod’s status:
Copy
Ask AI
root@controlplane:~# kubectl get podsNAME READY STATUS RESTARTS AGEmosquito 0/1 Pending 0 3m37sroot@controlplane:~#
Inspect the pod details to confirm the scheduling issue:
Copy
Ask AI
root@controlplane:~# kubectl describe pod mosquitoName: mosquitoNamespace: defaultPriority: 0Node: <none>Labels: run=mosquitoAnnotations: <none>Status: PendingIP: <none>Containers: mosquito: Image: nginx Port: <none> Host Port: <none> Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-f6lxf (ro)Conditions: Type Status PodScheduled FalseVolumes: default-token-f6lxf: Type: Secret (a volume populated by a Secret) SecretName: default-token-f6lxf Optional: falseQoS Class: BestEffortTolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s node.kubernetes.io/unreachable:NoExecute op=Exists for 300sEvents: Type Reason Age From Message ---- ------ ---- ---- ------- Warning FailedScheduling 45s (x2 over 45s) default-scheduler 0/2 nodes are available: 1 node(s) had taint {spray: moreteam:NoSchedule}, that the pod didn't tolerate, 1 node(s) had taint {node-role.kubernetes.io/master:NoSchedule}, that the pod didn't tolerate.root@controlplane:~#
The error indicates that the pod did not tolerate the {spray: moreteam:NoSchedule} taint on node01.
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:
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: