<p>Say I have an in-memory Deployment object, what is the correct way of testing if it is fully ready? (not in the progress of rollout, upgrade or rollback).</p>

Dagang
<p>I can't comment, so it will have to be an answer.</p>

<hr>

<p>I don't think there is a <strong><em>right way</em></strong> of doing this, as it depends on a number of variables. Such as what languages you are proficient with etc.</p>

<p>Where I work, we run a <code>kubectl get pods</code> and grep the information that is relevant (in this case if the pod is available (ready) or not. This is all run through <code>bash</code> as part of a startup script:</p>

<pre><code>function not_ready_count() {
  kubectl ${1} get pods -o json | jq -r '.items[].status.conditions[].status' | grep False | wc -l | awk '{ print $1 }'
}

function not_running_count() {
  kubectl ${1} get pods -o json | jq -r '.items[].status.phase' | grep -v Running | wc -l | awk '{ print $1 }'
}

function wait_until_running_and_ready() {
  sleep 2
  while [[ "$(not_running_count ${1})" != "0" ]]; do
    echo "waiting for $(not_ready_count ${1}) pods to start"
    sleep 3
  done
  while [[ "$(not_ready_count ${1})" != "0" ]]; do
    echo "waiting for $(not_ready_count ${1}) status probes to pass"
    sleep 3
  done
  sleep 2
}
</code></pre>
