Kubernetes: How do I delete PV in the correct manner Kubernetes: How do I delete PV in the correct manner kubernetes kubernetes

Kubernetes: How do I delete PV in the correct manner


You can delete the PV using following two commands:

kubectl delete pv <pv_name> --grace-period=0 --force

And then deleting the finalizer using:

kubectl patch pv <pv_name> -p '{"metadata": {"finalizers": null}}'


Firstly run kubectl patch pv {PVC_NAME} -p '{"metadata":{"finalizers":null}}'

then run kubectl delete pv {PVC_NAME}


At the beginning be sure that your Reclaim Policy is set up to Delete. After PVC is deleted, PV should be deleted.

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#reclaiming

If it doesn't help, please check this [closed] Kubernetes PV issue:https://github.com/kubernetes/kubernetes/issues/69697

and try to delete the PV finalizers.