Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete persistent volumes in Kubernetes

I am trying to delete persistent volumes on a Kubernetes cluster. I ran the following command:

kubectl delete pv pvc-08e65270-b7ce-11e9-ba0b-0a1e280502e2 pvc-08e87826-b7ce-11e9-ba0b-0a1e280502e2 pvc-08ea5f97-b7ce-11e9-ba0b-0a1e280502e2 pvc-08ec1cac-b7ce-11e9-ba0b-0a1e280502e2 

However it showed:

persistentvolume "pvc-08e65270-b7ce-11e9-ba0b-0a1e280502e2" deleted persistentvolume "pvc-08e87826-b7ce-11e9-ba0b-0a1e280502e2" deleted persistentvolume "pvc-08ea5f97-b7ce-11e9-ba0b-0a1e280502e2" deleted persistentvolume "pvc-08ec1cac-b7ce-11e9-ba0b-0a1e280502e2" deleted 

But the command did not exit. So I CONTROL+C to force exit the command. After a few minutes, I ran:

kubectl get pv 

And the status is Terminating, but the volumes don't appear to be deleting.

How can I delete these persistent volumes?

like image 312
Justin Avatar asked Aug 07 '19 19:08

Justin


People also ask

How do you clear PVCs in Kubernetes?

You can delete PVCs in using the kubectl delete command or from the F5 Console. To delete using kubectl, specify the PVC either by file or by name.

Does deleting PVC delete PV?

Reclaiming a persistent volume manuallyWhen a persistent volume claim (PVC) is deleted, the persistent volume (PV) still exists and is considered "released".

What are persistent volumes in Kubernetes?

A persistent volume is a piece of storage in a cluster that an administrator has provisioned. It is a resource in the cluster, just as a node is a cluster resource. A persistent volume is a volume plug-in that has a lifecycle independent of any individual pod that uses the persistent volume.


1 Answers

It is not recommended to delete pv it should be handled by cloud provisioner. If you need to remove pv just delete pod bounded to claim and then pvc. After that cloud provisioner should also remove pv as well.

kubectl delete pvc --all  

It sometimes could take some time so be patient.

like image 111
FL3SH Avatar answered Sep 18 '22 02:09

FL3SH