等待库贝内斯或Google集装箱发动机的工作/荚完成 [英] Wait for job/pod completion in Kubernetes or Google Container Engine

查看:155
本文介绍了等待库贝内斯或Google集装箱发动机的工作/荚完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



特别是,要通知您的工作或荚可以在Kubernetes或Google集装箱引擎中完成任务而不是在 kubectl 中轮询状态,但是我会很高兴有一个相当有效的循环,没有任何滑动之间的裂缝。基本上,我想要等同于一个简单的 docker运行,因为阻塞直到命令终止,但是我不想在这种情况下直接使用docker。



我查看了 Github问题#1899 但是它看起来尚未解决。

解决方案

这不是真正的设计,但您可以运行 kubectl附加$ POD 。它会在播放器运行时显示播放器的输出,并在pod运行完成后自动终止。



当然,您必须处理如果pod已经运行,它将打印,因为它只是真正用于当前正在运行的pod。


What's the best way in script to wait for a job or pod to complete in Kubernetes or Google Container Engine?

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. 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.

I looked at Github Issue #1899 but it looks unresolved as yet.

解决方案

It's not really what it was designed for, but you could run 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.

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.

这篇关于等待库贝内斯或Google集装箱发动机的工作/荚完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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