CertLumen

Certified Kubernetes Application Developer (CKAD) · Section 3 · 15% of the exam

Utilize container logs

One of the objectives of the Certified Kubernetes Application Developer (CKAD) exam, in the section “Application Observability and Maintenance”. Here is what it covers, the points to remember and a question to try.

What it covers

Use kubectl top, get, describe and events to see what your application is doing, then use kubectl logs with the right flags to read current, previous and multi-container output. You will also learn where logs live and why they disappear.

Points to remember

  • kubectl top pod|node needs metrics-server and shows current CPU (millicores) and memory, not history, requests or limits.
  • --sort-by=cpu|memory, --containers, -A and -l refine kubectl top.
  • kubectl describe shows conditions, state, last state, exit code and events; events live about one hour by default.
  • kubectl get -o wide|yaml|jsonpath, --sort-by, -w and kubectl wait cover most observation tasks.
  • Containers should log to stdout and stderr; the kubelet stores and rotates the files (10Mi and 5 files by default).

Try a question

A Pod named api has containers app and proxy. A developer wants the last 100 lines from proxy with timestamps. Which command is correct?

  1. Akubectl logs api -c proxy --tail=100 --timestamps
  2. Bkubectl logs api proxy --lines=100 --timestamps
  3. Ckubectl logs api --container=app --limit=100
  4. Dkubectl logs proxy --pod=api --tail=100
Show the answer

A. Use -c or --container to choose a container, --tail=N for the number of lines and --timestamps for time prefixes.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Monitoring with kubectl and Reading Container Logs teaches this objective (about 40 minutes), and 11 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.

More in this section

← Previous objective · All 24 objectives · Next objective →