Courseiva
Kubernetes FundamentalseasyMultiple SelectObjective-mapped

KCNA Kubernetes Fundamentals Practice Question

Which TWO of the following are valid ways to view the logs of a pod named 'my-pod'?

⚠ Common exam trap

A common mix-up: candidates confuse `kubectl describe` (which shows pod events and status) with `kubectl logs` (which shows actual application output), or assume `kubectl attach` can retrieve past logs when it only connects to the live process stream.

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 exec my-pod -- cat /var/log/app.log

`kubectl exec my-pod -- cat /var/log/app.log` runs the `cat` command inside the container of the pod, allowing you to read a specific log file directly from the filesystem. This is a valid method when the application writes logs to a file rather than stdout/stderr, or when you need to inspect a log file that is not captured by the standard logging driver.

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 describe pod my-pod

    Why it's wrong here

    This shows metadata and events but not the logs of the container.

  • kubectl exec my-pod -- cat /var/log/app.log

    Why this is correct

    If the application writes logs to a file, this command can retrieve them.

  • kubectl logs my-pod

    Why this is correct

    This is the standard kubectl command to view container logs.

  • kubectl run my-pod -- logs

    Why it's wrong here

    There is no such command; kubectl run creates a new pod.

  • kubectl attach my-pod

    Why it's wrong here

    This attaches to the running process; not used for viewing logs.

About these practice questions

One of 833 original KCNA practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This KCNA 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 KCNA exam.