<p>I have the following deployment in kubernetes:</p>

<pre><code> apiVersion: extensions/v1beta1
 kind: Deployment
 metadata:
   labels:
     run: hello-node
   name: hello-node
   namespace: default
 spec:
   replicas: 2
   selector:
     matchLabels:
       run: hello-node
   strategy:
     rollingUpdate:
       maxSurge: 2
       maxUnavailable: 0
     type: RollingUpdate
   template:
     metadata:
       creationTimestamp: null
       labels:
         run: hello-node
     spec:
       containers:
       - image: &lt;image&gt;:&lt;tag&gt;
         imagePullPolicy: Always
         name: hello-node
         livenessProbe:
           httpGet:
             path: /rest/hello
             port: 8081
           initialDelaySeconds: 15
           timeoutSeconds: 1
         ports:
         - containerPort: 8081
           protocol: TCP
         resources:
           requests:
             cpu: 400m
         terminationMessagePath: /dev/termination-log
       dnsPolicy: ClusterFirst
       restartPolicy: Always
       securityContext: {}
       terminationGracePeriodSeconds: 30
</code></pre>

<p>The issue is that when I update my deployment to let's say a new version of my image, <code>Kubernetes</code> will instantly kill both pods with the old image, and bring two new pods with the new image. While the new pods are booting up I experience an interruption of service.</p>

<p>Because of the <code>rollingUpdate</code> and the <code>livenessProbe</code> I'm expecting <code>Kubernetes</code> to do the following:</p>

<ol>
<li>Start one pod with the new image</li>
<li>Wait for the new pod to be healthy based on the <code>livenessProbe</code></li>
<li>Kill one pod with the old image</li>
<li>Repeat until all pods have been migrated</li>
</ol>

<p>I am missing something here?</p>

<p>What you need is <code>readinessProbe</code>.</p>
<p>The default state of <code>Liveness</code> before the initial delay is <code>Success</code>, whereas the default state of <code>Readiness</code> before the initial delay is <code>Failure</code>.</p>
<p>If you’d like your container to be killed and restarted if a probe fails, then specify a <code>LivenessProbe</code> and a <code>RestartPolicy</code> of <code>Always</code> or <code>OnFailure</code>.</p>
<p>If you’d like to start sending traffic to a pod only when a probe succeeds, specify a <code>ReadinessProbe</code>.</p>
<p>See <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/" rel="nofollow noreferrer">container probes</a> for more details.</p>
<p>To have the rolling update behavior you described, set <code>maxSurge</code> to <code>1</code> (default value). This tells the Deployment to &quot;scale up at most one more replica at a time&quot;. See <a href="http://kubernetes.io/docs/user-guide/deployments/#max-surge" rel="nofollow noreferrer">docs of <code>maxSurge</code></a> for more details.</p>
