How many Nodes exist on the system? including the master node
master $ kubectl get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 11m v1.18.0
node01 Ready <none> 10m v1.18.0
Do any taints exist on node01?
master $ kubectl describe node node01 | grep Taint
Taints: <none>
Create a taint on node01 with key of 'spray', value of 'mortein' and effect of 'NoSchedule'
master $ kubectl taint nodes node01 spray="mortein":No-Schedule
error: invalid taint effect: No-Schedule, unsupported taint effect
See 'kubectl taint -h' for help and examples
master $ kubectl taint nodes node01 spray="mortein":NoSchedule
node/node01 tainted
Create a new pod with the NGINX image, and Pod name as 'mosquito'
master $ kubectl run mosquito --image=nginx --dry-run=client -o yaml > mosquito.yaml
master $ ls -ltr
total 12
drwxr-xr-x 2 root root 4096 May 21 12:41 Desktop
drwxr-xr-x 4 root root 4096 Jun 8 22:04 go
-rw-r--r-- 1 root root 241 Jul 22 03:23 mosquito.yaml
master $ vi mosquito.yaml
master $ kubectl apply -f mosquito.yaml
pod/mosquito created
master $ kubectl get pods
NAME READY STATUS RESTARTS AGE
mosquito 0/1 Pending 0 6s
Why do you think the pod is in a pending state?
master $ kubectl describe pods mosquito
If you observed the description of the pods properly upto the bottom, the following error message can be seen which mean due to taint on given node, the scheduling of pod is failed.
Warning FailedScheduling 37s (x4 over 3m16s) default-scheduler 0/2 nodes are available: 1 node(s) had taint {node-role.kubernetes.io/master: }, that the pod didn't tolerate, 1 node(s) had taint {spray: mortein}, that the pod didn't tolerate.
Create another pod named 'bee' with the NGINX image, which has a toleration set to the taint Mortein info_outline Hint Image name: nginx Key: spray Value: mortein Effect: NoSchedule Status: Running
master $ kubectl run bee --image=nginx --dry-run=client -o yaml > bee.yaml
master $ ls -ltr
total 16
drwxr-xr-x 2 root root 4096 May 21 12:41 Desktop
drwxr-xr-x 4 root root 4096 Jun 8 22:04 go
-rw-r--r-- 1 root root 241 Jul 22 03:23 mosquito.yaml
-rw-r--r-- 1 root root 226 Jul 22 03:32 bee.yaml
master $ vi bee.yaml
edit the bee.yaml to add all those mentioned values from the question on tolerations section
tolerations:
-key: spray
operator: Equal
value: mortein
effect: NoSchedule
Remove the taint on master, which currently has the taint effect of NoSchedule
master $ kubectl taint nodes master node-role.kubernetes.io/master:NoSchedule-
node/master untainted
Notice the - sign at the end of the command, we would use exactly same command for tainting the master with NoSchedule except the - sign at the end .
Which node is the POD 'mosquito' on now?
master $ kubectl get pods mosquito -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
mosquito 1/1 Running 0 32m 10.244.0.4 master <none> <none>
No comments:
Post a Comment