TL;DR. I'm lost as to how to access the data after deleting a PVC, as well as why PV wouldn't go away after deleting a PVC.
Steps I'm taking:
created a disk in GCE manually:
gcloud compute disks create --size 5Gi disk-for-rabbitmq --zone europe-west1-bran:
kubectl apply -f /tmp/pv-and-pvc.yamlwith the following config:
# /tmp/pv-and-pvc.yaml apiVersion: v1 kind: PersistentVolume metadata: name: pv-for-rabbitmq spec: accessModes: - ReadWriteOnce capacity: storage: 5Gi gcePersistentDisk: fsType: ext4 pdName: disk-for-rabbitmq persistentVolumeReclaimPolicy: Delete storageClassName: standard --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: pvc-for-rabbitmq spec: accessModes: - ReadWriteOnce resources: requests: storage: 5Gi storageClassName: standard volumeName: pv-for-rabbitmqdeleted a PVC manually (on a high level: I'm simulating a disastrous scenario here, like accidental deletion or misconfiguration of a
helmrelease):kubectl delete pvc pvc-for-rabbitmq
At this point I see the following:
$ kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pv-for-rabbitmq 5Gi RWO Delete Released staging/pvc-for-rabbitmq standard 8m $ A side question, just improve my understanding: why PV is still there, even though it has a reclaim policy set to
Delete? Isn't this what the docs say for theDeletereclaim policy?
Now if I try to re-create the PVC to regain access to the data in PV:
$ kubectl apply -f /tmp/pv-and-pvc.yaml persistentvolume "pv-for-rabbitmq" configured persistentvolumeclaim "pvc-for-rabbitmq" created $ I still get this for pvs, e.g. a PV is stuck in Released state:
$ kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pv-for-rabbitmq 5Gi RWO Delete Released staging/pvc-for-rabbitmq standard 15m $ ...and I get this for pvcs:
$ kubectl get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE pvc-for-rabbitmq Pending pv-for-rabbitmq 0 standard 1m $ Looks like my PV is stuck in Released status, and PVC cannot access the PV which is not in Available status.
So, why the same PV and PVC cannot be friends again? How do I make a PVC to regain access to data in the existing PV?
ReleasedtoAvailable.. Its even worse with dynamic provisioning