Reclaim Policies in StorageClasses
What you'll learn: How to control what happens to your persistent volumes when their claims are deleted.
The Core Idea
When you delete a PersistentVolumeClaim (PVC), what should happen to the underlying PersistentVolume (PV) and its data? The reclaim policy in a StorageClass defines this behavior automatically for dynamically provisioned volumes.
Think of it like a rental agreement for storage space: when a tenant moves out (deletes their claim), should the landlord demolish the unit (Delete), keep it as-is for inspection (Retain), or clean it up for the next tenant (Recycle)?
The Three Reclaim Policies
Delete (Default)
The PV and its underlying storage are automatically deleted when the PVC is removed. This is cost-efficient but permanent—your data is gone.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: fast-delete
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Delete
Retain
The PV remains after the PVC is deleted, preserving the data. The volume enters a "Released" state and requires manual cleanup or reclamation. Use this for critical data you might need to recover.
reclaimPolicy: Retain
Recycle (Deprecated)
Performs a basic scrub (rm -rf /volume/*) and makes the volume available again. This option is deprecated and not supported by most modern provisioners—avoid it.
When It Matters
The reclaim policy only applies to dynamically provisioned volumes created through the StorageClass. For static PVs, you set the reclaim policy directly on the PV itself (as you learned in "PV Reclaim Policies").
Key Takeaway: StorageClass reclaim policies automate data lifecycle decisions—use Delete for temporary data and Retain for anything you might need to recover after claim deletion.