debugbashkubernetesMajor
PersistentVolumeClaim stuck in Pending — no matching PersistentVolume
Viewed 0 times
pvcpersistentvolumeclaimpersistentvolumestorageclasspendingdynamic provisioningcsi driverreadwriteonce
Error Messages
Problem
A PersistentVolumeClaim stays in Pending status indefinitely and the pod that needs it stays in Pending too.
Solution
Check the PVC events for the root cause:
Fix options:
kubectl describe pvc <pvc-name>
# Look at Events section for messages like:
# no persistent volumes available for this claim and no storage class is set
# List available StorageClasses
kubectl get storageclass
# List existing PVs and their status
kubectl get pvFix options:
- Set a valid
storageClassNamein the PVC spec matching an available StorageClass - Create a manual PV that matches the PVC's accessModes and storage request
- Install a dynamic provisioner (e.g. local-path-provisioner for local clusters, AWS EBS CSI driver)
Why
PVCs are bound to PVs either statically (pre-provisioned PVs) or dynamically (via a StorageClass with a provisioner). If no PV matches the PVC's requirements and no dynamic provisioner is configured, the PVC stays Pending.
Gotchas
- AccessModes must match between PV and PVC — ReadWriteMany is not supported by all backends (EBS only supports RWO)
- StorageClass with
volumeBindingMode: WaitForFirstConsumerdelays binding until a pod is scheduled — PVC shows Pending until then - Deleting a PVC does not automatically delete the PV — check the ReclaimPolicy (Retain vs Delete)
- On minikube use
storageClassName: standard; on kind install a local path provisioner
Code Snippets
PVC with explicit StorageClass
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: gp2 # must match an existing StorageClass
resources:
requests:
storage: 20GiContext
Attaching persistent storage to pods in Kubernetes
Revisions (0)
No revisions yet.