How to wait for condition ready, and exclude others

Viewed 29

I have an installation where I need some pods to be ready. Therefore I use this

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

Problem is that there are some pods running jobs where there condition status is Completed, and therefore wait hangs as the condition never will be ready.

Is it possible to wait for all but the ones running jobs?

1 Answers

All jobs are given a label of "job-name" so you can filter based on whether the pod has that label:

kubectl wait --selector='!job-name' \
--for=condition=ready --timeout=60s -n some-namespace --all pods

If you don't want to skip all jobs, just the ones in Completed, you can filter on "status.phase" instead:

kubectl wait --field-selector=status.phase!=Succeeded \
--for=condition=ready --timeout=60s -n some-namespace --all pods
Related