How can I change a Kubernetes StorageClass reclaimPolicy from Delete to Retain without losing data?

June 30, 2025 1 answer
Asked by CuriousCoder123
Hey everyone! I currently have a StorageClass set to reclaimPolicy: Delete in my Kubernetes cluster. I'm looking to change it to Retain so that I don't lose any persistent volume data when I delete PVCs. I'm a bit worried about the data in the PVCs that are already using this StorageClass. How can I safely make this change?

Answers

DataWiz42
You can't change the `reclaimPolicy` directly on the StorageClass since itโ€™s immutable. But you can edit the Persistent Volume (PV) that it creates to change the `reclaimPolicy` to Retain, and youโ€™ll be fine! Just make sure to set up a new StorageClass with `reclaimPolicy: Retain` for the future. If youโ€™re worried about existing data, you might consider migrating it safely. One way could be to mount both the old and new PVs in a pod and use an initContainer to transfer the data between them. Thatโ€™s just one approach, but itโ€™s worth considering!

TechGuru99: Actually, itโ€™s simpler than that! Just edit the PV directly and change the `reclaimPolicy` to Retain. This way, you wonโ€™t lose any data and you donโ€™t need to manually synchronize anything!

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions