The End of Manual Labor

Before Storage Classes, a Cluster Admin had to manually create 100 PVs in anticipation of developer needs. When those ran out, deployments failed. This is not Cloud Native.

1. Dynamic Provisioning

With Storage Classes, the Administrator defines “profiles” of storage (e.g., “fast-ssd”, “cheap-hdd”). When a Developer requests storage, the cluster automatically talks to the Cloud Provider (AWS, GCP, Azure) to create the disk on-demand.

No pre-provisioning. No waiting. Just instant storage.


2. Interactive: Dynamic Provisioning Flow

Visualize how a PVC triggers the creation of real cloud infrastructure.

👤

Developer

Create PVC Class: "fast-ssd"
⚙️

K8s Control Plane

Reads SC "fast-ssd" Provisioner: aws-ebs
☁️

AWS API

Creating Volume...
💾

PV Created

Bound to PVC

3. Anatomy of a StorageClass

A StorageClass is an interface to a specific storage backend (the Provisioner).

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast-ssd  # Developers reference this name
provisioner: kubernetes.io/aws-ebs # Who does the work?
parameters:
  type: gp3       # AWS specific parameter
  iopsPerGB: "10"
reclaimPolicy: Delete
allowVolumeExpansion: true

Key Fields

  1. Provisioner: The plugin that creates the storage (e.g., ebs.csi.aws.com, pd.csi.storage.gke.io).
  2. Parameters: Key-value pairs passed directly to the cloud API (e.g., “IOPS”, “Encryption Key”).
  3. ReclaimPolicy: What happens to the underlying disk when the PVC is deleted?
    • Delete (Default): The AWS EBS volume is deleted. Data is lost.
    • Retain: The PV object is released, but the EBS volume remains in AWS. Manual cleanup required.
  4. VolumeBindingMode:
    • Immediate: Create volume as soon as PVC is created.
    • WaitForFirstConsumer: (Best Practice) Wait until a Pod is scheduled. This ensures the volume is created in the same Availability Zone as the Node.

4. The “Default” Storage Class

Every cluster usually has one StorageClass marked as default. If a PVC does not specify a storageClassName, it gets the default.

To check your classes:

kubectl get sc

Output:

NAME                 PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      AGE
standard (default)   kubernetes.io/gce-pd    Delete          Immediate              10d
premium-rwo          pd.csi.storage.gke.io   Delete          WaitForFirstConsumer   10d

[!TIP] Use WaitForFirstConsumer in multi-zone clusters. Without it, the provisioner might create an EBS volume in us-east-1a, but your Pod might get scheduled in us-east-1b. The Pod will fail to start because it cannot attach a volume across zones.

5. Next Steps

We have covered how to get storage (PVC) and how it is created (SC). But what if you need to run a Database Cluster where each replica needs its own unique identity and storage? Enter StatefulSets.