- Take me to Practice Test
Solutions to the Practice Test - Taints and Tolerations
-
How many nodes exist on the system?
$ kubectl get nodes
Count the nodes
-
Do any taints exist on node01 node?
$ kubectl describe node node01
Find the
Taints
property in the output. -
Create a taint on node01 with key of spray, value of mortein and effect of NoSchedule
kubectl taint nodes node01 spray=mortein:NoSchedule
-
Create a new pod with the nginx image and pod name as mosquito.
kubectl run mosquito --image nginx
-
What is the state of the POD?
kubectl get pods
Check the
STATUS
column -
Why do you think the pod is in a pending state?
Mosqitoes don't like mortein!
So the answer is that the pod cannot tolerate the taint on the node.
-
Create another pod named bee with the nginx image, which has a toleration set to the taint mortein.
Allegedly bees are immune to mortein!
-
Create a YAML skeleton for the pod imperatively
kubectl run bee --image nginx --dry-run=client -o yaml > bee.yaml
-
Edit the file to add the toleration
vi bee.yaml
-
Add the toleration. This goes at the same indentation level as
containers
as it is a POD setting.tolerations: - key: spray value: mortein effect: NoSchedule operator: Equal
-
Save and exit, then create pod
kubectl create -f bee.yaml
-
-
Information only.
-
Do you see any taints on controlplane node?
kubectl describe node controlplane
Examine the
Taints
property. -
Remove the taint on controlplane, which currently has the taint effect of NoSchedule.
kubectl taint nodes controlplane node-role.kubernetes.io/control-plane:NoSchedule-
-
What is the state of the pod mosquito now?
$ kubectl get pods
-
Which node is the POD mosquito on now?
$ kubectl get pods -o wide
This also explains why the
mosquito
pod colud schedule anywhere. It also could not toleratecontrolplane
taints, which we have now removed.