<p>We Could deploy applications using 'Helm Charts' with</p>

<pre><code>helm install --name the-release  helm/the-service-helm --namespace myns
</code></pre>

<p>And we cold <em>'Rolling Upgrade'</em> the deployment using,</p>

<pre><code>helm upgrade --recreate-pods the-release helm/the-service-helm --namespace myns
</code></pre>

<p>Is there a way to use <em>'Helm Charts'</em> to achieve <strong><em>'Blue/Green'</em></strong> Deployments?</p>

<h1>Let's start from definitions</h1>
<p>Since there are <a href="https://thenewstack.io/deployment-strategies/" rel="nofollow noreferrer">many deployment strategies</a>, let's start from the definition.</p>
<p>As per <a href="https://martinfowler.com/bliki/BlueGreenDeployment.html" rel="nofollow noreferrer">Martin Flower</a>:</p>
<blockquote>
<p>The blue-green deployment approach does this by ensuring you have two production environments, as identical as possible. At any time one of them, let's say blue for the example, is live. As you prepare a new release of your software you do your final stage of testing in the green environment. Once the software is working in the green environment, you switch the router so that all incoming requests go to the green environment - the blue one is now idle.</p>
</blockquote>
<h1><code>Blue/Green</code> is not recommended in Helm. But there are workaround solutions</h1>
<ul>
<li><p>As per to <a href="https://github.com/helm/helm/issues/3518" rel="nofollow noreferrer">helm issue #3518</a>, it's not recommended to use <code>Helm</code> for <code>blue/green</code> or <code>canary</code> deployment.</p>
</li>
<li><p>There are at least 3 solutions based on top of Helm, see below</p>
</li>
<li><p>However there is a Helm chart for that case.</p>
</li>
</ul>
<h2>Helm itself (TL;DR: not recommended)</h2>
<p>Helm itself is not intended for the case. See their explanation:</p>
<blockquote>
<p><a href="https://github.com/helm/helm/issues/3518" rel="nofollow noreferrer">direct support for blue / green deployment pattern in helm · Issue #3518 · helm/helm</a></p>
</blockquote>
<blockquote>
<p>Helm works more in the sense of a traditional package manager, upgrading charts from one version to the next in a graceful manner (thanks to pod liveness/readiness probes and deployment update strategies), much like how one expects something like <code>apt upgrade</code> to work. Blue/green deployments are a very different beast compared to the package manager style of upgrade workflows; blue/green sits at a level higher in the toolchain because the use cases around these deployments require step-in/step-out policies, gradual traffic migrations and rollbacks. Because of that, we decided that blue/green deployments are something out of scope for Helm, though a tool that utilizes Helm under the covers (or something parallel like istio) could more than likely be able to handle that use case.</p>
</blockquote>
<h2>Other solutions based on <code>Helm</code></h2>
<p>There are at least three solution based on top of <code>Helm</code>, described and compared <a href="https://blog.csanchez.org/2019/01/22/progressive-delivery-in-kubernetes-blue-green-and-canary-deployments/" rel="nofollow noreferrer">here</a>:</p>
<ul>
<li><a href="https://github.com/carlossg/croc-hunter-jenkinsx-serverless/tree/master/shipper" rel="nofollow noreferrer">Shipper</a></li>
<li><a href="https://github.com/carlossg/croc-hunter-jenkinsx-serverless/tree/master/istio" rel="nofollow noreferrer">Istio</a></li>
<li><a href="https://github.com/carlossg/croc-hunter-jenkinsx-serverless/tree/master/flagger" rel="nofollow noreferrer">Flagger</a>.</li>
</ul>
<h3><a href="https://github.com/carlossg/croc-hunter-jenkinsx-serverless/tree/master/shipper" rel="nofollow noreferrer">Shipper</a> by Booking.com - <strong>DEPRECATED</strong></h3>
<p><a href="https://github.com/bookingcom/shipper" rel="nofollow noreferrer">bookingcom/shipper</a>: Kubernetes native multi-cluster canary or blue-green rollouts using Helm</p>
<blockquote>
<p>It does this by relying on Helm, and using Helm Charts as the unit of configuration deployment. Shipper's Application object provides an interface for specifying values to a Chart just like the helm command line tool.
Shipper consumes Charts directly from a Chart repository like ChartMuseum, and installs objects into clusters itself. This has the nice property that regular Kubernetes authentication and RBAC controls can be used to manage access to Shipper APIs.</p>
</blockquote>
<p>Kubernetes native multi-cluster canary or blue-green rollouts using Helm</p>
<h3><a href="https://github.com/carlossg/croc-hunter-jenkinsx-serverless/tree/master/istio" rel="nofollow noreferrer">Istio</a></h3>
<p>You can try something <a href="http://dougbtv.com/nfvpe/2017/06/05/istio-deploy/" rel="nofollow noreferrer">like this</a>:</p>
<pre><code>kubectl create -f &lt;(istioctl kube-inject -f cowsay-v1.yaml) # deploy v1
</code></pre>
<pre><code>kubectl create -f &lt;(istioctl kube-inject -f cowsay-v2.yaml) # deploy v1
</code></pre>
<h3><a href="https://github.com/carlossg/croc-hunter-jenkinsx-serverless/tree/master/flagger" rel="nofollow noreferrer">Flagger</a>.</h3>
<p>There is guide written by Flagger team: <a href="https://docs.flagger.app/usage/blue-green" rel="nofollow noreferrer">Blue/Green Deployments - Flagger</a>
This guide shows you how to automate Blue/Green deployments with Flagger and Kubernetes</p>
<h2>You might try Helm itself</h2>
<p>Also, as <a href="https://stackoverflow.com/users/11032044/kamol-hasan">Kamol Hasan</a> recommended, you can try that chart: <a href="https://github.com/puneetsaraswat/HelmCharts/tree/master/blue-green" rel="nofollow noreferrer">puneetsaraswat/HelmCharts/blue-green</a>.</p>
<p><a href="https://github.com/puneetsaraswat/HelmCharts/blob/master/blue-green/templates/deployment-blue.yaml" rel="nofollow noreferrer"><code>blue.yml</code> sample</a></p>
<pre class="lang-yaml prettyprint-override"><code>{{ if .Values.blue.enabled }}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: {{ template &quot;blue-green.fullname&quot; . }}-blue
  labels:
    release: {{ .Release.Name }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version }}
    app: {{ template &quot;blue-green.name&quot; . }}
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    metadata:
      labels:
        app: {{ template &quot;blue-green.name&quot; . }}
        release: {{ .Release.Name }}
        slot: blue
    spec:
      containers:
        - name: {{ template &quot;blue-green.name&quot; . }}-blue
          image: nginx:stable
          imagePullPolicy: IfNotPresent
          ports:
            - name: http
              containerPort: 80
              protocol: TCP
          # This (and the volumes section below) mount the config map as a volume.
          volumeMounts:
            - mountPath: /usr/share/nginx/html
              name: wwwdata-volume
      volumes:
        - name: wwwdata-volume
          configMap:
            name: {{ template &quot;blue-green.fullname&quot; . }}
{{ end }}
</code></pre>
<p>Medium blog post: <a href="https://medium.com/@saraswatpuneet/blue-green-deployments-using-helm-charts-93ec479c0282" rel="nofollow noreferrer">Blue/Green Deployments using Helm Charts</a></p>
