I created the following persistent volume by calling
kubectl create -f nameOfTheFileContainingTheFollowingContent.yaml
apiVersion: v1
ki
For me pv was in retain state, hence doing the above steps did not work.
1st we need to change policy state as below :
kubectl patch pv PV_NAME -p '{"spec":{"persistentVolumeReclaimPolicy":"Delete"}}'
Then delete pvc as below.
kubectl get pvc
kubectl delete pvc PVC_NAME
finally, delete pv with
kubectl delete pv PV_NAME
This happens when persistent volume is protected. You should be able to cross verify this:
Command:
kubectl describe pvc PVC_NAME | grep Finalizers
Output:
Finalizers: [kubernetes.io/pvc-protection]
You can fix this by setting finalizers to null using kubectl patch
:
kubectl patch pvc PVC_NAME -p '{"metadata":{"finalizers": []}}' --type=merge
Ref; Storage Object in Use Protection
Just met this issue hours ago.
I deleted deployments that used this references and the PV/PVCs are automatically terminated.
In my case, as long as I delete the pod associated to both pv
and pvc
, the pv
and pvc
in terminating status are gone
I'm not sure why this happened, but after deleting the finalizers of the pv and the pvc via the kubernetes dashboard, both were deleted. This happened again after repeating the steps I described in my question. Seems like a bug.
You can get rid of editing your pvc! Remove pvc protection.