Forum Navigation
You need to log in to create posts and topics.

Kubernetes stuck on removing PV

Problem

when trying to delete PV the resource is stuck in Terminating state and does not get deleted

Example:

NAME            CAPACITY          ACCESS         MODES        RECLAIM      POLICY          STATUS       CLAIM       STORAGECLASS        REASON        AGE

pvc-26026e36-c6f0-4414-a34c-7a996747fedb       1Gi          RWO        Delete        Terminating       default/pv1        standard          5d10h

Solution

Locate your PV with the following command

kubectl get pv

then edit the resource

kubectl edit pv <PV NAME>

find the following lines in the editor

finalizers:

– kubernetes.io/pv-protection

Delete both of them save and exit the VI editor

Run the following command

kubectl delete pv <PV NAME> –grace-period=0 –force

 

 

 

 

If you still need to keep the pvc settings and want to remove only the PV

edit the PV settings

kubectl edit pv pvc-9358d04c-497b-46fb-b828-d61385be8c08

and remove all parameters under finalizers

finalizers:
– kubernetes.io/pv-protection

to

finalizers:

save the new PV settings

 

PV Stuck on terminating state

For AWS EKS deployments  remove both of this lines

finalizers:
– kubernetes.io/pv-protection
– external-attacher/ebs-csi-aws-com

to

finalizers:

 

If you have found my website, guides, articles or videos useful, please buy me a coffee