<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>

<p>I found a solution that works well. Set the property <code>.spec.progressDeadlineSeconds</code> to a value such as 30 (default is 600 or ten minutes) and <code>kubectl rollout status deployment</code> will wait for this amount of time before displaying an error message and exiting with a non zero exit code:</p>

<pre><code>$ kubectl rollout status deploy/nginx
Waiting for rollout to finish: 2 out of 3 new replicas have been updated...
error: deployment "nginx" exceeded its progress deadline
</code></pre>

<p>Documentation is here: <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#failed-deployment" rel="noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#failed-deployment</a></p>
