[英]Wait for job/pod completion in Kubernetes or Google Container Engine
What's the best way in script to wait for a job or pod to complete in Kubernetes or Google Container Engine? 在Kubernetes或Google Container Engine中等待作业或pod完成的最佳方法是什么?
In particular, it would be better to be notified rather than polling for status in kubectl
, but I'd be happy with a fairly efficient loop without any slips between the cracks. 特别是,最好是通知而不是轮询
kubectl
状态,但我会对一个相当有效的循环感到满意,而且裂缝之间没有任何滑动。 Essentially, I'd like the equivalent of a plain docker run
since that blocks until command termination, but I don't want to use docker directly in this case. 从本质上讲,我喜欢相当于普通的
docker run
因为阻塞直到命令终止,但在这种情况下我不想直接使用docker。
I looked at Github Issue #1899 but it looks unresolved as yet. 我看了Github问题#1899,但它看起来尚未解决。
It's not really what it was designed for, but you could run kubectl attach $POD
. 这不是它的设计目的,但你可以运行
kubectl attach $POD
。 It'll show you the output of the pod while it's running and automatically terminate once the pod is done running. 它会在它运行时显示pod的输出,并在pod运行完毕后自动终止。
Of course, you'll have to handle the error that it prints if the pod is already done running, since it's only really meant for use on pods that are currently running. 当然,如果pod已经完成运行,你将不得不处理它打印的错误,因为它只适用于当前正在运行的pod。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.