告诉工作何时完成 [英] Tell when Job is Complete

查看:98
本文介绍了告诉工作何时完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法(从脚本内)告诉Kubernetes作业何时完成.然后,我想从容器中取出日志并执行清理.

I'm looking for a way to tell (from within a script) when a Kubernetes Job has completed. I want to then get the logs out of the containers and perform cleanup.

什么是做到这一点的好方法?最好的方法是为1 Succeeded或类似版本运行kubectl describe job <job_name>和grep吗?

What would be a good way to do this? Would the best way be to run kubectl describe job <job_name> and grep for 1 Succeeded or something of the sort?

推荐答案

从1.11版开始,您可以执行以下操作:

Since version 1.11, you can do:

kubectl wait --for=condition=complete job/myjob

,您还可以设置超时时间:

and you can also set a timeout:

kubectl wait --for=condition=complete --timeout=30s job/myjob

这篇关于告诉工作何时完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆