Certified Kubernetes Administrator (CKA) · Section 5 · 30% of the exam
Manage and evaluate container output streams
One of the objectives of the Certified Kubernetes Administrator (CKA) exam, in the section “Troubleshooting”. Here is what it covers, the points to remember and a question to try.
What it covers
Kubernetes logging starts with what a container writes to stdout and stderr. This lesson covers kubectl logs and its flags, previous containers, multi-container and multi-Pod selection, where logs live on the node, rotation, system component logs, sidecar patterns, and the tools beyond logs: describe, events, exec and kubectl debug.
Points to remember
- Containers should log to stdout and stderr; kubectl logs reads what the runtime captured.
- --previous (-p) shows the last terminated instance and is the tool for CrashLoopBackOff.
- -c selects a container, --all-containers shows all, -l selects Pods by label, --prefix labels lines.
- --since, --tail, --timestamps and -f control the window; with -l the default tail is 10.
- Node files: /var/log/pods/<ns>_<pod>_<uid>/<container>/N.log and symlinks in /var/log/containers.
Try a question
A Pod named api-5c7 is in CrashLoopBackOff. Which command shows the output of the container instance that crashed?
- A
kubectl logs api-5c7 --follow - B
kubectl logs api-5c7 --previous - C
kubectl describe node - D
kubectl get events --previous
Show the answer
B. In a crash loop the current instance is new. The error is in the previous one.
Written for practice in the style of the exam: never a question from the real exam.
In the course
The lesson Container Output Streams and Logs teaches this objective (about 45 minutes), and 17 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.