Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to wait until Kubernetes list of pods are successful using shell script

I am trying to find a command or a sample shell snippet where I can wait until the list of Kubernetes pods is successful. I have checked the answer but it was not giving any output. Can someone guide me or suggest an approach, I am completely new to kubernetes.

kubectl -n test-ns get jobs -w

NAME     DESIRED   SUCCESSFUL   AGE
test-1    1         1            2d
test-2    1         1            2d
test-3    1         1            2d
test-4    1         1            2d


until kubectl get jobs -n test-ns  -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}' | grep True ; do sleep 1 ; done

This is not giving any output

like image 203
Auto-learner Avatar asked Oct 15 '25 14:10

Auto-learner


2 Answers

To wait until your pods are running, check for "condition=ready" and filter by app label, for example:

$ kubectl wait --for=condition=ready pod -l app=netshoot 
pod/netshoot-58785d5fc7-xt6fg condition met
like image 89
Noam Manos Avatar answered Oct 17 '25 21:10

Noam Manos


you need to use this command

kubectl rollout status 
like image 29
Scott Stensland Avatar answered Oct 17 '25 22:10

Scott Stensland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!