Courseiva
Application Design and BuildmediumMultiple ChoiceObjective-mapped

CKAD Application Design and Build Practice Question

A DevOps engineer wants to deploy a logging sidecar container that reads log files from the main application container. Which volume type should be used to share files between the two containers?

⚠ Common exam trap

Test-takers frequently confuse persistentVolumeClaim with a general-purpose shared volume, not realizing it is for persistent, Pod-independent storage, while emptyDir is the correct ephemeral volume for sharing files between containers in 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

emptyDir

An emptyDir volume is the correct choice because it provides a shared, ephemeral storage space that is created when a Pod is assigned to a node and exists as long as that Pod is running. Both the main application container and the sidecar container can mount the same emptyDir volume at different mount paths, allowing the sidecar to read log files written by the main container. This volume type is ideal for sharing files between containers in the same Pod without requiring persistent storage.

Answer analysis

Option-by-option breakdown

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

  • emptyDir

    Why this is correct

    emptyDir is a pod-scoped volume that is created empty when a pod is scheduled and survives only as long as the pod runs. It is mounted into all containers sharing the same lifecycle, making it the standard choice for a sidecar that reads logs written by the main application because both can access the same files without any persistent storage overhead. Its ephemeral nature is exactly what you want here—logs are consumed immediately and discarded with the pod, so no cleanup or durability guarantees are needed.

  • persistentVolumeClaim

    Why it's wrong here

    A persistentVolumeClaim requests durable storage from a storage class, which is managed by the cluster and often backed by external infrastructure like cloud disks or NFS. That would be overkill and actively harmful for sidecar log sharing, because the sidecar only needs a temporary scratch space that disappears with the pod; instead of providing that fast intra-pod communication, a PVC introduces provisioning delays, network I/O, and leftover data that can conflict with future pods. For an ephemeral logging sidecar, any persistent storage is unnecessary and violates the pod-scoped sharing model.

  • configMap

    Why it's wrong here

    A configMap volume is designed to inject static configuration data—files or environment variables—into the pod as read-only files, and its contents are defined declaratively by the user, not generated by a running application. When a container writes its logs to a mount point, that data is dynamic and constantly changing, so a configMap simply cannot function as a writable shared space for live log files. Even if you tried, Kubernetes does not allow a configMap volume to be written by containers, making it impossible for the main app to persist logs there for the sidecar to read.

  • hostPath

    Why it's wrong here

    hostPath mounts a directory or file from the node's filesystem directly into the pod, which creates an unnecessary dependency on the specific node where the pod is scheduled. Because hostPath data lives on the node, the pod cannot move across nodes, and the sidecar would be reading from a host-level path rather than a pod-level shared volume, breaking the clean container-to-container communication that emptyDir provides. This approach introduces node-specific security and isolation risks and requires the same path to exist on every potential node, making it unsuitable for portable sidecar log collection.

About these practice questions

This CKAD question is part of Courseiva's 160-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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 CKAD 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 CKAD exam.