- List and inspect StorageClasses
- Demonstrate dynamic provisioning using a StorageClass (
fast) - Compare reclaim behaviors (
DeletevsRetain) - Apply best practices for production clusters
List available StorageClasses
Get the StorageClasses in the cluster:kubectl get sc output. If a PVC omits storageClassName, Kubernetes uses the default StorageClass automatically (if one exists).
If a PVC does not set
storageClassName, Kubernetes assigns the default StorageClass (if one exists). This behavior is important in production clusters to avoid unexpected storage types being provisioned.Inspect a StorageClass
To view details for thefast StorageClass:
Volume binding mode note:
WaitForFirstConsumer delays provisioning until a Pod using the PVC is scheduled — this avoids provisioning in the wrong zone/node and is highly recommended in multi-zone clusters.
Demonstrate dynamic provisioning (fast StorageClass)
Create a PVC that requests 1Gi using thefast StorageClass.
Save this as pvc-fast.yaml:
storage namespace:
VolumeBindingMode is WaitForFirstConsumer, the PVC will initially be Pending until a Pod mounts it. Create a Pod that consumes the PVC to trigger provisioning:
Pending to Bound:
fast StorageClass has ReclaimPolicy: Delete, the underlying storage will be deleted automatically when the PVC (and its binding) is removed.
Demonstrate reclaim policy difference: Retain (archive StorageClass)
Thearchive StorageClass in this cluster uses ReclaimPolicy: Retain. Create a PVC using that class.
Save this as pvc-archive.yaml:
archive-storage claim:
archive StorageClass. The PV will show RECLAIM POLICY: Retain:
What happens on deletion with different reclaim policies
-
For fast (ReclaimPolicy: Delete)
- Delete the Pod and the PVC:
- Result: The PV and the underlying storage resource are deleted automatically.
- Delete the Pod and the PVC:
-
For archive (ReclaimPolicy: Retain)
- Delete the Pod, then delete the PVC:
- Result: The PV remains in the cluster and moves to
Releasedstate. The underlying data is preserved and requires administrator action to reclaim or reuse the volume.
- Delete the Pod, then delete the PVC:
Retain PV:
Released with Retain, an administrator must:
- Inspect and back up data if needed
- Clean or wipe data to make the volume reusable
- Remove or update
claimRefon the PV to allow re-binding - Or manually delete the underlying storage resource
Choose reclaim policies based on workload needs:
- Use
Retainfor critical, stateful workloads (databases, logs) to prevent accidental data loss. - Use
Deletefor ephemeral or test workloads to automate cleanup. Also confirm correct access modes (ReadWriteOnce,ReadWriteMany) and zone affinity by usingWaitForFirstConsumerin multi-zone clusters.
Recap / Best practices
- Inspect StorageClasses before creating PVCs:
kubectl get scandkubectl describe sc <name>
- Understand reclaim behavior:
Delete— automated cleanupRetain— manual intervention required
- Use
WaitForFirstConsumerto avoid cross-zone provisioning in multi-zone clusters. - Prefer explicitly setting
storageClassNamein PVCs unless you intentionally rely on a default StorageClass. - Confirm access modes and size requirements match application needs.
- Monitor resource lifecycle:
kubectl get pvc -n <ns> -wkubectl get pv