StorageClasses and Dynamic Provisioning
Learn how StorageClasses let Kubernetes provision Persistent Volumes automatically, on demand, without manual admin work.
StorageClasses and Dynamic Provisioning is a free DevOps Bootcamp lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Manual Storage Problem
With static provisioning, an admin must create each PersistentVolume by hand before a PersistentVolumeClaim can bind. That does not scale.
Dynamic provisioning creates volumes automatically when a claim is made.
What Is a StorageClass?
A StorageClass describes a type of storage a cluster can offer: which provisioner to use, what parameters, and how volumes behave.
Think of it as a template for creating PersistentVolumes on demand.
A StorageClass Definition
The provisioner field names the plugin that creates the volume, often a cloud disk driver.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd
provisioner: kubernetes.io/aws-ebs
parameters:
type: gp3
reclaimPolicy: Delete
volumeBindingMode: WaitForFirstConsumerRequesting Dynamic Storage
A PVC simply references the StorageClass by name. Kubernetes then provisions a matching PV automatically.
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: data
spec:
accessModes: ['ReadWriteOnce']
storageClassName: fast-ssd
resources:
requests:
storage: 10GiThe Default StorageClass
If a PVC omits storageClassName, Kubernetes uses the cluster default StorageClass (marked with an annotation). This makes claims work out of the box.
kubectl get storageclass
# NAME PROVISIONER DEFAULT
# standard (default) ...Reclaim Policy
The reclaimPolicy decides what happens when the PVC is deleted:
- Delete: the underlying volume is removed too
- Retain: the volume is kept for manual recovery
Volume Binding Mode
WaitForFirstConsumer delays creating the volume until a Pod using the PVC is scheduled. This ensures the disk lands in the same zone as the Pod.
Immediate provisions right away, which can cause zone mismatches.
Watching Provisioning Happen
After applying a PVC, watch it move from Pending to Bound as the volume is created.
kubectl apply -f pvc.yaml
kubectl get pvc data -w
# data Pending
# data Bound pvc-8a3f... 10GiMultiple Tiers
Clusters often define several StorageClasses for different needs, letting teams pick the right trade-off per workload.
# fast-ssd -> low latency, higher cost
# standard -> balanced default
# cold-hdd -> cheap, archivalExpanding Volumes
If the StorageClass has allowVolumeExpansion: true, you can grow a PVC by editing its requested size, and the provisioner resizes the underlying disk.
spec:
resources:
requests:
storage: 20Gi # increased from 10GiWhen to Use Static vs Dynamic
- Dynamic: default choice; self-service, scales well
- Static: when you must bind to a specific pre-existing disk or NFS export
Quick Check
Test your grasp of dynamic provisioning.
Recap
You learned that a StorageClass templates how storage is created, enabling dynamic provisioning. Key fields include the provisioner, reclaimPolicy, and volumeBindingMode. PVCs reference a class by name, and a default class handles claims that omit one.
Frequently asked questions
Is the “StorageClasses and Dynamic Provisioning” lesson free?
Yes — the full text of “StorageClasses and Dynamic Provisioning” is free to read here on the web, and the DevOps Bootcamp course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the DevOps Bootcamp course, upgrade to CoddyKit PRO.
What will I learn in “StorageClasses and Dynamic Provisioning”?
Learn how StorageClasses let Kubernetes provision Persistent Volumes automatically, on demand, without manual admin work. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “StorageClasses and Dynamic Provisioning” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- ConfigMaps for Configuration
- Secrets for Sensitive Data
- Persistent Volumes and Claims
- StorageClasses and Dynamic Provisioning