Kubernetes CKA sample exam question 28 with answer

Question
Create a new deployment called nginx-deploy, with image nginx:1.16 and 8 replica. There are 5 worker nodes in the cluster.
Please make sure no pod will get deployed on 2 worker nodes, mentioned below:
worker-node-1
worker-node-2
Note: revert any changes that you did in cluster.

Answer
Get env details:

kubectl get nodes
we can see that indeed are 5 worker nodes in the cluster.
To make a node unschedulable we must cordon it. So, proceed with this:
kubectl cordon worker-node-1
kubectl cordon worker-node-2
Get nodes status:
kubectl get nodes
we can see that for those 2 cordoned node the status is changed to SchedulingDisabled
Create the deployment per requirements:
kubectl create deploy nginx-deploy --image nginx:1.16 --replicas 8
Get status of pods:
kubectl get po -o wide
we can see that no pods are deployed on cordoned nodes.
Now, revert the changes and uncordon nodes:
kubectl uncordon worker-node-1
kubectl uncordon worker-node-2
Verify:
kubectl get nodes
kubectl get po -o wide