How to wait until Kubernetes list of pods are successful using shell script

不想你离开。 提交于 2019-12-24 00:36:55

问题


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

This is not giving any output


回答1:


you need to use this command

kubectl rollout status 



回答2:


If you want to use kubectl as described here where it gets all the jobs, you need to use .items[*]... in your JSONpath (That answer is for just one specific job). For example:

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


来源:https://stackoverflow.com/questions/52862487/how-to-wait-until-kubernetes-list-of-pods-are-successful-using-shell-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!