0
0
KubernetesConceptBeginner · 3 min read

Kubernetes Persistent Volume Reclaim Policy Explained

In Kubernetes, the reclaimPolicy of a Persistent Volume (PV) defines what happens to the storage resource after the associated Persistent Volume Claim (PVC) is deleted. Common policies are Retain, Delete, and Recycle, controlling whether the volume is kept, deleted, or cleaned for reuse.
⚙️

How It Works

Think of a Persistent Volume (PV) like a rented storage locker. The reclaimPolicy is the rule that decides what happens to the locker after you stop renting it (delete the Persistent Volume Claim).

If the policy is Delete, the locker is emptied and removed automatically, freeing the space. If it is Retain, the locker stays as is, so you can keep or manually manage the data inside. The Recycle policy (now deprecated) used to clean the locker by deleting files so it could be rented again.

This policy helps Kubernetes manage storage resources efficiently and safely, depending on your needs for data preservation or cleanup.

💻

Example

This example shows a Persistent Volume with a reclaimPolicy set to Retain. When the claim is deleted, the volume and its data remain intact for manual recovery or reuse.

yaml
apiVersion: v1
kind: PersistentVolume
metadata:
  name: example-pv
spec:
  capacity:
    storage: 5Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: /mnt/data
Output
PersistentVolume 'example-pv' created with reclaimPolicy 'Retain'. When PVC is deleted, volume data remains.
🎯

When to Use

Use Delete reclaim policy when you want Kubernetes to clean up storage automatically after a claim is removed, ideal for dynamic provisioning and temporary data.

Choose Retain when you need to keep data safe after the claim is deleted, such as for backups, audits, or manual data migration.

The Recycle policy is rarely used now and generally replaced by dynamic provisioning with proper cleanup scripts.

For example, in a development environment, Delete is convenient to avoid leftover storage. In production, Retain helps prevent accidental data loss.

Key Points

  • Reclaim policy controls what happens to PV after PVC deletion.
  • Delete removes the volume and data automatically.
  • Retain keeps the volume and data for manual handling.
  • Recycle is deprecated and rarely used.
  • Choosing the right policy depends on your data retention needs.

Key Takeaways

The reclaimPolicy defines how Kubernetes handles PVs after PVC deletion.
Use 'Delete' for automatic cleanup and 'Retain' to keep data safe.
Recycle policy is deprecated and should be avoided.
Choosing the right reclaimPolicy helps manage storage lifecycle effectively.