volumeBindingMode affects when a PVC is bound. We’ll inspect StorageClasses, identify which support dynamic provisioning, create a PVC that remains pending due to delayed binding, create a Pod to trigger binding, and then create a no-provisioner StorageClass with delayed binding.
Keywords: Kubernetes StorageClass, PersistentVolume, PersistentVolumeClaim, WaitForFirstConsumer, dynamic provisioning, no-provisioner.
1) How many StorageClasses exist in the cluster?
Check the cluster’s StorageClasses:local-path.
2) Which StorageClass does not support dynamic provisioning?
After creating more StorageClasses, list them again:kubernetes.io/no-provisioner provisioner indicates a StorageClass that does not support dynamic provisioning. In this example, local-storage is configured for static provisioning—meaning PVs must be pre-provisioned.
StorageClass quick reference:
3) What is the volumeBindingMode used for the local-storage StorageClass?
From the output above, local-storage has:
VOLUMEBINDINGMODE:WaitForFirstConsumer
4) What is the provisioner for portworx-io-priority-high?
From the same output:
PROVISIONERforportworx-io-priority-highiskubernetes.io/portworx-volume.
5) Is there a PVC consuming the PV named local-pv?
Inspect PVs and PVCs:
local-pv at this time; local-pv is Available.
6) Create a PersistentVolumeClaim named local-pvc that should bind to local-pv
To bind a PVC to an existing PV you must match capacity, access modes, and storageClassName. Create pvc.yaml:
Pending. Describe it to see why:
local-storage uses volumeBindingMode: WaitForFirstConsumer. Binding is intentionally delayed until a Pod that consumes the PVC is scheduled.
StorageClasses with
volumeBindingMode: WaitForFirstConsumer delay the PV/PVC binding until a Pod that uses the PVC is created and scheduled. This is commonly used for local volumes so the scheduler can place the Pod on a node that has access to the PV.7) Create a Pod that consumes the PVC (so the PVC can bind)
Createnginx-pod.yaml which mounts the local-pvc at /var/www/html:
Bound to local-pv. Creating the Pod triggered the binding because of WaitForFirstConsumer. The scheduler decided the Pod’s node and the persistentvolume-controller completed the binding.
8) Create a StorageClass named delayed-volume-sc with no-provisioner and WaitForFirstConsumer
Create delayed-volume-sc.yaml:
delayed-volume-sc is created with provisioner: kubernetes.io/no-provisioner and volumeBindingMode: WaitForFirstConsumer. It expects statically provisioned PVs and will delay binding until a consuming Pod is scheduled.
Summary
- Use
kubectl get scto list StorageClasses and inspectPROVISIONERandVOLUMEBINDINGMODE. kubernetes.io/no-provisionerindicates static provisioning (no dynamic provisioning).WaitForFirstConsumerdelays binding until a Pod using the PVC is scheduled—useful for local volumes.- Creating a Pod that references a PVC using a
WaitForFirstConsumerStorageClass triggers binding to a matching PV.