A DevOps team needs to provide persistent storage to a set of pods that all require read-write access to the same data simultaneously. Which volume type should they use?
Trap 1: hostPath
A hostPath volume mounts a file or directory from the host node's filesystem directly into your Pod. While this allows sharing data between pods on the exact same node, it fails to provide a shared storage solution for pods scheduled across different nodes in a multi-node cluster, and it poses significant security risks.
Trap 2: emptyDir
An emptyDir volume is created when a Pod is assigned to a node and exists only as long as that Pod is running on that node. Because its lifecycle is strictly tied to the hosting Pod, it cannot persist data across Pod restarts or deletions, nor can it be shared with other Pods running elsewhere in the cluster.
Trap 3: PersistentVolumeClaim with ReadWriteOnce
A PersistentVolumeClaim with the ReadWriteOnce (RWO) access mode restricts volume mounting to a single node at a time for read-write operations. If the DevOps team deploys multiple pods across different nodes, only the pods on the first node to claim the volume will be able to write to it, causing scheduling or mounting failures for the others.
- A
PersistentVolumeClaim with ReadWriteMany
A PersistentVolumeClaim configured with the ReadWriteMany (RWX) access mode allows a volume to be mounted as read-write by many nodes concurrently. This is the correct choice for enabling multiple pods distributed across different nodes in a cluster to simultaneously access and modify the same persistent storage backend.
- B
hostPath
Why wrong: A hostPath volume mounts a file or directory from the host node's filesystem directly into your Pod. While this allows sharing data between pods on the exact same node, it fails to provide a shared storage solution for pods scheduled across different nodes in a multi-node cluster, and it poses significant security risks.
- C
emptyDir
Why wrong: An emptyDir volume is created when a Pod is assigned to a node and exists only as long as that Pod is running on that node. Because its lifecycle is strictly tied to the hosting Pod, it cannot persist data across Pod restarts or deletions, nor can it be shared with other Pods running elsewhere in the cluster.
- D
PersistentVolumeClaim with ReadWriteOnce
Why wrong: A PersistentVolumeClaim with the ReadWriteOnce (RWO) access mode restricts volume mounting to a single node at a time for read-write operations. If the DevOps team deploys multiple pods across different nodes, only the pods on the first node to claim the volume will be able to write to it, causing scheduling or mounting failures for the others.