Kubernetes CKA sample exam question 30 with answer

Question
There are 3 nodes in the cluster. Create DaemonSet (name: my-pod, image: nginx) on each node except one (worker-node-3)

Answer
Get env details:

kubectl get nodes
we can see 3 nodes on the cluster.
To make node unschedulable for DaemonSet, we must taint it:
kubectl taint node worker-node-3 env=qa:NoSchedule
Create manifest file - as imperative creation of DaemonSet is not available, we will do for Deployment:
kubectl create deploy my-pod --image=nginx --dry-run=client -o yaml
Adjust the manifest to look like this:
apiVersion: apps/v1
kind: DaemonSet
metadata:
  labels:
    app: my-pod
  name: my-pod
spec:
  selector:
    matchLabels:
      app: my-pod
  template:
    metadata:
      labels:
        app: my-pod
    spec:
      containers:
      - image: nginx
        name: nginx
Apply:
kubectl apply -f ds.yaml
Check:
kubectl get ds
kubectl get po -o wide
we can see that the desired number of pods is 2 instead of 3 and no pod are deployed on worker-node-3