首页 > 解决方案 > kubectl 等待 --for=condition=complete --timeout=30s

问题描述

我正在尝试通过此文档使用 kubectl wait 命令检查 pod 的状态。以下是我正在尝试的命令

kubectl wait --for=condition=complete --timeout=30s -n d1 job/test-job1-oo-9j9kj

以下是我得到的错误

Kubectl error: status.conditions accessor error: Failure is of the type string, expected map[string]interface{}

和我的kubectl -o json output can be accessed via this github 链接

有人可以帮我解决问题吗

标签: kuberneteskubectl

解决方案


要等到您的 pod 运行,请检查“condition=ready”。另外,更喜欢按标签过滤,而不是指定 pod id。例如:

$ kubectl wait --for=condition=ready pod -l app=netshoot 
pod/netshoot-58785d5fc7-xt6fg condition met

另一个选项是推出状态- 等到部署完成:

$ kubectl rollout status deployment netshoot
deployment "netshoot" successfully rolled out

当需要等待安装应用程序时,这两个选项在自动化脚本中都非常有效。但是,正如@CallMeLaNN 为第二个选项所指出的那样,部署“推出”不一定没有错误。


推荐阅读