<p>Accidentally tried to delete all PV's in cluster but thankfully they still have PVC's that are bound to them so all PV's are stuck in Status: Terminating.</p>

<p>How can I get the PV's out of the "terminating" status and back to a healthy state where it is "bound" to the pvc and is fully working?</p>

<p>The key here is that I don't want to lose any data and I want to make sure the volumes are functional and not at risk of being terminated if claim goes away.</p>

<p>Here are some details from a <code>kubectl describe</code> on the PV.</p>

<pre><code>$ kubectl describe pv persistent-vol-1
Finalizers:      [kubernetes.io/pv-protection foregroundDeletion]
Status:          Terminating (lasts 1h)
Claim:           ns/application
Reclaim Policy:  Delete
</code></pre>

<p>Here is the describe on the claim.</p>

<pre><code>$ kubectl describe pvc application
Name:          application
Namespace:     ns
StorageClass:  standard
Status:        Bound
Volume:        persistent-vol-1
</code></pre>

Hobbit-42
<p><strong>It is, in fact, possible to save data from your <code>PersistentVolume</code> with <code>Status: Terminating</code> and <code>RetainPolicy</code> set to default (delete).</strong> We have done so on GKE, not sure about AWS or Azure but I guess that they are similar</p>
<p>We had the same problem and I will post our solution here in case somebody else has an issue like this.</p>
<p>Your <code>PersistenVolumes</code> will not be terminated while there is a pod, deployment or to be more specific - a <code>PersistentVolumeClaim</code> using it.</p>
<p>The steps we took to remedy our broken state:</p>
<p>Once you are in the situation lke the OP, the first thing you want to do is to create a snapshot of your <code>PersistentVolumes</code>.</p>
<p>In GKE console, go to <code>Compute Engine -&gt; Disks</code> and find your volume there (use <code>kubectl get pv | grep pvc-name</code>) and create a snapshot of your volume.</p>
<p>Use the snapshot to create a disk: <code>gcloud compute disks create name-of-disk --size=10 --source-snapshot=name-of-snapshot --type=pd-standard --zone=your-zone</code></p>
<p><strong>At this point, stop the services using the volume and delete the volume and volume claim.</strong></p>
<p>Recreate the volume manually with the data from the disk:</p>
<pre><code>---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: name-of-pv
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 10Gi
  gcePersistentDisk:
    fsType: ext4
    pdName: name-of-disk
  persistentVolumeReclaimPolicy: Retain
</code></pre>
<p>Now just update your volume claim to target a specific volume, the last line of the yaml file:</p>
<pre><code>---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
  namespace: my-namespace
  labels:
    app: my-app
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  volumeName: name-of-pv
</code></pre>
