PV PVC and StorageClass
Why a Pod needs storage that outlives it
Imagine a bookstore catalog that writes its inventory to disk. A replacement Pod has a new identity and may run on another node. If the inventory exists only in the old container writable layer, the replacement cannot rely on finding it. A PersistentVolume (PV) represents storage with a lifecycle independent of an individual Pod. A PersistentVolumeClaim (PVC) is a namespaced request for storage; the Pod references that claim. A PV is cluster-scoped. The actual bytes live in a storage backend, not in the Kubernetes API object. Persistence is not the same as backup or replication.
Read a claim for 2 GiB
The following static manifest requests at least 2 GiB of filesystem storage from the class study-zonal, with ReadWriteOnce access. Gi is a binary quantity: 2Gi is 2 × 1024³ bytes. A claim can bind to a suitable larger volume, such as a 5Gi PV; the claim reserves the entire PV, not a 2Gi slice to share with other claims. Binding is exclusive between a PV and a PVC. The namespace must already exist in a real environment. The class and driver in this lesson are fictional; do not apply these manifests.
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: catalog-data namespace: storage-studyspec: storageClassName: study-zonal accessModes: - ReadWriteOnce volumeMode: Filesystem resources: requests: storage: 2GiStatic binding: match the request to existing storage
For a simplified inventory, consider an Available 5Gi PV named study-disk-a. The class, access mode and volume mode match the claim. It is a candidate; the 1Gi alternative is too small, and a 10Gi Block-mode alternative does not match Filesystem. The binding controller also considers selectors, existing reservations and other constraints. A compatible PV is not proof of a successful mount. A Pending claim can be normal when the storage class delays binding until scheduling.
apiVersion: v1kind: PersistentVolumemetadata: name: study-disk-aspec: capacity: storage: 5Gi accessModes: - ReadWriteOnce volumeMode: Filesystem persistentVolumeReclaimPolicy: Retain storageClassName: study-zonal csi: driver: storage.example.invalid volumeHandle: fictional-disk-a nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: topology.kubernetes.io/zone operator: In values: [study-a]Dynamic provisioning: request storage on demand
A StorageClass describes a storage offering and its provisioner. If a compatible PV is not available, a suitable class and working provisioner may create one for the request. The class can describe parameters, expansion and reclaim behavior. The following class intentionally names a nonexistent CSI driver, so it is only a reading example. A claim with an omitted class can receive the default class; an explicit empty string requests storage with no class and avoids default dynamic provisioning. A selector on a PVC prevents dynamic provisioning of that claim. Inspect actual class settings rather than assuming a default exists.
apiVersion: storage.k8s.io/v1kind: StorageClassmetadata: name: study-zonalprovisioner: storage.example.invalidreclaimPolicy: RetainallowVolumeExpansion: truevolumeBindingMode: WaitForFirstConsumerFollow the claim into the Pod
A Pod in storage-study uses volumes[].persistentVolumeClaim.claimName to refer to catalog-data, then volumeMounts connects that named volume to a path. A Pod cannot mount a PVC from a different namespace by using the same claim name. If the claim is Bound, the node still needs successful attach and mount operations where applicable. A replacement Pod that uses the same surviving claim can see the same data if the backend remains accessible and the workload writes durably. Review the reader.yaml fixture; its image and driver are deliberately unusable.
Practice and diagnose Pending
Use binding-cases.json to decide which candidates match. If no volume binds, inspect the requested size, class, volume mode, access modes, reservation, provisioner health and binding mode. In a separately approved lab, get and describe the PVC, PV and StorageClass with an explicit kubeconfig and context. Distinguish Pending, Bound and Released PV/PVC observations: Released is a PV phase, not a PVC phase. Do not delete the claim merely to troubleshoot. Next, explore how access and location constrain the workload.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
PV PVC and StorageClass — knowledge check
Reason about persistent storage using synthetic Kubernetes examples.
Which object is namespaced?
A 2Gi Filesystem claim matches a 5Gi Available PV in class and access mode. What is true?
What does an explicit storageClassName: "" request?
Where does the catalog data actually live?
A delayed-binding claim has no consumer Pod. What is the next reasonable action?