CKA Troubleshooting 1 — Questions and Answers
Question 1: How do you view logs for a specific container named 'nginx' in a multi-container pod named 'mypod'?
- kubectl logs mypod -c nginx (Correct answer)
- kubectl logs mypod --container=nginx --all
- kubectl describe pod mypod -c nginx
- kubectl get logs mypod nginx
Correct answer: kubectl logs mypod -c nginx
The -c flag specifies the container name when a pod runs multiple containers.
Question 2: A pod is stuck in the 'Pending' state. Which command provides the most useful diagnostic information?
- kubectl get pods -o wide
- kubectl describe pod <pod-name> (Correct answer)
- kubectl logs <pod-name>
- kubectl exec -it <pod-name> -- /bin/sh
Correct answer: kubectl describe pod <pod-name>
kubectl describe shows the Events section and conditions that reveal why a pod is pending, such as insufficient resources or unschedulable nodes.
Question 3: What does the 'CrashLoopBackOff' status indicate for a pod?
- The pod is waiting for a PersistentVolume to be provisioned
- The pod's container repeatedly crashes and Kubernetes is backing off restart attempts (Correct answer)
- The pod failed to pull its container image from the registry
- The pod was evicted due to node memory pressure
Correct answer: The pod's container repeatedly crashes and Kubernetes is backing off restart attempts
CrashLoopBackOff means the container starts, crashes, and Kubernetes keeps restarting it with increasing exponential delays.
Question 4: Which command lists events in a specific namespace sorted chronologically?
- kubectl get events -n <namespace> --sort-by='.lastTimestamp' (Correct answer)
- kubectl describe events -n <namespace>
- kubectl logs events -n <namespace>
- kubectl get pods -n <namespace> --events
Correct answer: kubectl get events -n <namespace> --sort-by='.lastTimestamp'
kubectl get events with --sort-by='.lastTimestamp' lists events in chronological order, making it easy to trace the sequence of recent issues.
Question 5: A node shows 'NotReady' in kubectl get nodes. Which command gives the most detail about the node's condition?
- kubectl logs node/<node-name>
- kubectl describe node <node-name> (Correct answer)
- kubectl get node <node-name> -o yaml
- kubectl top node <node-name>
Correct answer: kubectl describe node <node-name>
kubectl describe node shows Conditions, allocatable resources, taints, and events that explain why a node is NotReady.
Question 6: You need a temporary interactive debug pod to troubleshoot network connectivity in the cluster. Which command is most appropriate?
- kubectl run debug --image=busybox --restart=Never --rm -it -- /bin/sh (Correct answer)
- kubectl create debug --image=busybox -it
- kubectl apply -f debug-pod.yaml --interactive
- kubectl exec debug -- /bin/sh
Correct answer: kubectl run debug --image=busybox --restart=Never --rm -it -- /bin/sh
kubectl run with --restart=Never --rm -it creates a temporary interactive pod that is automatically deleted when you exit the shell.
Question 7: Where are kubelet logs found on a systemd-based Linux node?
- /var/log/kubelet.log
- journalctl -u kubelet (Correct answer)
- /etc/kubernetes/logs/kubelet.log
- kubectl logs -n kube-system kubelet
Correct answer: journalctl -u kubelet
On systemd-based systems, kubelet is managed as a systemd service, so its logs are accessible via journalctl -u kubelet.
How do you view logs for a specific container named 'nginx' in a multi-container pod named 'mypod'?