<p><a href="http://kubernetes.io/docs/user-guide/deployments/#the-status-of-a-deployment" rel="noreferrer">The status of a deployment</a> indicates that you can look at a deployments <code>observedGeneration</code> vs <code>generation</code> and when <code>observedGeneration &gt;= generation</code> then the deployment succeeded. That's fine, but I'm interested in knowing when the new container is actually running in <em>all</em> of my pods, so that if I hit a service I know for sure I'm hitting a server that represents the latest deployed container.</p>

<p>Another tip from a K8S Slack member:</p>

<pre><code>kubectl get deployments | grep &lt;deployment-name&gt; | sed 's/ /,/g' | cut -d ' ' -f 4
</code></pre>

<p>I deployed a bad image, resulting in <code>ErrImagePull</code>, yet the deployment still reported the correct number of 8 up-date-date replicas (available replicas was 7).</p>

<p><strong>Update #2:</strong> Kubernetes 1.5 will ship with a much better version of <code>kubectl rollout status</code> and improve even further in 1.6, possibly replacing my custom solution/script laid out below.</p>

<p><strong>Update #1:</strong> I have turned my answer into a <a href="https://github.com/timoreimann/kubernetes-scripts/" rel="noreferrer">script hosted on Github</a> which has received a small number of improving PRs by now.</p>

<p><strong>Original answer:</strong></p>

<p>First of all, I believe the <code>kubectl</code> command you got is not correct: It replaces all white spaces by commas but then tries to get the 4th field after separating by white spaces.</p>

<p>In order to validate that a deployment (or upgrade thereof) made it to all pods, I think you should check whether the number of available replicas matches the number of desired replicas. That is, whether the <code>AVAILABLE</code> and <code>DESIRED</code> columns in the <code>kubectl</code> output are equal. While you could get the number of available replicas (the 5th column) through</p>

<p><code>kubectl get deployment nginx | tail -n +2 | awk '{print $5}'</code></p>

<p>and the number of desired replicas (2nd column) through</p>

<p><code>kubectl get deployment nginx | tail -n +2 | awk '{print $2}'</code></p>

<p>a cleaner way is to use <code>kubectl</code>'s jsonpath output, especially if you want to take the generation requirement that the official documentation mentions into account as well.</p>

<p>Here's a quick bash script I wrote that expects to be given the deployment name on the command line, waits for the observed generation to become the specified one, and then waits for the available replicas to reach the number of the specified ones:</p>

<pre><code>#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset

deployment=

get_generation() {
  get_deployment_jsonpath '{.metadata.generation}'
}

get_observed_generation() {
  get_deployment_jsonpath '{.status.observedGeneration}'
}

get_replicas() {
  get_deployment_jsonpath '{.spec.replicas}'
}

get_available_replicas() {
  get_deployment_jsonpath '{.status.availableReplicas}'
}

get_deployment_jsonpath() {
  local readonly _jsonpath="$1"

  kubectl get deployment "${deployment}" -o "jsonpath=${_jsonpath}"
}

if [[ $# != 1 ]]; then
  echo "usage: $(basename $0) &lt;deployment&gt;" &gt;&amp;2
  exit 1
fi

readonly deployment="$1"

readonly generation=$(get_generation)
echo "waiting for specified generation ${generation} to be observed"
while [[ $(get_observed_generation) -lt ${generation} ]]; do
  sleep .5
done
echo "specified generation observed."

readonly replicas="$(get_replicas)"
echo "specified replicas: ${replicas}"

available=-1
while [[ ${available} -ne ${replicas} ]]; do
  sleep .5
  available=$(get_available_replicas)
  echo "available replicas: ${available}"
done

echo "deployment complete."
</code></pre>
