Courseiva
Kubernetes FundamentalseasyMultiple ChoiceObjective-mapped

KCNA Kubernetes Fundamentals Practice Question

A Pod has a container that needs to write logs to a file. The administrator wants the logs to persist even if the container restarts. What is the simplest solution?

⚠ Common exam trap

CNCF often tests the misconception that container restarts always wipe all data, leading candidates to choose persistent storage options like PVCs or hostPath, when in fact emptyDir volumes are specifically designed to survive container restarts within the same Pod.

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

Use an emptyDir volume and mount it at the log path.

An emptyDir volume provides a simple, ephemeral storage solution that persists across container restarts within the same Pod. When a container crashes and is restarted by the kubelet, the emptyDir volume's contents remain intact, allowing log files to survive container restarts without requiring external storage or complex configuration.

Answer analysis

Option-by-option breakdown

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

  • Use a PersistentVolumeClaim for each container.

    Why it's wrong here

    Using a PersistentVolumeClaim (PVC) for each container is incorrect because PVCs provide durable storage for application *data* that needs to persist beyond the Pod's lifecycle, not typically for logs persisting only across container restarts within the same Pod. The simplest solution for this scenario usually involves writing logs to `stdout`/`stderr`, which the container runtime collects, or utilising an `emptyDir` volume if explicit file writing within the Pod is necessary. This option is tempting as PVCs offer persistence, but they are designed for stateful application data that must outlive the Pod itself, making them the correct choice for databases or file storage requiring long-term durability.

  • Use a hostPath volume to write logs directly to the node filesystem.

    Why it's wrong here

    hostPath ties the Pod to a specific node and is not recommended for simple log persistence.

  • Store logs in a ConfigMap.

    Why it's wrong here

    ConfigMaps are read-only and not intended for log storage.

  • Use an emptyDir volume and mount it at the log path.

    Why this is correct

    emptyDir volumes share the Pod's lifetime and persist across container restarts within the same Pod.

About these practice questions

Courseiva writes every KCNA question from scratch — 833 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.