CFN Cloud
2025-10-10

StorageClass

Let PVCs trigger storage provisioning automatically.

StorageClass allows PVCs to provision storage automatically, removing the need to pre-create PVs.

Key fields

  • provisioner: storage plugin
  • parameters: storage options
  • reclaimPolicy: cleanup behavior

Minimal example

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: fast
provisioner: csi.example.com
parameters:
  type: ssd
reclaimPolicy: Delete

Tips

  • Two tiers (fast/standard) are usually enough
  • Review reclaim policy and backups in production

Practical notes

  • Start with a quick inventory: kubectl get nodes, kubectl get pods -A, and kubectl get events -A.
  • Compare desired vs. observed state; kubectl describe usually explains drift or failed controllers.
  • Keep names, labels, and selectors consistent so Services and controllers can find Pods.

Quick checklist

  • The resource matches the intent you described in YAML.
  • Namespaces, RBAC, and images are correct for the target environment.
  • Health checks and logs are in place before promotion.

Storage model and binding

Kubernetes separates storage intent from storage implementation. A PVC expresses what a workload needs, while a PV represents a piece of storage. StorageClass ties these together by describing how to provision volumes. StorageClass is where you define how storage is created and how it will be attached to Pods.

Access modes and reclaim policy

Access modes describe how a volume can be mounted: read write once for single writer, read write many for shared access, or read only many for shared reads. Reclaim policy controls what happens when a claim is deleted. Delete removes the underlying volume, while Retain keeps it. Be intentional here because the policy determines whether data survives cleanup.

Expansion and snapshots

Many storage backends support volume expansion. When enabled, you can grow PVCs without recreating the workload, but you still need to confirm filesystem growth steps. Snapshots are a separate feature that enable backups or clones. Use them for testing upgrades and for faster recovery drills.

Performance and cost tradeoffs

Storage is often the bottleneck for stateful workloads. SSD backed classes provide low latency, while network attached storage can be more flexible but slower. Choose classes based on actual IOPS and throughput needs, not just size. Over provisioning is common, so track utilization and adjust requests to avoid paying for unused capacity.

Topology awareness

Some storage backends are zonal. The volume binding mode and scheduler need to align so Pods land in the same zone as their volumes. If you see pods stuck in Pending with volume binding errors, check topology constraints and StorageClass settings.

Data integrity and backup windows

Snapshots and backups should be taken at safe times. For databases, coordinate backup windows with application quiescing or use consistent snapshot tooling. Test restores regularly so you know the time to recover, not just the time to backup.

Operational workflow

Provision, mount, observe, and validate. Always verify that the PVC is bound before starting the workload. Monitor disk usage and inode pressure. For migrations, plan for data copy time and test your restore process. Storage is persistent, so cleaning up old PVCs and orphaned volumes should be part of your decommission process.

kubectl get pv
kubectl get pvc -n demo
kubectl describe pvc data-demo -n demo

Wrap-up: StorageClass is your default contract

If you pick the wrong class (or no default class), PVCs will hang and you’ll debug the wrong thing.

Know your defaults, reclaim policy, and binding mode before you trust it with real data.

StorageClass sanity check

Before using a new class, confirm the provisioner exists in the cluster, test a small PVC, and verify the reclaim policy matches expectations. A quick smoke test up front saves time later.

References