Skip to main content
This lesson walks through a hands-on lab for StorageClasses, PersistentVolumes (PVs), and PersistentVolumeClaims (PVCs) in Kubernetes. Each step includes the exact commands and example outputs you can use to validate the cluster state. Links to relevant Kubernetes documentation are included at the end.
  1. How many StorageClasses exist in the cluster?
List StorageClasses with either the short or full command:
Example output when the cluster initially had only the default StorageClass:
After creating additional StorageClasses, you might see multiple entries. Example consolidated output (trimmed for clarity):
Summary table (sample output columns):
  1. Which StorageClass does not support dynamic provisioning?
A StorageClass that uses the kubernetes.io/no-provisioner provisioner will not dynamically provision volumes. In the example output above, local-storage uses kubernetes.io/no-provisioner, so it does not support dynamic provisioning and relies on pre-provisioned PVs.
  1. What is the volume binding mode for the local-storage StorageClass?
local-storage uses the WaitForFirstConsumer volumeBindingMode. This delays binding until a Pod that consumes the PVC is scheduled, ensuring the PV is bound on a node that actually has access to the underlying local storage.
  1. What is the provisioner for the StorageClass named portworx-io-priority-high?
From the sample output, the provisioner for portworx-io-priority-high is kubernetes.io/portworx-volume.
  1. Is there a PersistentVolumeClaim consuming the PersistentVolume named local-pv?
List PVs and PVCs:
Example output before creating any PVCs:
Initially there are no PVCs consuming local-pv; the PV is Available and unbound.
  1. Create a PersistentVolumeClaim named local-pvc that should bind to local-pv
To bind a PVC to an existing PV:
  • Request the same or smaller capacity than the PV.
  • Use a compatible access mode (e.g., ReadWriteOnce).
  • Specify the same storageClassName as the PV (local-storage in this example).
Create pvc.yaml:
Apply the manifest:
Check the PVC status:
  1. Why is the PVC in Pending even though the PV exists and matches?
Describe the PVC to view events:
Relevant events example:
Because the StorageClass local-storage uses volumeBindingMode: WaitForFirstConsumer, binding is intentionally delayed until a Pod that consumes the PVC is created and scheduled. The PVC remains Pending until an associated Pod exists so the scheduler can ensure the Pod is placed on a node that can access the PV.
StorageClasses with WaitForFirstConsumer delay binding (and dynamic provisioning) until a Pod uses the PVC. This is typical for local volumes to ensure the PV is bound on a node that actually has the storage.
  1. Create a Pod that consumes local-pvc
Create nginx-pod.yaml that mounts the claim at /var/www/html:
Create the Pod:
Verify Pod and PVC status:
When the Pod that uses the PVC is created, the PVC transitions from Pending to Bound and the PV becomes bound to the claim.
  1. Create a new StorageClass delayed-volume-sc that uses no-provisioner and delayed binding
Create delayed-volume-sc.yaml:
Create the StorageClass:
Verify StorageClasses:
The delayed-volume-sc StorageClass uses the no-provisioner provisioner and WaitForFirstConsumer binding, suitable for clusters that rely on pre-provisioned local PVs and want to delay binding until Pod scheduling. Links and references
A screenshot of the Kubernetes documentation webpage titled "Persistent Volumes," showing the article content and an introduction about persistent volumes. The page includes a left navigation menu, a right sidebar of links, and a blue banner about Dockershim removal.

Watch Video