What is the difference between a PersistentVolume, a PersistentVolumeClaim, and a StorageClass?
Quick Answer
A PersistentVolume (PV) is a piece of actual storage in the cluster; a PersistentVolumeClaim (PVC) is a pod's request for storage; a StorageClass describes how to dynamically provision PVs on demand. Pods mount PVCs, which bind to PVs.
Detailed Answer
A PV is a cluster resource representing real storage (an EBS volume, an NFS share, a cloud disk) with a capacity and access mode; it's cluster-scoped and outlives pods. A PVC is a namespaced request — 'I need 20Gi, ReadWriteOnce' — that binds to a suitable PV; the pod references the PVC, decoupling the app from the storage details. A StorageClass enables dynamic provisioning: instead of an admin pre-creating PVs, the class names a provisioner (e.g., ebs.csi.aws.com) and parameters, so when a PVC requests that class, a PV is created automatically. Also key: reclaimPolicy (Delete vs Retain) decides what happens to the underlying disk when the PVC is deleted, and access modes (RWO/ROX/RWX) constrain how many nodes can mount it. StatefulSets use volumeClaimTemplates to give each pod its own PVC/PV.
Code Example
kind: PersistentVolumeClaim
apiVersion: v1
metadata: { name: data }
spec:
accessModes: [ReadWriteOnce]
storageClassName: gp3 # dynamic provisioning via the StorageClass
resources: { requests: { storage: 20Gi } }
# Pod: volumes: [{ name: d, persistentVolumeClaim: { claimName: data } }]Interview Tip
Analogy that lands: 'StorageClass is the vending machine, PVC is your coin+selection, PV is the item that drops out.' Then mention reclaimPolicy Retain vs Delete — a common data-loss gotcha.