Kubectl wait: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 29: Line 29:
The length of time to wait before giving up.  Zero means check once and don't wait, negative means wait for a week.
The length of time to wait before giving up.  Zero means check once and don't wait, negative means wait for a week.


{{Warn|The resource must '''exist''' for this option to be effective. If the resource does not exist, then the wait command exits immediately with an error message ("Error from server (NotFound): pods "..." not found"), irrespective of the timeout value.}}
{{Warn|The resource must '''exist''' for this option to be effective. If the resource is specified by name and does not exist, then the wait command exits immediately with an error message ("Error from server (NotFound): pods "..." not found"), irrespective of the timeout value. If the resource is specified by selector, the error message is "at least one resource must be specified to use a selector".}}


  ... --timeout=30s ...
  ... --timeout=30s ...

Revision as of 16:55, 20 September 2019

Internal

Overview

The command waits for a specific condition, as reported by the ".status.conditions" field on a pod state, on one or many pods. If more than one pod is specified, the condition must be seen in every pod. Alternatively, the command can wait for a specific pod to be deleted.

The documentation mentions "resources" instead of pods. Can wait be applied for other things than pods? If yes, what is them meaning of "condition" in that context, as other resources may not have conditions?

Wait for a Specific Condition

Wait on a Pod Specified by Name

kubectl wait --for=condition=Ready pod <pod-name>

Wait on a Pod Specified by Label

kubectl wait --for=condition=Ready -l color=blue

Wait for Deletion

kubectl wait --for=delete pod <pod-name> --timeout=60s

Options

--timeout

The length of time to wait before giving up. Zero means check once and don't wait, negative means wait for a week.


The resource must exist for this option to be effective. If the resource is specified by name and does not exist, then the wait command exits immediately with an error message ("Error from server (NotFound): pods "..." not found"), irrespective of the timeout value. If the resource is specified by selector, the error message is "at least one resource must be specified to use a selector".

... --timeout=30s ...

-l, --selector

Specifies the selector (label query) to use to identify the resource. The expression supports '=', '==', and '!='.

-l key1=value1,key2!=value2