代码之家  ›  专栏  ›  技术社区  ›  David Dehghan

如何在GKE中找到使用持久卷声明的pod

  •  0
  • David Dehghan  · 技术社区  · 3 年前

    我在Google Kubernetes引擎中有几个持久卷声明,我不确定它们是否仍在使用。我如何才能知道它们连接到哪个吊舱,或者可以安全地删除它们?

    Google Kubernetes UI告诉我它们绑定到了哪个容器,但没有绑定到哪个容器。或者,这可能意味着它们与批量索赔绑定。

    kubectl describe也没有返回pod的名称。

       kubectl describe pv xxxxxx-id
    

    enter image description here

    0 回复  |  直到 3 年前
        1
  •  1
  •   David Dehghan    3 年前

    这给了你每个吊舱的聚氯乙烯

    kubectl get pods --all-namespaces -o=json | jq -c '.items[] | {name: .metadata.name, namespace: .metadata.namespace, claimName: .spec |  select( has ("volumes") ).volumes[] | select( has ("persistentVolumeClaim") ).persistentVolumeClaim.claimName }'
    
    推荐文章