简体   繁体   中英

kubectl wait until pod is gone (Terminating)

I know I can use kubectl wait to check if a pod is Ready but is there an easy way to check whether the pod is gone or in Terminating state? I'm running some tests and I only want to continue when the pod (or the namespace for that matter) is completely gone.

Also a timeout option would come in handy.

It's actually part of the wait command.

kubectl wait --for=delete pod/busybox1 --timeout=60s

You can check with kubectl wait --help to see this example and some more. For example

--for='': The condition to wait on: [delete|condition=condition- name|jsonpath='{JSONPath expression}'=JSONPath Condition]. The default status value of condition-name is true, you > can set false with condition=condition-name=false.

If you execute kubectl delete po' <pod name> , the command will automatically wait until the pod is deleted. This is thanks to the finalizers feature that keeps the resource (the Pod in this case) from being deleted until the dependent resources (the containers of the pod for example) are cleaned up by the kubelet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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