Having trouble deleting a persistent volume claim (PVC) stuck in “terminating“ status in Kubernetes/Openshift? We‘ve got the fix. Read on to learn how to patch the PVC to allow the final unmount and delete the PVC.
The Issue
Whilst working on a Kubernetes demo for a customer, I was cleaning up my environment and deleting persistent volume claims (PVC) that were no longer need.
I noticed that one PVC was stuck in “terminating” status for quite a while.
Note: I am using the OC commands in place of kubectl due to this being a Openshift environment
The Cause
I had a quick google and found I needed to verify if the PVC is still attached to a node in the cluster.
kubectl get volumeattachment
I could see it was, and the reason behind this was the configuration for the PVC was not fully updated during the delete process.
The Fix
I found the fix on this github issue log .
You need to patch the PVC to set the “finalizers” setting to null, this allows the final unmount from the node, and the PVC can be deleted.
kubectl patch pvc {PVC_NAME} -p '{"metadata":{"finalizers":null}}'
Regards
no volume attachments in my case.
my issue details: https://serverfault.com/questions/1103575/terraform-destroy-failing-for-kubernetes-provider-with-pvc-in-aws-eks-how-to-fi
Thank you!
Thanks!
you saved me ! thx
Thanks it worked
Thank you so much, saved my day