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?
- A.kubectl cp node/n-03:/var/log ./node-logs
- B.kubectl attach node/n-03 --shell, then look under /var/log
- C.kubectl debug node/n-03 -it --image=busybox, then look under /host/var/log
- 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
- Drain flags for DaemonSets and emptyDir
- CronJob concurrencyPolicy Forbid
- Listing cluster-scoped API resources
- Setting the default namespace in a context
- Session affinity by client IP
- Pod dnsPolicy Default versus ClusterFirst
- Raw block volumes with volumeMode
- CreateContainerConfigError from missing ConfigMap
- Approving a client CertificateSigningRequest
- NetworkPolicy ipBlock with except
- Restoring a PVC from a VolumeSnapshot