title: How to wait for a rollout to complete in Kubernetes
body: <p>As part of our CI pipeline, we have a deployment script for a number of web services that looks something like this:</p>
  
  <pre><code>kubectl apply -f deployment1.yml
  kubectl apply -f deployment2.yml
  </code></pre>
  
  <p>The problem is that the next stage of the pipeline sometimes fails because the services are not ready by the time it starts.</p>
  
  <p>I would like to add a line in the script that says something like:</p>
  
  <pre><code>Wait until all deployments are in the Ready state, or fail if more than 30 seconds has elapsed.
  </code></pre>
  
  <p>I thought that the following would work but unfortunately it seems that the timeout flag is not available:</p>
  
  <pre><code>kubectl rollout status deployment deployment1 --timeout=30s
  kubectl rollout status deployment deployment2 --timeout=30s
  </code></pre>
  
  <p>I don't want to run "kubectl rollout status" without a timeout as that will cause our build to hang if there is a failure in one of the deployments.</p>