Courseiva
Cloud Native ObservabilitymediumMultiple ChoiceObjective-mapped

KCNA Cloud Native Observability Practice Question

A developer wants to view the logs of a specific container named 'sidecar' inside a pod named 'app-pod'. Which command should they use?

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 logs app-pod -c sidecar

The -c flag specifies the container name. The correct command is 'kubectl logs app-pod -c sidecar'.

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 log app-pod --container sidecar

    Why it's wrong here

    Incorrect; the command should be 'kubectl logs', not 'kubectl log'.

  • kubectl logs app-pod sidecar

    Why it's wrong here

    Incorrect; the container name must be specified using the -c flag, not as a second positional argument.

  • kubectl logs -c sidecar app-pod

    Why it's wrong here

    This command places the -c flag before the pod name, which is not the conventional order. The standard syntax is 'kubectl logs <pod> -c <container>', so option D is correct.

  • kubectl logs app-pod -c sidecar

    Why this is correct

    Correct; this uses the proper syntax: kubectl logs <pod-name> -c <container-name>.

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

Same concept, more angles

1 more way this is tested on KCNA

These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.

Variation 1. A developer wants to view the logs of a specific container named 'sidecar' in a pod called 'web-app'. Which command should they use?

medium
  • A.kubectl logs sidecar --pod web-app
  • B.kubectl logs -c sidecar web-app
  • C.kubectl logs sidecar web-app
  • D.kubectl logs web-app -c sidecar

Why D: The -c flag specifies the container name when a pod has multiple containers.

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.