K8s 集群内有一个已经不再使用的 PV,虽然已经删除了与其关联的 Pod 及 PVC,并对其执行了删除命令,但仍无法正常删除,一直处于 Terminating 状态:

[root@k8s-master share]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS        CLAIM                             STORAGECLASS                   REASON   AGE
nfs-pv-kuboard-nfs                         20G        RWX            Retain           Terminating   kube-system/nfs-pvc-kuboard-nfs   nfs-storageclass-provisioner            19h
nfs-pv-storage-nfs                         10G        RWX            Retain           Terminating   kube-system/nfs-pvc-storage-nfs   nfs-storageclass-provisioner            16h
pvc-908de6c6-40d8-460c-97bd-38ac1799b677   10G        RWX            Delete           Bound         default/test-claim                managed-nfs-storage                     35m

解决办法:

[root@k8s-master share]# kubectl patch pv nfs-pv-storage-nfs -p '{"metadata":{"finalizers":null}}'              
persistentvolume/nfs-pv-storage-nfs patched
[root@k8s-master share]# kubectl patch pv nfs-pv-kuboard-nfs -p '{"metadata":{"finalizers":null}}'           
persistentvolume/nfs-pv-kuboard-nfs patched
[root@k8s-master share]# kubectl get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                STORAGECLASS          REASON   AGE
pvc-908de6c6-40d8-460c-97bd-38ac1799b677   10G        RWX            Delete           Bound    default/test-claim   managed-nfs-storage            36m
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐