Difficulty: Intermediate
What are the access modes for a PersistentVolumeClaim in Kubernetes, and how do you choose between them?
Access modes describe how a volume can be mounted by nodes and Pods. The three classic ones are ReadWriteOnce (RWO, read-write by a single node), ReadOnlyMany (ROX, read-only by many nodes) and ReadWriteMany (RWX, read-write by many nodes). A fourth mode, ReadWriteOncePod (RWOP), stable since Kubernetes 1.29, restricts the volume to a single Pod in the whole cluster.
| Mode | Short form | Who can mount it | Typical backends |
|---|---|---|---|
| ReadWriteOnce | RWO | Read-write by one node (any number of Pods on that node) | AWS EBS, GCE Persistent Disk, Azure Disk, local volumes |
| ReadOnlyMany | ROX | Read-only by many nodes | GCE PD in read-only mode, NFS, pre-populated datasets |
| ReadWriteMany | RWX | Read-write by many nodes | AWS EFS, Azure Files, Filestore, NFS, CephFS |
| ReadWriteOncePod | RWOP | Read-write by exactly one Pod | CSI drivers that support it |
The most misunderstood point: RWO is per node, not per Pod. Two Pods scheduled on the same node can both mount an RWO volume. If you need a hard guarantee that only one Pod writes, use RWOP.
Pending.readOnly: true on the volume mount for that.Multi-Attach error for volume. Use a StatefulSet with volumeClaimTemplates so each replica gets its own volume.strategy: Recreate for single-replica stateful Deployments.For example, a Razorpay-style ledger database runs as a StatefulSet with RWO SSD volumes per replica, while a shared invoice-template folder used by many rendering Pods could sit on an RWX file share.
| RWO | RWX | RWOP | |
|---|---|---|---|
| Writers allowed | Pods on one node | Pods on many nodes | Exactly one Pod |
| Typical storage | Block disk like EBS | File share like EFS or NFS | CSI block or file volume |
| Best for | Databases per replica | Shared files | Strict single writer |
| Common failure | Multi-Attach error across nodes | Slower IO, locking issues | Second Pod stays Pending |
# Block storage for a single-writer database
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ledger-db-data
spec:
accessModes: ["ReadWriteOncePod"] # only one Pod may use it
storageClassName: gp3
resources:
requests:
storage: 100Gi
---
# Shared file storage for many web Pods
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: shared-uploads
spec:
accessModes: ["ReadWriteMany"]
storageClassName: efs-sc # backed by a network filesystem
resources:
requests:
storage: 50Gi
The access mode must be supported by the StorageClass's driver. Requesting RWX on a block-storage class like gp3 would leave the claim Pending.
ReadWriteOnce, ReadOnlyMany, ReadWriteMany, ReadWriteOncePod, StorageClass