k8s无法删除pv,pvc问题

问题:

在k8s里面创建了pv,pvc删除时报错:error: resource(s) were provided, but no name was specified

k8s无法删除pv,pvc问题_第1张图片

解决:

正确的删除顺序:

1.先删除pod

2.再删除pv 

3.在删除pvc

删除pv,pvc命令:

kubectl patch pv pvname -p '{"metadata":{"finalizers":null}}'

kubectl patch pvc pvcname -p '{"metadata":{"finalizers":null}}'
[root@master1 pv]# kubectl get pod
NAME                         READY   STATUS              RESTARTS   AGE
nginx-web-6656ddb4dd-52gj6   0/1     ContainerCreating   0          6m38s
[root@master1 pv]# kubectl get deployment 
NAME        READY   UP-TO-DATE   AVAILABLE   AGE
nginx-web   0/1     1            0           4h30m
[root@master1 pv]# kubectl delete deployment nginx-web
deployment.apps "nginx-web" deleted
[root@master1 pv]# kubectl patch pv pv -p '{"metadata":{"finalizers":null}}'
persistentvolume/pv patched
[root@master1 pv]# kubectl patch pvc pvc -p '{"metadata":{"finalizers":null}}'
persistentvolumeclaim/pvc patched
[root@master1 pv]# kubectl get pv,pvc 
NAME                        STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/pvc   Lost     pv       0                                        4h36m
[root@master1 pv]# kubectl delete pvc pvc
persistentvolumeclaim "pvc" deleted
[root@master1 pv]# kubectl get pv,pvc 
No resources found

你可能感兴趣的:(kubernetes,容器,云原生)