<p>I have a simple Kubernetes deployment. It consists of a single, unreplicated container. There is no service exposing the container. The container has a health check which checks that it is correctly configured and can communicate with its external dependencies. I update the deployment using <code>kubectl apply</code>.</p>

<p>After updating the deployment, I would like to check that the new version has been rolled out completely and is passing its health check. I can't work out how to configure my deployment to achieve that.</p>

<p>I have tried various combinations of liveness and readiness probes, deployment strategies and ready/progress deployment properties. I've tried inspecting the status of the deployment, its pods and the rollout command. All to no avail.</p>

<p>I get the impression that I should be looking at deployment conditions to understand the status, but I can't find clear documentation of what those conditions are or how to bring them into being.</p>

<p>You have not mentioned your deployment strategy. But one generic problem I have seen with k8s deployments is that if the application fails to boot up, it will be restarted infinitely. So you might have to <code>kubectl delete deploy/******</code> explicitly after detecting the deployment failed status. (There is also <code>failureThreshold</code> for probes, but I didn't try yet).</p>

<p>Case <strong>Recreate</strong>:</p>

<p>You can use the combination of <code>progressDeadlineSeconds</code> and <code>readinessProbe</code>. Let's say your application needs 60 seconds to boot-up/spin-up. You need to configure <code>progressDeadlineSeconds</code> a bit more than 60 seconds just be in the safer side. Now, after running your <code>kubectl apply -f my-deploy.yaml</code>, run the <code>kubectl rollout status deploy/my-deployment</code> command. For me it looks like this:</p>

<pre><code>12:03:37 kubectl apply -f deploy.yaml
12:03:38 deployment "my-deployment" configured
12:04:18 kubectl rollout status deploy/my-deployment
12:04:18 Waiting for rollout to finish: 0 of 1 updated replicas are available (minimum required: 1)...
12:04:44 deployment "my-deployment" successfully rolled out
</code></pre>

<p>Once you execute the <code>rollout</code> command, kubectl will keep waiting till it has some answer. Also it returns with a proper exit code <code>echo $?</code> - you can check this programmatically and delete the deployment.</p>

<p>Case <strong>rollingUpdate</strong>:</p>

<p>If you have multiple replicas, then the above mentioned trick should work.
If you have just one replica, then use <code>maxUnavailable: 0</code> and <code>maxSurge: 1</code> along with the above config.</p>
