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

0
36
Asked By CuriousCoder123 On

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?

1 Answer

Answered By DataWiz42 On

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!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.