k8s不能删除pv,pvc

k8s不能删除pv,pvc

参考 https://www.cnblogs.com/weifeng1463/p/11490399.html

一般删除步骤为:先删pod再删pvc最后删pv

但是遇到pv始终处于“Terminating”状态,而且delete不掉。

 

[root@k8s-master ops]# kubectl get  pvc -n kube-ops
NAME     STATUS        VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
opspvc   Terminating   opspv    20Gi       RWX                           15m
[root@k8s-master ops]# kubectl get  pv | grep ops
opspv                                                                               20Gi       RWX            Delete           Terminating   kube-ops/opspvc                                                           15m
[root@k8s-master ops]#

解决方法:

直接删除k8s中的记录:

 

[root@k8s-master ops]# kubectl patch pv opspv -p '{"metadata":{"finalizers":null}}'
persistentvolume/opspv patched
[root@k8s-master ops]# kubectl get  pv | grep ops
[root@k8s-master ops]# kubectl get  pvc -n kube-ops
NAME     STATUS        VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
opspvc   Terminating   opspv    0                                        17m
[root@k8s-master ops]# kubectl delete pvc opspvc  -n kube-ops
persistentvolumeclaim "opspvc" deleted
^C
[root@k8s-master ops]# kubectl get  pvc -n kube-ops
NAME     STATUS        VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
opspvc   Terminating   opspv    0                                        17m
[root@k8s-master ops]#
[root@k8s-master ops]# kubectl patch pvc opspvc  -p '{"metadata":{"finalizers":null}}' -n kube-ops
persistentvolumeclaim/opspvc patched
[root@k8s-master ops]# kubectl get  pvc -n kube-ops
No resources found.
[root@k8s-master ops]#

 

posted on 2019-10-16 10:43  光阴8023  阅读(10508)  评论(0编辑  收藏  举报