【问题标题】:How to wait until Kubernetes list of pods are successful using shell script如何使用 shell 脚本等到 Kubernetes 的 Pod 列表成功
【发布时间】:2019-03-22 13:58:12
【问题描述】:

我正在尝试找到一个命令或示例 shell sn-p,我可以在其中等待 Kubernetes pod 列表成功。我检查了answer,但它没有给出任何输出。有人可以指导我或建议一种方法,我对 Kubernetes 完全陌生。

kubectl -n test-ns get jobs -w

NAME     DESIRED   SUCCESSFUL   AGE
test-1    1         1            2d
test-2    1         1            2d
test-3    1         1            2d
test-4    1         1            2d


until kubectl get jobs -n test-ns  -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}' | grep True ; do sleep 1 ; done

这没有给出任何输出

【问题讨论】:

    标签: shell kubernetes kubectl


    【解决方案1】:

    要等到您的 pod 运行,请检查“condition=ready”并按应用标签过滤,例如:

    $ kubectl wait --for=condition=ready pod -l app=netshoot 
    pod/netshoot-58785d5fc7-xt6fg condition met
    

    【讨论】:

      【解决方案2】:

      你需要使用这个命令

      kubectl rollout status 
      

      【讨论】:

        【解决方案3】:

        如果您想按照here 的描述使用 kubectl 来获取所有作业,则需要在 JSONpath 中使用 .items[*]...(该答案仅针对一项特定作业)。例如:

        kubectl -n test-ns get jobs \
          -o jsonpath='{.items[*].status.conditions[?(@.type=="Complete")].status}' \
          | grep True
        

        【讨论】:

          猜你喜欢
          • 2021-12-17
          • 2022-01-15
          • 2017-03-06
          • 1970-01-01
          • 2014-07-17
          • 2021-05-07
          • 2021-02-19
          • 2020-03-01
          • 1970-01-01
          相关资源
          最近更新 更多