<p>I am having a kubernetes deployment. I am trying to scale down it to zero replicas. how will i wait to ensure the number pods are zero ?</p>
<p>the following is my command to scale down the deployment</p>
<pre><code>kubectl scale deployment openet-k6 --replicas=0
</code></pre>
<p>How will i ensure all pods are scaled down ? I am actually using this command in a shell script , so i can write additional logic to check that .</p>
<p>thank you</p>

Starbucks Admin
<p>You can do a while loop, something like:</p>
<pre><code>#! /bin/bash


while true; do
  kubectl get pods -o json | jq -r '.items[].status.phase' | grep 'Running'
  RC=$?

  if [ ${RC} -eq 1 ]; then
    echo &quot;We're done here&quot;
    exit 0
  fi

  sleep 3
done
</code></pre>
<p>The above is just a very simple example. Ideally, you'll want to filter your pods based on labels.</p>
