An access mode describes how a PersistentVolume may be mounted for reading and writing. An application requests one in a PersistentVolumeClaim (PVC), alongside a minimum storage size. The choice matters when more than one pod needs the same data: some modes limit use to one pod, while others allow sharing across nodes. section 10.2.1 section 10.6
Listing 10.1 A minimal PVC definition using the default storage class
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: quiz-data
spec: #1
resources: #2
requests: #2
storage: 1Gi #2
accessModes: #3
- ReadWriteOncePod #3
This minimal claim requests 1Gi of storage with `ReadWriteOncePod` access. It relies on the cluster’s default StorageClass. section 10.2.1
Choose the mode that matches who needs to use the volume:
- `ReadWriteOncePod` (RWOP): one pod across the cluster can mount the volume for reading and writing. section 10.2.1 section 10.2.4
- `ReadWriteOnce` (RWO): one node can mount it for reading and writing; multiple pods on that node can use it. section 10.2.1 section 10.2.4
- `ReadWriteMany` (RWX): multiple nodes can mount it for reading and writing at the same time. section 10.2.1
- `ReadOnlyMany` (ROX): multiple nodes can mount it simultaneously for reading only. section 10.2.1 section 10.2.4
One pod or one node?
If a second pod uses a `ReadWriteOncePod` claim while the first is running, the second remains `Pending`. With `ReadWriteOnce`, several pods on the same node can read and write the volume, but pods scheduled on another node can remain in `ContainerCreating` because the volume cannot attach there. Check pod placement with `kubectl get pods -o wide` and attachment events with `kubectl describe`. section 10.2.4
A claim’s access mode is part of its storage requirements. With static provisioning, Kubernetes looks for an available PersistentVolume that meets those requirements and binds it to the claim. With dynamic provisioning, a volume is created for the claim using its requirements and StorageClass. Once a pod uses the claim, the volume is attached to a node and mounted into the pod’s containers. Access mode is distinct from volume mode: volume mode determines whether the container receives a filesystem or a raw block device. section 10.1.2 section 10.6 section 10.2.1


