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.
CodePudding user response:
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.
CodePudding user response:
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.