Retain vs Delete vs Recycle Reclaim Policy in Kubernetes Explained
Retain reclaim policy keeps the Persistent Volume (PV) after its claim is deleted, requiring manual cleanup. The Delete policy automatically deletes the PV and its storage when the claim is removed. The Recycle policy (now deprecated) used to clean the volume for reuse by deleting its contents.Quick Comparison
This table summarizes the key differences between the three reclaim policies in Kubernetes Persistent Volumes.
| Reclaim Policy | Action on PV after PVC deletion | Storage Cleanup | Automation Level | Use Case |
|---|---|---|---|---|
| Retain | PV remains but is released and not deleted | No automatic cleanup; manual intervention needed | Manual | Data preservation and manual recovery |
| Delete | PV and underlying storage are deleted | Automatic cleanup of storage | Automatic | Temporary storage or dynamic provisioning |
| Recycle (Deprecated) | PV is scrubbed and made available again | Deletes files inside volume but keeps PV | Semi-automatic | Reuse of volumes with basic cleanup |
Key Differences
The Retain policy keeps the Persistent Volume (PV) intact even after the Persistent Volume Claim (PVC) is deleted. This means the data remains on the storage, but the PV is released and no longer bound to any claim. Manual cleanup or recovery is required to reuse or delete the volume, making it suitable when data must be preserved.
The Delete policy automatically deletes both the PV and its underlying storage resource when the PVC is deleted. This is common with dynamically provisioned volumes where storage lifecycle is tied to the claim, simplifying cleanup and resource management.
The Recycle policy was designed to delete the contents of the volume (like deleting files) and then make the PV available again for new claims. However, it is deprecated and not recommended for use because it only supports basic cleanup and lacks flexibility compared to other methods.
Retain Reclaim Policy Example
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-retain-example
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
hostPath:
path: "/mnt/data-retain"Delete Reclaim Policy Equivalent
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-delete-example
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Delete
hostPath:
path: "/mnt/data-delete"When to Use Which
Choose Retain when you need to keep data safe after the claim is deleted, such as for backups or manual recovery.
Choose Delete for dynamic storage where you want automatic cleanup to save resources and avoid manual steps.
Avoid Recycle as it is deprecated and offers limited cleanup; prefer manual scripts or external tools for volume reuse.