Kubernetes: Can't delete PersistentVolumeClaim (pvc) Kubernetes: Can't delete PersistentVolumeClaim (pvc) kubernetes kubernetes

Kubernetes: Can't delete PersistentVolumeClaim (pvc)


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


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.

  1. kubectl edit pvc YOUR_PVC -n NAME_SPACE
  2. Manually edit and put # before this line enter image description here
  3. All pv and pvc will be deleted