简体   繁体   English

kubectl 等待无法创建资源

[英]kubectl wait not working for creation of resources

How do you get around waiting on resources not yes created?您如何避免等待资源未创建?

In script I get:在脚本中我得到:

kubectl wait --for=condition=ready --timeout=60s -n <some namespace> --all pods

error: no matching resources found

This is a community wiki answer posted for better visibility.这是为了更好的可见性而发布的社区 wiki 答案。 Feel free to expand it.随意扩展它。

As documented:正如记录的那样:

Experimental: Wait for a specific condition on one or many resources.实验性:等待一个或多个资源的特定条件。

The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource.该命令获取多个资源并等待,直到在每个给定资源的状态字段中看到指定的条件。

Alternatively, the command can wait for the given set of resources to be deleted by providing the "delete" keyword as the value to the --for flag.或者,该命令可以通过提供“delete”关键字作为 --for 标志的值来等待给定的资源集被删除。

A successful message will be printed to stdout indicating when the specified condition has been met.成功消息将打印到标准输出,指示何时满足指定条件。 One can use -o option to change to output destination.可以使用 -o 选项更改为输出目标。

This command will not work for the resources that hasn't been created yet.此命令不适用于尚未创建的资源。 @EmruzHossain has posted two valid points: @EmruzHossain 发表了两个有效的观点:

  • Make sure you have provided a valid namespace.确保您提供了有效的命名空间。

  • First wait for the resource to get created.首先等待资源被创建。 Probably a loop running kubectl get periodically.可能是定期运行kubectl get的循环。 When the desired resource is found, break the loop.找到所需资源后,中断循环。 Then, run kubectl wait to wait for the resource to be ready.然后,运行kubectl wait等待资源准备就绪。

Also, there is this open thread: kubectl wait for un-existed resource.此外,还有一个开放线程: kubectl 等待不存在的资源。 #83242 which is still waiting (no pun intended) to be implemented. #83242仍在等待(无双关语)实施。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM