Home > Software design >  What happens if I delete a PVC that it's volume is bound to a PV?
What happens if I delete a PVC that it's volume is bound to a PV?

Time:11-21

The problem I have is that I need to modify the StorageClassName but it's not possible because there was a blank StorageClassName assigned.

The think is, as I said, this PVC is bound to a PV so, if I delete the PVC to create new one with the StorageClassName, the data that is in my AWS will be deleted?

Thanks.

CodePudding user response:

You can recreate an existing PVC reusing the same PV with no data losses by using reclaim policy.

In case of Delete, the PV is deleted automatically when the PVC is removed, and the data on the PVC will also be lost. In that case, it is more appropriate to use the “Retain” policy. With the “Retain” policy, if a user deletes a PersistentVolumeClaim, the corresponding PersistentVolume is not deleted. Instead, it is moved to the Released phase, where all of its data can be manually recovered.

Reclaim Policy: Used to tell the cluster what to do with the volume after releasing its claim. Current reclaim policies are:

  • Retain — manual reclamation
  • Recycle — basic scrub (rm -rf/thevolume/*)
  • Delete — associated storage assets such as AWS EBS, GCE PD, Azure Disk, or OpenStack Cinder volume is deleted

NOTE: Extremely recommended to use Retain policy for PVCs that store critical data.

Here in this blog you have detailed steps to recreate a PVC in another name space similarly you can change the storage class.

  • Related