๐Ÿ“– Read-only preview โ€” lessons, diagrams, and quizzes only. The hands-on labs, live grading, and progress tracking require running the real course locally against a Kubernetes cluster.Run it locally โ†’

Module 7 ยท Lesson 7.2

StorageClasses & Dynamic Provisioning

You saw a StorageClass named in a PVC last lesson without really defining it. Here's what it actually is: a named template that tells the cluster how to dynamically provision storage when a PVC asks for it.

What's actually in a StorageClass

provisioner: rancher.io/local-path   # which plugin creates the volume
reclaimPolicy: Delete                 # what happens to the PV when its PVC is deleted
volumeBindingMode: WaitForFirstConsumer
  • provisioner is the plugin doing the real work โ€” on EKS this would be ebs.csi.aws.com or efs.csi.aws.com; on kind it's a simple local-path provisioner writing to each node's filesystem.
  • reclaimPolicy decides whether the underlying storage is deleted or kept around after its PVC is deleted. Retain is what you'd want for anything you can't afford to lose to a typo.
  • volumeBindingMode: WaitForFirstConsumer delays actually creating the volume until a Pod using the PVC is scheduled โ€” critical in clouds where storage is zone-locked, so the volume gets created in the same zone as the Pod, not a random one. Immediate provisions right away, which only really makes sense for storage with no such topology constraint.

A cluster can have many StorageClasses

Nothing stops you from having fast-ssd, cheap-hdd, and encrypted all pointing at the same or different provisioners with different parameters โ€” PVCs pick one by name via storageClassName. Exactly one can be marked the cluster's default (an annotation on the StorageClass itself), used when a PVC doesn't specify one at all.

The other common failure mode

Last lesson's bug was a request the provisioner genuinely couldn't satisfy. This lesson's is simpler and, in practice, far more common: a typo in the StorageClass name. There's no autocomplete enforcing that storageClassName: fast-locall matches a real class โ€” it just won't, and the PVC sits Pending with an unambiguous "not found" event, which is almost a relief compared to the previous lesson's failure mode.

The infrastructure analogy

A StorageClass is closest to an EBS volume type + parameters template (gp3, 3000 IOPS, encrypted) that you'd reference by name in a launch template โ€” defined once, requested by name repeatedly, with the actual provisioning handled by the cloud underneath.

In the lab, you'll define your own StorageClass and fix exactly this kind of name mismatch.

๐Ÿงช Lab: lab-14-storageclasses

Preview only

Goal

See a StorageClass as what it really is โ€” a named template dynamic provisioning reads from โ€” and fix a one-character typo that's extremely common in real manifests.

Tasks

  1. Apply the starting manifests: kubectl apply -f manifests/
  2. List StorageClasses: kubectl get storageclass โ€” you now have two: standard (kind's built-in default) and fast-local (yours, same provisioner, reclaimPolicy: Retain instead of Delete).
  3. Check status: kubectl get pvc,pod -n lab-14-storageclasses โ€” app-data is stuck Pending.
  4. Diagnose: kubectl describe pvc app-data -n lab-14-storageclasses โ€” read the Events.
  5. Compare the StorageClass name the PVC asks for against kubectl get storageclass โ€” find the typo.
  6. Fix it in manifests/pvc-and-pod.yaml, then kubectl delete -f manifests/pvc-and-pod.yaml && kubectl apply -f manifests/pvc-and-pod.yaml
  7. Confirm: kubectl get pvc app-data -n lab-14-storageclasses shows Bound with STORAGECLASS = fast-local.

Check

Run the check once app-data is Bound to the fast-local class and app is Running.

This lab runs against a real local Kubernetes cluster with an automated grader โ€” clone the repo and run make start to do it for real.

๐Ÿ“ Quiz

1. What does a StorageClass's `provisioner` field actually control?

2. Why does `volumeBindingMode: WaitForFirstConsumer` matter more on a real cloud than it does on kind?scenario

3. A PVC's `storageClassName` has a typo and matches no real StorageClass. What's the failure mode?

4. What does `reclaimPolicy: Retain` protect you from, compared to `Delete`?

5. Which of these can differ between two StorageClasses pointing at the same provisioner? (select all that apply)

Progress isn't saved in this preview โ€” run the course locally to track completion and grade labs for real.