Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes Clustsr stuck on removing PV/PVC

Tags:

kubernetes

I am been struggling to get my simple 3 node Kubernetes cluster running.

$ kubectl get nodes                                                                                    NAME   STATUS   ROLES         AGE   VERSION
ubu1   Ready    master        31d   v1.13.4
ubu2   Ready    master,node   31d   v1.13.4
ubu3   Ready    node          31d   v1.13.4

I tried creating a PVC, which was stuck in Pending forever. So I deleted it, but now it is stuck in Terminating status.

$ kubectl get pvc
NAME                        STATUS        VOLUME           CAPACITY   ACCESS MODES   STORAGECLASS      AGE
task-pv-claim               Terminating   task-pv-volume   100Gi      RWO            manual            26d

How can I create a PV that is properly created and useable for the demos described on the official kubernetes web site?

PS: I used kubespray to get this up and running.

On my Ubuntu 16.04 VMs, this is the Docker version installed:

ubu1:~$ docker version
Client:
 Version:           18.06.2-ce
 API version:       1.38
 Go version:        go1.10.3
 Git commit:        6d37f41
 Built:             Sun Feb 10 03:47:56 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Thanks in advance.

like image 955
farhany Avatar asked Apr 14 '19 06:04

farhany


People also ask

How do you fix Kubernetes deleting a PVC stuck in status terminating?

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.

How do I delete all PV in Kubernetes?

Delete the PersistentVolume The kubectl delete command can be used to delete PVCs. To delete a PVC with kubectl, provide it by file or name.


2 Answers

kubectl patch pvc {PVC_NAME} -p '{"metadata":{"finalizers":null}}'

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.

like image 199
yasin lachini Avatar answered Sep 21 '22 06:09

yasin lachini


kubectl edit pv (pv name)

FIND the following

finalizers: - kubernetes.io/pv-protection

AND delete it. Then exit and: kubectl delete pv (pv name) --grace-period=0 --force

like image 44
Dragomir Ivanov Avatar answered Sep 20 '22 06:09

Dragomir Ivanov