Question 458 of 997
Monitoring Logging and Runtime SecurityeasyMultiple ChoiceObjective-mapped

CKS Monitoring Logging and Runtime Security Practice Question

This CKS practice question tests your understanding of monitoring logging and runtime security. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

A DevOps engineer notices that a container's stdout logs are not appearing in the `kubectl logs` output. The container runs a legacy application that writes logs to a file inside the container. What is the most efficient way to capture these logs without modifying the application?

Question 1easymultiple choice
Full question →

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

Add a sidecar container that reads the log file and outputs to stdout.

Option B is correct because deploying a sidecar container that tails the log file and writes to its own stdout is the most efficient, Kubernetes-native pattern for capturing logs from applications that write to files. The sidecar container shares the same Pod and volume, reads the log file (e.g., using `tail -F`), and outputs to stdout, which is then collected by `kubectl logs` and the cluster-level logging pipeline. This approach requires no modification to the legacy application and leverages the existing container runtime and kubelet log collection.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Configure the kubelet to rotate logs from the container's filesystem.

    Why it's wrong here

    Kubelet only captures container stdout/stderr, not file logs.

  • Add a sidecar container that reads the log file and outputs to stdout.

    Why this is correct

    The sidecar pattern streams file logs to stdout for kubectl logs.

    Related concept

    Read the scenario before looking for a memorised answer.

  • Use `kubectl cp` to periodically copy logs from the container.

    Why it's wrong here

    Manual copying is not efficient or real-time.

  • Install a syslog daemon in the container to forward logs.

    Why it's wrong here

    Modifying the image is not efficient and violates immutability.

Common exam traps

Common exam trap: answer the scenario, not the keyword

CNCF often tests the sidecar logging pattern as the standard Kubernetes solution for capturing file-based logs, and the trap here is that candidates may incorrectly choose kubelet log rotation (Option A) thinking it applies to all container logs, when in fact it only applies to the container runtime's own stdout/stderr streams.

Detailed technical explanation

How to think about this question

Under the hood, the sidecar pattern uses a shared emptyDir volume mounted into both containers; the legacy application writes logs to that volume, and the sidecar runs a command like `tail -F /var/log/app.log` to stream the content to its stdout. The kubelet then captures that stdout stream and makes it available via the kube-apiserver's log endpoint, following the Kubernetes logging architecture where each container's stdout/stderr is stored in JSON files on the node (typically under /var/log/pods/). In a real-world scenario, this pattern is essential for legacy Java applications that use Log4j file appenders or for applications that write to access logs in /var/log/nginx/access.log.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A small business has 20 workstations on the 192.168.1.0/24 network and one public IP from its ISP. The router uses PAT (NAT overload) so all 20 devices share one public address using different source ports. NAT questions test whether you understand the four address terms and which direction each translation applies.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related CKS practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free CKS practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this CKS question test?

Monitoring Logging and Runtime Security — This question tests Monitoring Logging and Runtime Security — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: Add a sidecar container that reads the log file and outputs to stdout. — Option B is correct because deploying a sidecar container that tails the log file and writes to its own stdout is the most efficient, Kubernetes-native pattern for capturing logs from applications that write to files. The sidecar container shares the same Pod and volume, reads the log file (e.g., using `tail -F`), and outputs to stdout, which is then collected by `kubectl logs` and the cluster-level logging pipeline. This approach requires no modification to the legacy application and leverages the existing container runtime and kubelet log collection.

What should I do if I get this CKS question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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