Issue
I have a script with command that is sleeping if pods with specific labels is not ready. But it does not work if there are a few pods (in this way it need to be like condition != "true true true"). How can I check, if one of any pods is not ready (ready = false)?
while [ "$(kubectl get pods -l=app.kubernetes.io/instance=loki -n grafana -o jsonpath='{.items[*].status.containerStatuses[0].ready}')" != "true" ]; do
sleep 5
echo "Waiting for Loki to be ready."
done
Solution
You could just check to see if any pods have .ready
equal to false
like this:
while kubectl get pods \
-l=app.kubernetes.io/instance=loki \
-n grafana \
-o jsonpath='{.items[*].status.containerStatuses[0].ready}' | grep -q false; do
echo "Waiting for Loki to be ready."
sleep 5
done
Answered By - larsks Answer Checked By - Mildred Charles (WPSolving Admin)