Persistent Volume Claims in Kubernetes Explained
Understand how Persistent Volume Claims work in Kubernetes, including static vs dynamic provisioning, access modes, and reclaim policies.
Persistent Volume Claims (PVCs)
Persistent Volume Claims (PVCs) are the only supported way to consume durable storage inside Kubernetes Pods.
Pods cannot mount Persistent Volumes (PVs) directly. Instead, they request storage through a PVC, and Kubernetes takes care of binding that claim to a suitable volume.
What Is a Persistent Volume Claim?
A PersistentVolumeClaim is an abstraction that:
- Reserves an existing PersistentVolume (static provisioning), or
- Triggers the creation of a new PersistentVolume (dynamic provisioning)
In both cases, the PVC becomes the contract between your Pod and the storage backend.
Important rule:
The relationship between a PVC and a PV is strictly 1-to-1.
- One PVC → one PV
- One PV → at most one PVC
Static vs Dynamic Provisioning
Static Provisioning
With static provisioning:
- You manually create PersistentVolumes first
- A PVC is created later
- Kubernetes performs a best-effort match based on:
- Requested size
- Access mode
- Storage class (if specified)
⚠️ If no matching PV exists, the PVC will remain Pending.
Example pitfall
If a PV has 10Gi and a PVC requests 1Gi:
- The PVC binds successfully
- The remaining 9Gi cannot be reused
- This unused capacity is lost to other claims
This is why static provisioning requires careful capacity planning.
Dynamic Provisioning
With dynamic provisioning:
- You create a PVC
- Kubernetes automatically provisions a PV behind the scenes
- The volume matches the exact request
As long as the backend supports:
- The requested size
- The requested access mode
…the claim will always be fulfilled.
This is why dynamic provisioning is strongly recommended, especially in cloud environments.
Reclaim Policies
When a PVC is deleted, Kubernetes must decide what to do with the underlying PV.
Available reclaim policies
| Policy | Behavior |
|---|---|
Delete | Deletes the underlying storage (default for dynamic provisioning) |
Retain | Keeps the volume and its data |
Recycle | Deprecated |
When to use Retain
- Auditing or forensic analysis
- Manual data recovery
- Controlled cleanup workflows
Access Modes Explained
Access modes define how a volume can be mounted, not how many Pods use it.
Common access modes
ReadWriteOnce (RWO)
- Mounted read-write by a single node
- Multiple Pods on that node may use it
ReadOnlyMany (ROX)
- Mounted read-only by many nodes
ReadWriteMany (RWX)
- Mounted read-write by many nodes
- Requires shared storage (e.g. NFS, CephFS)
ReadWriteOncePod (RWOP)
- Mounted read-write by exactly one Pod
- Strongest isolation guarantee
If you need to restrict a volume to a single Pod, you must use
ReadWriteOncePod.ReadWriteOncealone does not guarantee this.
How Pods Use PVCs
From the Pod’s perspective:
- A PVC is just a volume reference
- It doesn’t matter whether the PV is:
- Statically provisioned
- Dynamically provisioned
A single Pod can mount multiple PVCs, and each PVC may come from a different storage backend.
Summary
- PVCs are mandatory for using persistent storage in Pods
- PVC ↔ PV is always a 1-to-1 relationship
- Static provisioning is best-effort
- Dynamic provisioning is predictable and safer
- Access modes control where and how volumes can be mounted
- Reclaim policies determine what happens to data after deletion
Comments
Post a Comment