0
0
Kubernetesdevops~10 mins

Reclaim policies (Retain, Delete) in Kubernetes - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Reclaim policies (Retain, Delete)
PVC Bound to PV
Delete PVC
Check Reclaim Policy
PV stays
Manual
cleanup
When a PersistentVolumeClaim (PVC) is deleted, Kubernetes checks the PersistentVolume's (PV) reclaim policy. If Retain, the PV stays for manual cleanup. If Delete, the PV and storage are deleted automatically.
Execution Sample
Kubernetes
apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv-example
spec:
  persistentVolumeReclaimPolicy: Retain
Defines a PersistentVolume with reclaim policy set to Retain, meaning storage is kept after PVC deletion.
Process Table
StepActionPVC StatePV StateReclaim PolicyResult
1PVC created and bound to PVBoundBoundRetainPV and PVC linked
2User deletes PVCDeletedReleasedRetainPV released, data intact
3Admin manually cleans PVDeletedAvailableRetainPV ready for reuse
4PVC created and bound to PVBoundBoundDeletePV and PVC linked
5User deletes PVCDeletedReleasedDeletePV released, storage deleted
💡 Execution stops after PVC deletion and reclaim policy action completes
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5
PVC StateNot createdBoundDeletedDeletedBoundDeleted
PV StateAvailableBoundReleasedAvailableBoundReleased
Reclaim PolicySet at PV creationRetainRetainRetainDeleteDelete
Key Moments - 3 Insights
Why does the PV remain after PVC deletion when reclaim policy is Retain?
Because Retain policy tells Kubernetes to keep the PV and data intact for manual cleanup, as shown in step 2 of the execution_table.
What happens to the PV and storage when reclaim policy is Delete?
The PV enters Released state and its storage is deleted automatically when the PVC is deleted, as shown in step 5 of the execution_table.
When does the PV state change to Released?
After PVC deletion with Retain or Delete policy, the PV state changes to Released indicating it is no longer bound but data may remain, as in step 2 and step 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the PV state immediately after PVC deletion with Retain policy?
AReleased
BDeleted
CBound
DAvailable
💡 Hint
Check Step 2 in execution_table where PVC is deleted: PV state is Released.
At which step does the PV get deleted automatically?
AStep 3
BStep 4
CStep 5
DStep 2
💡 Hint
Look at Step 5 in execution_table where reclaim policy is Delete and PV is released and storage deleted.
If the reclaim policy was changed from Retain to Delete, what would happen at Step 2?
APV state changes to Released
BPV and storage get deleted
CPV remains Bound
DPVC remains Bound
💡 Hint
Refer to Step 5 where Delete policy causes PV release and storage deletion after PVC deletion.
Concept Snapshot
Reclaim policies control what happens to storage after PVC deletion.
Retain: PV stays, manual cleanup needed.
Delete: PV released and storage deleted automatically.
Set in PV spec: persistentVolumeReclaimPolicy.
Important for managing storage lifecycle in Kubernetes.
Full Transcript
In Kubernetes, PersistentVolumes (PV) have a reclaim policy that decides what happens when the PersistentVolumeClaim (PVC) using it is deleted. The two main policies are Retain and Delete. When the PVC is deleted, if the policy is Retain, the PV enters the Released state and data is kept safe for manual cleanup. If the policy is Delete, the PV enters Released state and its storage is deleted automatically. This flow helps manage storage resources properly. The execution table shows step-by-step how PVC and PV states change depending on the reclaim policy. Understanding this helps avoid accidental data loss or orphaned storage.