CertKeen

Certified Kubernetes Administrator (CKA) · Free practice question 8 of 12

Debugging a node with kubectl debug

An admin at Thornaby Steel cannot SSH to node n-03 but has cluster-admin access. They need a shell to look at the node's files under /var/log. Which approach works?

  1. A.kubectl cp node/n-03:/var/log ./node-logs
  2. B.kubectl attach node/n-03 --shell, then look under /var/log
  3. C.kubectl debug node/n-03 -it --image=busybox, then look under /host/var/log
  4. D.kubectl exec node/n-03 -it -- sh, then look under /var/log
Show answer and explanation

Correct answer: C. kubectl debug node/n-03 -it --image=busybox, then look under /host/var/log

Why: kubectl debug node/<name> creates a pod on that node in the host namespaces with the node's root file system mounted at /host, so node files are reachable under /host. kubectl exec, attach and cp act on containers in pods, not on nodes.

More free Certified Kubernetes Administrator (CKA) questions