What are blue/green deployments for Kubernetes?

What are blue/green deployments for Kubernetes?

Blue/Green deployments are a form of progressive delivery where a new version of the application is deployed while the old version still exists. The two versions coexist for a brief period of time while user traffic is routed to the new version, before the old version is discarded (if all goes well).

How Blue/Green deployments work

  1. The current version is marked with a color (e.g blue)
  2. A new deployment is performed with brand new pods and is marked with the new color (i.e. green)
  3. Both versions exist at the same but the Kubernetes service is still pointing at the existing/blue version and thus not all users of the system are see the change yet
  4. Different types of tests (e.g. smoke tests) can be performed on the new version with no impact to existing users
  5. After a user-defined amount of time, the Kubernetes service is switched and now points to the new version. All live users can now use the new functionality without any downtime
    1. If the new version works as expected, the old version is destroyed. The new version becomes the “current version” and the Kubernetes service stays as is
    2. If the new version has issues, the Kubernetes service is switched back to the previous version. This has minimal impact on users. The new version is destroyed and everything is back to the original state

Blue/Green deployments With Codefresh

Blue/green deployment step for Kubernetes

By default Kubernetes offers two very simple deployment methods (rolling updates and destroy/create) that can easily result in unplanned downtime if the new version of an application does not work as expected.

Codefresh offers a blue/green plugin that can be used in place of a standard Kubernetes deployment. The plugin offers the basic blue/green deployment process along with the automatic service switch if the new version works without errors.

Users of the plugin can configure the amount of time where both versions/colors are active. The plugin checks pod restart numbers to decide if the new version is healthy or not.

The plugin is open-source code, and can be used in Codefresh in a declarative manner or even manually from any container image.

Advanced progressive delivery with Argo Rollouts

In addition to the basic Blue/Green plugin, Codefresh offers advanced progressive delivery methods by leveraging Argo Rollouts, a project specifically designed for gradual deployments to Kubernetes.

Through Argo Rollouts, Codefresh can perform advanced blue/green deployments that support:

  1. Pausing a deployment and resuming it after a user-defined set of tests have succeeded
  2. Advanced traffic switching methods that take advantage of services meshes available on the Kubernetes cluster
  3. Creation of a preview service that can be used for verifying the new color (i.e smoke testing before the traffic switch takes place)
  4. Inclusion of Anti-affinity rules for better cluster utilization
  5. Easy management of the rollout status via the ArgoCD CLI