kubectl wait --for=condition=complete --timeout=30s

kubectl wait --for=condition=complete --timeout=30s

我正在尝试通过此 documentation 使用 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 link.

谁能帮我解决这个问题

这看起来完全像是 运行宁 kubectl wait --for=condition=complete Pod as described in your output rather than a Job

一个 pod 没有 --for=condition=complete 选项。确切地说,当我 运行 它在 pod 上时我得到了什么:

$ kubectl wait --for=condition=complete pod/mypod-xxxxxxxxxx-xxxxx
error: .status.conditions accessor error: Failure is of the type string, expected map[string]interface{}

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

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

另一种选择是 rollout status - 等待部署完成:

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

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

正如 Rico 所概述的,您不能等待 pod 上的完成状态,假设您想等待作业完成使用以下内容

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