Kubernetes · Orchestration under pressure
How do StorageClasses enable dynamic provisioning?
Short answer
A StorageClass describes a provisioner and parameters for creating volumes on demand. A PVC that references it triggers dynamic provisioning instead of waiting for a pre-created PV.
StorageClasses remove the need to pre-provision volumes. When a PVC names a class, the CSI driver creates a matching volume and PV. Parameters control disk type, IOPS, replication and encryption depending on the driver. A default class is used when a PVC omits storageClassName.
- Different classes for fast SSD, cheap bulk and replicated storage
- volumeBindingMode: WaitForFirstConsumer delays provisioning until a pod is scheduled
- allowVolumeExpansion lets PVCs grow if the driver supports it
- reclaimPolicy on the class controls what happens after the PVC is deleted
- Changing a PVC's StorageClass after binding is not supported
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-ssd
provisioner: ebs.csi.aws.com
parameters:
type: gp3
encrypted: "true"
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
reclaimPolicy: RetainWaitForFirstConsumer is important in multi-zone clusters because it lets the scheduler pick a zone first and then provision storage there. Without it, a volume can be created in a zone where no eligible node exists, leaving pods pending. Always confirm zone topology and node affinity align with the storage class.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1What does dynamic provisioning do?
- 2Why is WaitForFirstConsumer useful in multi-zone clusters?
- 3Can you shrink a PVC after expansion?
- 4How do you choose between storage tiers?
Say it in the interview
A StorageClass tells Kubernetes how to provision storage on demand using a CSI driver and parameters. I define classes for performance and cost tiers, and use WaitForFirstConsumer so the scheduler picks a zone before the volume is created. Expansion depends on the driver, and shrinking is generally not supported. I also make sure there is exactly one default class to avoid surprises.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Kubernetes mock interview and get scored feedback on depth, clarity and confidence.