KUBERNETES(1)(kubernetes)
π kubectl wait
okay bestie, sit down, hydrate, and let me tell you about the actual most underrated glow-up command in the whole kubernetes(1) manual. this is kubectl wait and it is, no cap, the "are we there yet" of the cluster. π
πΈ NAME πΈ
kubectl wait β wait for a specific condition on one or many resources
like literally just. sit there. and wait. but in a cute, declarative way.
β¨ SYNOPSIS β¨
kubectl wait [OPTIONS]
π¦ DESCRIPTION π¦
Wait for a specific condition on one or many resources. that's the whole vibe.
The command takes multiple resources and waits until the specified condition is seen in the Status field of every given resource. every. single. one. it's giving β¨accountabilityβ¨.
Alternatively, the command can wait for the given set of resources to be created or deleted by providing the create or delete keyword as the value to the --for flag. yes bestie, you can just vibe and wait for a thing to exist or stop existing. iconic.
A successful message will be printed to stdout indicating when the specified condition has been met. and if you want that message somewhere else, you can use the -o option to change the output destination. she's flexible. π
π OPTIONS π
--all=falseβ select all resources in the namespace of the specified resource types. go big or go home.-A,--all-namespaces=falseβ if present, list the requested object(s) across all namespaces. the namespace in the current context gets ignored even if you specified it with--namespace. sorry girl, she's overruling you.--allow-missing-template-keys=trueβ if true, ignore any errors in templates when a field or map key is missing in the template. only applies togolangandjsonpathoutput formats.--field-selector=""β selector (field query) to filter on, supports'=','==', and'!='. (e.g.--field-selector key1=value1,key2=value2). heads up: the server only supports a limited number of field queries per type. don't get greedy.-f,--filename=[]β identifying the resource.--for=[]β the condition to wait on:[create|delete|condition=condition-name[=condition-value]|jsonpath='{JSONPath expression}'=[JSONPath value]]. the defaultcondition-valueistrue. condition values are compared after Unicode simple case folding, which is a more general form of case-insensitivity (so yes, your capitalization drama does not matter here π ). multiple conditions are supported and AND'ed to each other in a sequential order. and if--for=createis passed, it is always waited first. she has priorities.--local=falseβ if true, annotation will NOT contact api-server but run locally. introvert mode activated. π-o,--output=""β output format. one of: (json,yaml,kyaml,name,go-template,go-template-file,template,templatefile,jsonpath,jsonpath-as-json,jsonpath-file).-R,--recursive=trueβ process the directory used in-f,--filenamerecursively. useful when you want to manage related manifests organized within the same directory. she goes deep. π-l,--selector=""β selector (label query) to filter on, supports'=','==', and'!='. (e.g.-l key1=value1,key2=value2)--show-managed-fields=falseβ if true, keep themanagedFieldswhen printing objects in JSON or YAML format.--template=""β template string or path to template file to use when-o=go-template,-o=go-template-file. the template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].--timeout=30sβ the length of time to wait before giving up. Zero means check once and don't wait, negative means wait for a week. a WHOLE WEEK bestie. π
π OPTIONS INHERITED FROM PARENT COMMANDS π
these are the family heirlooms, passed down from the parent command. they're all yours too.
--as=""β username to impersonate for the operation. user could be a regular user or a service account in a namespace. (not me impersonating, it's a whole thing)--as-group=[]β group to impersonate for the operation. this flag can be repeated to specify multiple groups.--as-uid=""β UID to impersonate for the operation.--as-user-extra=[]β user extras to impersonate for the operation. this flag can be repeated to specify multiple values for the same key.--cache-dir="/home/username/.kube/cache"β default cache directory.--certificate-authority=""β path to a cert file for the certificate authority.--client-certificate=""β path to a client certificate file for TLS.--client-key=""β path to a client key file for TLS.--cluster=""β the name of the kubeconfig cluster to use.--context=""β the name of the kubeconfig context to use.--disable-compression=falseβ if true, opt-out of response compression for all requests to the server.--insecure-skip-tls-verify=falseβ if true, the server's certificate will not be checked for validity. β οΈ this will make your HTTPS connections insecure. like walking outside with no shoes. do not.--kubeconfig=""β path to the kubeconfig file to use for CLI requests.--kuberc=""β path to the kuberc file to use for preferences. this can be disabled by exportingKUBECTL_KUBERC=falsefeature gate or turning off the featureKUBERC=off.--match-server-version=falseβ require server version to match client version. picky queen.-n,--namespace=""β if present, the namespace scope for this CLI request.--password=""β password for basic authentication to the API server.--profile="none"β name of profile to capture. one of (none|cpu|heap|goroutine|threadcreate|block|mutex|trace).--profile-output="profile.pprof"β name of the file to write the profile to.--proxy-url=""β proxy URL to use for requests to the API server.--request-timeout="0"β the length of time to wait before giving up on a single server request. non-zero values should contain a corresponding time unit (e.g.1s,2m,3h). a value of zero means don't timeout requests.-s,--server=""β the address and port of the Kubernetes API server.--tls-server-name=""β server name to use for server certificate validation. if it is not provided, the hostname used to contact the server is used.--token=""β bearer token for authentication to the API server.--user=""β the name of the kubeconfig user to use.--username=""β username for basic authentication to the API server.--version=falseβ--version,--version=rawprints version information and quits;--version=vX.Y.Z...sets the reported version.--warnings-as-errors=falseβ treat warnings received from the server as errors and exit with a non-zero exit code. she does NOT let the side comments slide.
π EXAMPLE π
run these, they're literally the whole tutorial. copy-paste away, bestie.
# Wait for the pod "busybox1" to contain the status condition of type "Ready"
kubectl wait --for=condition=Ready pod/busybox1
# The default value of status condition is true; you can wait for other targets after an equal delimiter (compared after Unicode simple case folding, which is a more general form of case-insensitivity)
kubectl wait --for=condition=Ready=false pod/busybox1
# Wait for the pod "busybox1" to contain the status phase to be "Running"
kubectl wait --for=jsonpath='{.status.phase}'=Running pod/busybox1
# Wait for pod "busybox1" to be Ready
kubectl wait --for='jsonpath={.status.conditions[?(@.type=="Ready")].status}=True' pod/busybox1
# Wait for the service "loadbalancer" to have ingress
kubectl wait --for=jsonpath='{.status.loadBalancer.ingress}' service/loadbalancer
# Wait for the secret "busybox1" to be created, with a timeout of 30s
kubectl create secret generic busybox1
kubectl wait --for=create secret/busybox1 --timeout=30s
# Wait for the pod "busybox1" to be deleted, with a timeout of 60s, after having issued the "delete" command
kubectl delete pod/busybox1
kubectl wait --for=delete pod/busybox1 --timeout=60s
# Wait for pod "busybox1" to be created AND reach the "Ready" status condition
kubectl wait --for=condition=Ready --for=create pod/busybox1
# Wait for pod "busybox1" to reach the "Ready" status OR for its containers to report a "False" readiness state
until kubectl wait pod/busybox1 --for=condition=Ready --timeout=1s 2>/dev/null || \
kubectl wait pod/busybox1 --for=condition=ContainersReady=False --timeout=1s 2>/dev/null; \
do echo "Checking conditions..."; sleep 1; done
that last one is the "OR" energy. she loops until one of those is true. main character problem-solving fr fr. π«Ά
π SEE ALSO π
π HISTORY π
January 2015, Originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since!
and that's the whole page, bestie π¦ this gem came out of the kubernetes(1) manual β User manual, Manuals section, dated Jan 2015 and credited to Eric Paris β and honestly? it ate. go wait on something. slay. βπ πΈ
π¦ where this page comes from
- arch rolling: kubectl 1.37.2-1 Β· Apache-2.0
- fedora 43: kubernetes1.37-client 1.37.0-3.fc43
- fedora 43: kubernetes1.37-client 1.37.1-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-HP AND CC-BY-4.0 AND ISC AND MIT AND MPL-2.0
- fedora 44: kubernetes1.37-client 1.37.0-3.fc44
- fedora 44: kubernetes1.37-client 1.37.1-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND BSD-3-Clause-HP AND CC-BY-4.0 AND ISC AND MIT AND MPL-2.0
- nixpkgs unstable: kubectl 1.37.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms