暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

0175.K delete pv状态状态一直为Terminating解决方法

rundba 2022-06-02
3024

 

  执行delete pv后,pv状态一直为Terminating状态,文中提供解决方法。

 

 

 

 

0. ENV


kubernetes V1.23.5;


 


1. 问题现象



执行kubectk delete pv nfs-pv-kuboard-prometheus后,pv状态一直为Terminating状态

    [root@rh-master01 ~]# kubectl get pv | grep nfs-pv-kuboard-prometheus
    nfs-pv-kuboard-prometheus 40Gi RWX Retain Terminating kube-system/nfs-pvc-kuboard-prometheus nfs-storageclass-provisioner 2d18h

     



    2. 尝试操作



     1) describe pv查看信息

    pv状态一直是Terminating,已经持续47h

      [root@rh-master01 ~]# kubectl describe pv nfs-pv-kuboard-prometheus
      Name: nfs-pv-kuboard-prometheus
      Labels: <none>
      Annotations: pv.kubernetes.io/bound-by-controller: yes
      Finalizers: [kubernetes.io/pv-protection] #终结器包含kubernetes.io/pv-protection
      StorageClass: nfs-storageclass-provisioner
      Status: Terminating (lasts 47h) #状态一直为Terminating
      Claim: kube-system/nfs-pvc-kuboard-prometheus
      Reclaim Policy: Retain
      Access Modes: RWX
      VolumeMode: Filesystem
      Capacity: 40Gi
      Node Affinity: <none>
      Message:
      Source:
      Type: NFS (an NFS mount that lasts the lifetime of a pod)
      Server: 192.168.80.159
      Path: /vm/dev-nfs/kuboard_pv/kuboard-prometheus
      ReadOnly: false
      Events: <none>


      2) 使用patch删除记录

      使用patch删除记录,但并未匹配信息

        [root@rh-master01 ~]# kubectl patch pv nfs-pv-kuboard-prometheus -p ‘{“metadata”:{“finalizers”:null}}’
        Error from server (BadRequest): json: cannot unmarshal string into Go value of type map[string]interface {}

         


        3. 问题原因



        当 PV 对象的状态为 Terminating 且其 Finalizers 列表中包含 kubernetes.io/pv-protection 时,PV 对象是处于被保护状态的。


         

        4. 问题解决



         注释pv的终结器(Finalizers)的状态,解除PV保护状态

          [root@rh-master01 ~]# kubectl edit pv nfs-pv-kuboard-prometheus
          4 #
          5 apiVersion: v1
          6 kind: PersistentVolume
          7 metadata:
          8 annotations:
          9 pv.kubernetes.io/bound-by-controller: "yes"
          10 creationTimestamp: "2022-05-24T13:33:40Z"
          11 deletionGracePeriodSeconds: 0
          12 deletionTimestamp: "2022-05-25T08:17:12Z"
          13 finalizers:
          14 # - kubernetes.io/pv-protection #注释改行,关闭pv的保护模式
          15 name: nfs-pv-kuboard-prometheus
          16 resourceVersion: "10338089"


          再次查看,pv已经消失

            [root@rh-master01 ~]# kubectl get pv | grep nfs-pv-kuboard-prometheus
            [root@rh-master01 ~]#


             

            5. 参考



              https://kubernetes.io/zh/docs/concepts/storage/persistent-volumes



               

              文章转载自rundba,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

              评论