Skip to content

Blue/Green Deployment (Kubernetes)

Blue/Green Deployment is a release strategy that aims to achieve zero downtime by maintaining two identical production environments—referred to as "Blue" and "Green."^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md]

Overview

In Kubernetes, this strategy is implemented by running two versions of an application simultaneously.^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md] The core concept involves directing external traffic to the active version (e.g., v1) while the new version (e.g., v2) is deployed and fully readied in the background.^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md]

One of the primary characteristics of this method is the requirement for sufficient resources, as the system must handle the load of running both versions concurrently for a period of time.^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md]

Implementation Logic

The implementation in Kubernetes relies on manipulating the label selectors of a network resource, such as a [[Service]] or Ingress, to switch traffic between versions.^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md] This control mechanism ensures that the switch can happen instantaneously.

Deployment Process

The procedure typically follows these four steps^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md]:

  1. Deploy v1: Start the original version and configure the Service to point to it.
  2. Deploy v2: Start the new version and wait for it to become fully ready. At this stage, both v1 and v2 are running.
  3. Switch Traffic: Update the Service's label selector to target the new v2 version.
  4. Terminate v1: Remove the old v1 resources once the traffic switch is confirmed.

This approach creates a clean cut-over, avoiding issues where multiple versions exist simultaneously in the active traffic path, provided the underlying resources support the load.^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md]

Sources

^[400-devops__06-Kubernetes__k8s-ithelp__Day14__README.md]