How to recover pv(Released) data after pvc deletion

3.3k views Asked by At

I have a kubernetes cluster on the eks of aws. I use aws-ebs as the Provisioner of StorageClass, and the ReclaimPolicy is set to Retain. I install the application with helm. When I delete the application, the pvc is deleted, but the pv still exists. The status is Released. I can see that the aws-ebs volume is still in the aws console. Now I want to create a new application and still use the original data. I think there are two ways to do it

  1. Manually create a pvc to bind this pv to make pv work again, but the StorageClass cannot be used
  2. Re-create a new PV to bind aws-ebs and then create a new PVC through this PV, it seems that StorageClass cannot be used

But I don’t know how to change it, can I ask for help? thanks in advance

1

There are 1 answers

3
Wytrzymały Wiktor On BEST ANSWER

The ReclaimPolicy: Retain means that:

The Retain reclaim policy allows for manual reclamation of the resource. When the PersistentVolumeClaim is deleted, the PersistentVolume still exists and the volume is considered "released". But it is not yet available for another claim because the previous claimant's data remains on the volume. An administrator can manually reclaim the volume with the following steps.

  1. Delete the PersistentVolume. The associated storage asset in external infrastructure (such as an AWS EBS, GCE PD, Azure Disk, or Cinder volume) still exists after the PV is deleted.

  2. Manually clean up the data on the associated storage asset accordingly.

  3. Manually delete the associated storage asset, or if you want to reuse the same storage asset, create a new PersistentVolume with the storage asset definition.

Here you can find an example showing step by step how to manually reuse a PV after PVC was deleted the way that the data will not be lost.