【问题标题】:delete improperly removed PersistentVolume in kubernetes在 kubernetes 中删除不正确删除的 PersistentVolume
【发布时间】:2019-12-03 16:43:05
【问题描述】:

看起来,在删除 pv、pvc 时,我搞砸了。我可以毫无问题地删除 pvc,但我无法删除其中的 pv 保护 pv。在之前删除 pv,pvc 时,我按下了 CTRL+C,因为删除它需要时间,并且在删除 pvc 之前还删除了 storageclass。我不记得用于创建 pvc 的存储类。

post 中,它说,将 pvc 保护更新为 null 将有助于删除 pvc。但我不得不删除具有光伏保护的光伏。以下是 pv 的描述输出。

~/github/vault-operator# kubectl describe pv pv-hostpath
Name:            pv-hostpath
Labels:          type=local
Annotations:     pv.kubernetes.io/bound-by-controller: yes
Finalizers:      [kubernetes.io/pv-protection]
StorageClass:    manual
Status:          Terminating (lasts <invalid>)
Claim:           poc-namespace/pvc-hostpath
Reclaim Policy:  Retain
Access Modes:    RWO
Capacity:        1Gi
Node Affinity:   <none>
Message:         
Source:
    Type:          HostPath (bare host directory volume)
    Path:          /kube
    HostPathType:  
Events:            <none>

~/github/vault-operator# kubectl get pv,pvc
NAME                           CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS        CLAIM                            STORAGECLASS   REASON   AGE
persistentvolume/pv-hostpath   1Gi        RWO            Retain           Terminating   poc-namespace/pvc-hostpath   manual                  11d

问题是,我如何删除未正确删除的 pv 以及可能是我的问题。

【问题讨论】:

    标签: kubernetes persistent-volumes persistent-volume-claims storage-class-specifier


    【解决方案1】:

    在这种情况下,您有一个 PVC(poc-namespace/pvc-hostpath)阻止您的 PV 被删除。删除PVC,即可删除PV。

    一般来说,PVC的Reclaim Policy默认为delete,所以当你删除一个PVC时,它会自动删除与之绑定的PV。

    您的storageClass 可能是this 一个(或类似的),来自牧场主。它是基于hostPath 的,这意味着它将您的容器卷映射到主机。

    【讨论】:

    • 我错过了认出这个 pvc bcoz 它在不同的命名空间中。很好的收获。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-17
    • 1970-01-01
    相关资源
    最近更新 更多