Decoupling Provisioning from Consumption
Decoupling Provisioning from Consumption
PersistentVolumes are cluster-scope storage objects created by an admin or provisioner; PersistentVolumeClaims are namespace-scope requests from workloads. Pods never reference a PV directly — they mount a claim.
Binding matches claim requirements — access mode, capacity, storageClassName, and optional label selectors — against available PVs, and once bound the pair stays locked. Access modes state concurrency:
- ReadWriteOnce — one node read-write.
- ReadOnlyMany — many nodes may read.
- ReadWriteMany — many nodes may write (needs filesystem support such as NFS or EFS).
The separation lets storage admins offer capacity without knowing which team will consume it, and lets developers request storage without knowing the backend.
A Claim and Its Pod
A Claim and Its Pod
apiVersion: v1
kind: PersistentVolumeClaim
metadata: { name: data }
spec:
accessModes: [ReadWriteOnce]
storageClassName: standard
resources: { requests: { storage: 10Gi } }
---
apiVersion: v1
kind: Pod
metadata: { name: app }
spec:
containers:
- name: app
image: nginx:1.27
volumeMounts: [{ name: data, mountPath: /var/lib/data }]
volumes:
- name: data
persistentVolumeClaim: { claimName: data }
With dynamic provisioning you need a default StorageClass (annotated storageclass.kubernetes.io/is-default-class: "true") or an explicit storageClassName. Reclaim policy decides fate: Delete removes the backing volume when released, Retain parks it for manual recovery.
Pitfalls and Interview Angles
Pitfalls and Interview Angles
Pitfall 1 — misreading ReadWriteOnce. RWO restricts to one node, not one pod — several pods on that node may share it, pods elsewhere cannot. Multi-host writers need RWX-capable storage or an operator managing access.
Pitfall 2 — delete order and costs. Deleting a bound PVC while pods mount it blocks on the protection finalizer until they exit; with Retain policy, orphaned cloud volumes keep billing after the claim is gone.
Interview-ready: recite the binding criteria, the three access modes with an example each, and reclaim behavior — plus why databases typically pair RWO claims with StatefulSet volumeClaimTemplates and why WaitForFirstConsumer matters for zonal disks.
Quiz
1. What does a pod reference when mounting durable storage?
2. Can two pods on different nodes share an RWO volume?
3. What does reclaimPolicy: Retain do when a claim is deleted?
Flashcards
Question
PV vs PVC
Click to reveal answer
Answer
PV = cluster-wide storage offer; PVC = namespace-scoped request that binds to it.
Question
Access modes
Click to reveal answer
Answer
RWO one node, ROX many readers, RWM many writers (filesystem-dependent).
Question
Reclaim policies
Click to reveal answer
Answer
Delete removes the backend with the claim; Retain preserves it for manual recovery.
Question
Why Pending claims hang
Click to reveal answer
Answer
No matching PV, missing default StorageClass, or a provisioner that cannot satisfy size/mode.
Revision Notes
Key Takeaways
- 1. The chain is pod → PVC → PV → backend storage
- 2. RWO is node-scoped, not pod-scoped
- 3. Reclaim policy controls both data safety and cloud cost
Interview Tips
- • Walk binding criteria: access modes, size, class, selectors
- • Use a database example to justify RWO plus StatefulSet templates
Cheat Sheet
pod → PVC → PV. Modes: RWO/ROX/RWM (node-scoped). Reclaim Delete vs Retain. Pending claims: no PV, no default StorageClass, or failing provisioner.