CKA Troubleshooting Practice Question
You run 'kubectl get pods' and see that a pod named 'db' is in 'CrashLoopBackOff'. Which TWO commands are most useful for diagnosing the issue? (Choose two)
⚠ Common exam trap
Test-takers frequently choose 'kubectl get pod -o yaml' thinking it shows runtime errors, but it only shows the desired and current state in YAML format, not the event history or container logs that are essential for diagnosing a CrashLoopBackOff.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
kubectl describe pod db
Option B, 'kubectl describe pod db', is correct because it surfaces the pod's Events section, which shows scheduling failures, image pull errors, container restarts, and the exit codes/reasons behind the CrashLoopBackOff. Option C, 'kubectl logs db', is correct because it retrieves the container's stdout/stderr, revealing the application-level error or stack trace that caused the process to exit and restart repeatedly. Together these two commands cover both the kubelet-side view (describe) and the application-side view (logs) of why the container keeps crashing. Option A, 'kubectl top pod db', only reports CPU/memory usage and cannot explain a crash loop, and it often fails anyway if the container isn't running. Option D, 'kubectl get pod db -o yaml', shows the pod spec and status but not the event history or application output needed to diagnose the crash. Option E, 'kubectl exec db -- /bin/sh', is not useful because the container is not staying up long enough to exec into, and it doesn't reveal the prior crash cause.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
kubectl top pod db
Why it's wrong here
This command queries the Metrics Server to display real-time CPU and memory utilization for the pod. If the pod is in a CrashLoopBackOff state or is not actively running, the Metrics Server will not have active telemetry data to report. Consequently, this command will fail to provide any diagnostic information regarding the root cause of the crash.
- ✓
kubectl describe pod db
Why this is correct
This command retrieves detailed lifecycle information directly from the Kubernetes API server, including the pod's current state, container statuses, and historical events. Crucially, it displays the "Last State" field, which reveals the exit code and termination message of the previous failed container run. This makes it an essential first-line troubleshooting tool for identifying configuration or startup failures.
- ✓
kubectl logs db
Why this is correct
This command retrieves the standard output (stdout) and standard error (stderr) streams from the container's application process. When a pod is crashing, inspecting these logs is vital because they capture runtime application exceptions, database connection failures, or syntax errors that occurred immediately before termination. You can also append the "--previous" flag to view logs from the most recently crashed instance.
- ✗
kubectl get pod db -o yaml
Why it's wrong here
While this command outputs the complete declarative configuration and current status block of the pod in YAML format, it lacks detailed event logs and application-level error messages. It is useful for verifying environment variables, volume mounts, or image tags, but it does not provide the specific runtime error details or exit codes needed to diagnose why the application process crashed.
- ✗
kubectl exec db -- /bin/sh
Why it's wrong here
This command attempts to initiate an interactive shell session inside a running container by spawning a process via the container runtime. If the pod is crashing or in a CrashLoopBackOff state, there is no active, running container to attach to. As a result, the API server will reject the connection request with an error, making it impossible to inspect the container's internal filesystem.
Go deeper
Related to this question
Learn chapter
Configuring Scheduling and Affinity
Key term
kubectl Command Reference
kubectl is the command-line tool used to interact with and manage Kubernetes clusters by sending commands to the Kubernetes API.
Key term
Log Analysis
Log analysis is the process of reviewing and interpreting system-generated records to understand what happened in an application or infrastructure.
About these practice questions
Courseiva writes every CKA question from scratch — 726 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This CKA practice question is part of Courseiva's free CNCF certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the CKA exam.