<p>Kubernetes Blue-green deployment, I am patching the Kubernetes-application-service to redirect the traffic from app-v1 to app-v2(Behind the load balancer). if any connection is ongoing on during that "patching", will be disconnected? and if not !! how I can test this?</p>

<p>what is the best approach as per you for version deployment with the warm handover(without any connection loss) from app-v1 to app-v2?</p>

me25
<p>The question seems to be about supporting two versions at the same time. That is kind of <a href="https://github.com/ContainerSolutions/k8s-deployment-strategies/tree/master/canary" rel="nofollow noreferrer">Canary deployment</a>, which make production traffic to gradually shifting from app-v1 to app-v2. </p>

<p>This could be achieved with:</p>

<ul>
<li>Allow deployments to have HPA with custom metric that based on number of connections. That is, when it reaches certain number of connections scale up/down.</li>
<li>Allow two deployments at the same time, <code>app-v1</code> and <code>app-v2</code>.</li>
<li>Allow new traffic to route on new deployment via some Ingress annotation, but still keeping access to the old version, so no existing connection be dropped.</li>
<li>Now, all the new requests will be routed to the new version. The HPA eventually, scale down pods from old version. (You can even allow deployment to have zero replicas).</li>
</ul>

<p>Addition to your question above blue-green deployments.
The blue-green deployment is about having two identical environments, where one environment active at a time, let's say <code>blue</code> is active on production now. Once you have a new version ready for deployment, say <code>green</code>, is deployed and tested separately. Finally, you switched the traffic to the green environment, when you are happy with the test result on green environment. So <code>green</code> become active while <code>blue</code> become idle or terminated later sometime.
(Referred from martin fowler <a href="https://martinfowler.com/bliki/BlueGreenDeployment.html" rel="nofollow noreferrer">article</a>).</p>

<p>In Kubernetes, this can be achieved with having two identical deployments. Here is a good <a href="https://kubernetes.io/blog/2018/04/30/zero-downtime-deployment-kubernetes-jenkins/" rel="nofollow noreferrer">reference</a>. </p>

<p>Basically, you can have two identical deployments, assume you have current deployment <code>my-deployment-blue</code> is on production. Once you are ready with the new version, you can deploy it as a completely new deployment, lets say <code>my-deployment-green</code>, and use a separate test service to test the <code>green</code> environment. Finally, switch the traffic to the <code>my-deployment-green</code> when all test are passed.</p>
