Docker Certified Associate (DCA) — Question 31
You are running only Kubernetes workloads on a worker node that requires maintenance, such as installing patches or an OS upgrade.
Which command must be run on the node to gracefully terminate all pods on the node, while marking the node as unschedulable?
Answer options
- A. ‘kubectl cordon <node name>’
- B. ‘docker swarm leave’
- C. ‘kubectl drain <node name>’
- D. ‘docker node update --availability drain <node name>’
Correct answer: C
Explanation
The command ‘kubectl drain <node name>’ is used to safely evict all pods from a node, ensuring they are terminated gracefully while marking the node as unschedulable. In contrast, ‘kubectl cordon <node name>’ only prevents new pods from being scheduled but does not terminate existing ones. The other options involve Docker commands that are not relevant to Kubernetes workloads.