What Are PersistentVolume Access Modes (RWO, ROX, RWX)?
Access modes define how a PersistentVolume can be mounted by nodes. ReadWriteOnce (RWO) allows read-write by a single node, ReadOnlyMany (ROX) allows read-only by multiple nodes, and ReadWriteMany (RWX) allows read-write by multiple nodes. The mode determines which workload patterns a volume supports.
Detailed Answer
The Four Access Modes
Kubernetes defines four access modes for PersistentVolumes. These control how many nodes (not Pods) can mount the volume simultaneously and whether the mount is read-write or read-only.
| Mode | Abbreviation | Description | |---|---|---| | ReadWriteOnce | RWO | Read-write by a single node | | ReadOnlyMany | ROX | Read-only by multiple nodes | | ReadWriteMany | RWX | Read-write by multiple nodes | | ReadWriteOncePod | RWOP | Read-write by a single Pod (K8s 1.27+) |
ReadWriteOnce (RWO)
RWO is the most common access mode. The volume can be mounted as read-write by a single node at a time. All Pods scheduled on that node can access the volume.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-data
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 50Gi
storageClassName: gp3
Supported by: AWS EBS, GCE Persistent Disk, Azure Disk, local volumes, iSCSI.
Use case: Single-instance databases (PostgreSQL, MySQL), application state that does not need sharing.
Important caveat: RWO does not mean single-Pod. If two Pods are scheduled on the same node and both mount the same PVC, both can read and write. This can cause data corruption if the application is not designed for concurrent access.
ReadOnlyMany (ROX)
ROX allows the volume to be mounted as read-only by Pods on many nodes simultaneously. The data must be written beforehand (often by a Job or external process).
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: static-assets
spec:
accessModes:
- ReadOnlyMany
resources:
requests:
storage: 5Gi
Supported by: NFS, CephFS, GlusterFS, and some CSI drivers.
Use case: Shared configuration files, ML model files distributed to inference Pods, static website content.
ReadWriteMany (RWX)
RWX allows the volume to be mounted as read-write by Pods across multiple nodes. This is required for workloads that need shared writable storage.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: shared-uploads
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Gi
storageClassName: efs
Supported by: NFS, AWS EFS, Azure Files, CephFS, GlusterFS.
Not supported by: AWS EBS, GCE PD, Azure Disk (block storage).
Use case: Shared file uploads, CMS content directories, log aggregation, multi-instance applications with shared state.
AWS EFS Example
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: efs
provisioner: efs.csi.aws.com
parameters:
provisioningMode: efs-ap
fileSystemId: fs-0abc123def456
directoryPerms: "700"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: shared-data
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 50Gi
storageClassName: efs
ReadWriteOncePod (RWOP)
RWOP was introduced to address the RWO limitation where multiple Pods on the same node can access the volume. RWOP ensures exactly one Pod in the entire cluster can mount the volume:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: exclusive-data
spec:
accessModes:
- ReadWriteOncePod
resources:
requests:
storage: 20Gi
storageClassName: gp3
If a second Pod tries to mount a RWOP volume, it will remain in Pending state until the first Pod releases it. This is critical for applications where concurrent access would cause corruption, such as SQLite databases or write-ahead logs.
Checking Access Mode Support
# View access modes supported by existing PVs
kubectl get pv -o custom-columns=NAME:.metadata.name,CAPACITY:.spec.capacity.storage,MODES:.spec.accessModes
# View access modes on PVCs
kubectl get pvc -o custom-columns=NAME:.metadata.name,MODES:.spec.accessModes,STATUS:.status.phase
# Check what a CSI driver supports
kubectl get csidriver
Selecting the Right Access Mode
| Workload | Recommended Mode | Storage Type | |---|---|---| | Single database instance | RWO or RWOP | Block (EBS, PD) | | StatefulSet (one PVC per replica) | RWO | Block (EBS, PD) | | Shared file uploads | RWX | NFS, EFS | | Distributed read-only config | ROX | NFS, ConfigMap | | Exclusive write (no sharing) | RWOP | Block (CSI with RWOP support) |
Common Mistakes
A frequent error is requesting RWX with a StorageClass backed by block storage (like AWS EBS). The PVC will stay Pending because the provisioner cannot satisfy the access mode. Always verify that your storage backend supports the requested access mode before deploying.
Another mistake is assuming RWO prevents multi-Pod access. It does not. If your application requires exclusive single-Pod access, use RWOP instead of RWO.
Why Interviewers Ask This
Interviewers ask this to ensure you can select the correct storage type for stateful applications and understand why certain volumes cannot be shared across Pods on different nodes.
Common Follow-Up Questions
Key Takeaways
- RWO is per-node, not per-Pod
- RWX requires network-attached storage like NFS or EFS
- RWOP provides true single-Pod exclusive access