PersistentVolumeClaim
A PersistentVolumeClaim (PVC) is a request for storage in Kubernetes that binds to a PersistentVolume, letting pods use durable storage independent of their own lifecycle. The PVC states size, access mode, and storage class, and Kubernetes finds or provisions matching storage.
PV, PVC, StorageClass
- A PersistentVolume (PV) is the actual storage resource, such as a cloud disk. It is cluster-scoped.
- A PersistentVolumeClaim is a namespaced request for storage.
- A StorageClass defines how storage is dynamically provisioned.
50Gi RWO"] --> S["StorageClass
gp3-encrypted"] S -->|"provisions"| V["PersistentVolume
EBS disk"] V -->|"binds one to one"| D D --> P["Pod mounts PVC"] classDef dev fill:#475569,color:#ffffff classDef sc fill:#FFEDD5,color:#1E293B classDef pv fill:#EDE9FE,color:#1E293B classDef pod fill:#D1FAE5,color:#1E293B class D dev class S sc class V pv class P pod
Access modes
| Mode | Meaning |
|---|---|
| ReadWriteOnce | One node mounts it read-write, typical for databases |
| ReadOnlyMany | Many nodes read it |
| ReadWriteMany | Many nodes read and write, needs NFS or EFS-like storage |
| ReadWriteOncePod | Only a single pod may use it |
Example
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: mysql-data-pvc namespace: productionspec: accessModes: ["ReadWriteOnce"] storageClassName: gp3-encrypted resources: requests: storage: 50GiapiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: gp3-encryptedprovisioner: ebs.csi.aws.comparameters: type: gp3 encrypted: "true"reclaimPolicy: RetainallowVolumeExpansion: truevolumeBindingMode: WaitForFirstConsumerWaitForFirstConsumer delays provisioning until the pod is scheduled, so the disk lands in the same zone.
kubectl get pvc -Akubectl describe pvc mysql-data-pvc -n productionkubectl patch pvc mysql-data-pvc -n production \ -p '{"spec":{"resources":{"requests":{"storage":"100Gi"}}}}'Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| PVC stuck Pending | No matching PV or StorageClass | Read events in describe |
| Pod in ContainerCreating | PVC not bound or attach failing | Check PVC and CSI driver |
| Resize does nothing | StorageClass blocks expansion | Enable allowVolumeExpansion |
| Wrong-zone binding | Immediate binding mode | Use WaitForFirstConsumer |
TipUse
reclaimPolicy: Retainfor production databases so deleting a PVC does not delete the underlying disk.
Common MistakeRequesting ReadWriteMany from block storage like EBS. It is unsupported and the PVC stays Pending.
Frequently Asked Questions
How does a PVC get matched to storage?
The control plane binds it to a PersistentVolume that satisfies its size, access mode, and class. With dynamic provisioning the StorageClass provisioner creates a new volume on demand.
Why does deleting a pod not delete its data?
PVCs decouple storage from pod lifecycle. Even deleting the PVC may keep the disk, depending on the reclaim policy.
Why do orphaned disks accumulate?
With Retain, volumes remain after their claims are deleted, and teams that delete namespaces can leave unattached cloud disks that quietly add cost.