title: Ensure Kubernetes Deployment has completed and all pods are updated and available
body: <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>