Skip to content

KCSA · Domain 2: Kubernetes Cluster Component Security · 22% of the exam

Task 2.11: Storage

Volume types and their risks, hostPath, storage access control, and encryption of data at rest in volumes and Secrets.

Study it

Sample questions

Try each one before opening the answer. Every option is explained, with the CNCF documentation page that proves it.

Question 1 · choose 1

A log shipper DaemonSet mounts the host's /var/log through a hostPath volume: volumeMounts: - name: varlog mountPath: /host/var/log readOnly: true A tmpfs is mounted read-write on the hosts at /var/log/journal, and the container can write there. The node pools are being moved to a container runtime that supports recursive read-only mounts, which takes several weeks. The shipper must keep running on every node during the move, and on each node that already supports it the whole mounted tree must be read-only. What should the team add to the volumeMount?

  1. ArecursiveReadOnly: Enabled
  2. BrecursiveReadOnly: IfPossible
  3. CmountPropagation: HostToContainer
  4. DreadOnlyRootFilesystem: true in the container's securityContext
Show the answer and why
  • ArecursiveReadOnly: Enabled

    Incorrect

    Enabled requires kernel and runtime support for recursive read-only mounts and fails if any requirement is not met, so the shipper would not start on the nodes that are not yet moved.

  • BrecursiveReadOnly: IfPossible

    Correct

    IfPossible attempts the recursive read-only mount and falls back to a plain read-only mount where the node cannot do it, so the shipper runs everywhere and submounts are read-only on supported nodes.

  • CmountPropagation: HostToContainer

    Incorrect

    Propagation controls whether later host mounts appear in the container, not whether they are writable; recursive read-only mounts even require propagation to be unset or None.

  • DreadOnlyRootFilesystem: true in the container's securityContext

    Incorrect

    That setting makes the container's root filesystem read-only; volumes mounted into the container keep their own mount settings.

On Linux a read-only mount is not recursively read-only: a filesystem mounted read-write below the mounted path stays writable. recursiveReadOnly closes that gap when readOnly is true. Enabled insists on support from the kernel and both runtime layers and fails otherwise, while IfPossible applies the recursive mount where it can and falls back elsewhere, which fits a gradual runtime migration.

Question 2 · choose 1

In a Pod, the container app mounts a shared volume with readOnly: true, and the container sidecar mounts the same volume without readOnly. What does that mean for the volume's data?

  1. Aapp cannot write to it, but sidecar can, because readOnly applies only to that mount
  2. BNeither container can write, because one read-only mount locks the volume
  3. CBoth containers can write, because readOnly is ignored for shared volumes
  4. DThe Pod is rejected for mixing read-only and read-write mounts
Show the answer and why
  • Aapp cannot write to it, but sidecar can, because readOnly applies only to that mount

    Correct

    The volumes documentation says readOnly does not make the volume itself read-only: that container cannot write, while other containers in the Pod may mount the same volume read-write.

  • BNeither container can write, because one read-only mount locks the volume

    Incorrect

    A read-only mount affects only the container that declares it.

  • CBoth containers can write, because readOnly is ignored for shared volumes

    Incorrect

    readOnly is honored for the container that sets it.

  • DThe Pod is rejected for mixing read-only and read-write mounts

    Incorrect

    Mixing mount modes for one volume is allowed.

readOnly on a volumeMount restricts only the container that declares it. Another container in the same Pod can still mount the volume read-write, so protecting data requires every mount to be read-only.

Question 3 · choose 1

A database Pod needs storage on a node's local disk. What does the Kubernetes volumes documentation suggest instead of a hostPath volume?

  1. AAn emptyDir volume with medium set to Memory
  2. BA hostPath volume of type DirectoryOrCreate
  3. CA projected volume of the node's directory
  4. DA local PersistentVolume
Show the answer and why
  • AAn emptyDir volume with medium set to Memory

    Incorrect

    A memory-backed emptyDir is lost when the Pod goes away and does not use the local disk.

  • BA hostPath volume of type DirectoryOrCreate

    Incorrect

    Changing the hostPath type keeps all of hostPath's security risks.

  • CA projected volume of the node's directory

    Incorrect

    Projected volumes combine API sources such as Secrets and ConfigMaps; they do not mount node directories.

  • DA local PersistentVolume

    Correct

    The volumes documentation says to avoid hostPath where possible, for example by defining a local PersistentVolume and using that instead.

hostPath volumes present many security risks, from exposing node credentials to differing behavior across nodes. For local disk storage the documentation suggests a local PersistentVolume, managed by administrators and consumed through claims.

Practice domain 2 →Practice all domains →