如何使用Shell脚本等待Kubernetes Pod列表成功完成 [英] How to wait until Kubernetes list of pods are successful using shell script
本文介绍了如何使用Shell脚本等待Kubernetes Pod列表成功完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图找到一个命令或示例shell片段,在这里我可以等到Kubernetes Pod列表成功完成.我已经检查了答案,但是它没有给出任何输出.有人可以指导我或建议一种方法吗,我对kubernetes完全陌生.
I am trying to find a command or a sample shell snippet where I can wait until the list of Kubernetes pods is successful. I have checked the answer but it was not giving any output. Can someone guide me or suggest an approach, I am completely new to 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
这没有给出任何输出
推荐答案
要等到pod运行起来,请检查"condition = ready"并按应用标签进行过滤,例如:
To wait until your pods are running, check for "condition=ready" and filter by app label, for example:
$ kubectl wait --for=condition=ready pod -l app=netshoot
pod/netshoot-58785d5fc7-xt6fg condition met
这篇关于如何使用Shell脚本等待Kubernetes Pod列表成功完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文