Blue Green Helm Deployments

Carl Domingue
2 min readApr 22, 2022

I’ve been thinking about how to implement blue/green deployments in my kubernetes applications for a long time, and it turns out to be far easier than I thought.

Some Background

Helm is an excellent tool for deploying kubernetes applications, and one key element to enabling blue/green deployments is helm’s ability to manage multiple releases of the same chart.

A deployment is composed of a docker image and any other resources (ConfigMap, PersistentVolumes, Secrets etc) assembled to form a running application. These resources may be configured in different ways yielding a different release. In our use case we need two releases — blue and green.

How It’s Done

Another key element to enabling multiple deployments is to ensure that the application’s resources are uniquely named so there are no conflicts between the different releases. Let’s start by creating a new chart for deploying an nginx server app:

Note the use of .Release.Name instead of the default .Chart.Name - this ensures a unique naming of resources. We can now install two different revisions of the application into the same namespace using these commands

helm install app-chart-blue app-chart --set indexText="this is blue"helm install app-chart-green app-chart --set indexText="this is green"

Where’s the Ingress?

So far no Ingress resource has been defined, and this is by design to easily toggle between the revisions. We will define a new chart which contains the ingress, or rather two ingresses, since a blue/green strategy is normally used to stage a new release before making it generally available. Let’s take a look at the ingress chart:

Let’s install the ingress chart such that production points to blue and preview/staging points to green:

helm install app-chart-ingress app-chart-ingress --set releaseName=app-chart-blue  --set prevReleaseName=app-chart-green

Our setup looks like this:

When we’ve completed testing using the preview/staging host we can toggle the ingress such that production points to the green release:

helm upgrade --install app-chart-ingress app-chart-ingress --set releaseName=app-chart-green  --set prevReleaseName=app-chart-green

and our setup now looks like this:

Cleaning Up

Now that our production hostname is directing traffic to the green release, we can uninstall the blue release since it is no longer needed:

helm uninstall app-chart-blue

Separating our application into two charts and using the .Release.Name allows us to easily manage blue/green deployments using helm.

--

--

Carl Domingue

I’m a software engineer in the Atlanta area currently working with cloud technology.