What is the difference between a PersistentVolume and a PersistentVolumeClaim in Kubernetes?
PersistentVolumes (PV) and PersistentVolumeClaims (PVC) are Kubernetes abstractions for managing storage.
PersistentVolume (PV)
A PersistentVolume is a storage resource in the cluster provisioned by an administrator or dynamically created via StorageClass. It exists independently of any pod lifecycle.
Key properties:
- Capacity: Size of the storage
- Access Modes: ReadWriteOnce, ReadOnlyMany, ReadWriteMany
- Reclaim Policy: Retain, Recycle, or Delete
- StorageClass: Defines the provisioner
PersistentVolumeClaim (PVC)
A PVC is a request for storage by a user/application. It consumes PV resources similar to how pods consume node resources.
Example PVC:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: standardBinding Process
- Admin creates PV (or StorageClass enables dynamic provisioning)
- Developer creates PVC with storage requirements
- Kubernetes binds PVC to a matching PV
- Pod references the PVC as a volume
Dynamic Provisioning
With StorageClass, PVs are created automatically when a PVC is submitted, eliminating manual PV creation. This is the preferred approach in cloud environments (EBS, GCP PD, Azure Disk).