How do reclaim policys for persistent storage work in Kubernetes?

12/8/2020

I am having a bit of a problem understanding how the reclaim policy of persistent storage works in detail. I want to define a storage class that saves some logs and if the pods fail or I restart the setup, keeps the data.

According to here when I set the reclaim policy to delete the PV and the storage in Azure is removed. If it is set to retain the PV needs to be manually reclaimed.

Now I have the feeling that both types are wrong for my usage (although it seems rather common), as I do want to keep the data (so delete is wrong) and I do not want to manually reclaim the PV every time (so retain seems wrong).

Is there something I misunderstand or is there another way to achieve this?

-- Manuel
kubernetes
persistent-storage

1 Answer

12/8/2020

A reclaim policy of delete won't be deleted when the pod is deleted. This is more about when the PVC itself is deleted what happens with the cloud provider.

Delete means if the PVC itself is deleted the provisioned disk is also removed. If you have a pod which is deleted, as long as future pods use the pvc you'll still have the data, just don't delete the pvc resource also.

Having it set to retain means even when the pv/pvc resource is deleted the provisioned storage will remain just in case

-- Dom
Source: StackOverflow