-
Recreate Strategy:
The old version of the application is completely shut down before deploying the new version. This results in temporary unavailability for users during the transition. -
Rolling Update Strategy:
Instances of the old version are gradually replaced with newer ones one at a time. This approach minimizes downtime and facilitates a smoother upgrade process. Many systems default to this strategy.
Blue-Green Deployment Strategy
Blue-green deployment leverages two production environments:- Blue Environment: Runs the current or stable version of the application.
- Green Environment: Hosts the new version that is being prepared and tested.
Blue-green deployment minimizes risk by allowing testing of a new release in a live but isolated environment before directing all user traffic to it.
How Blue-Green Deployment Works with Kubernetes
-
Deploy the Blue Version (Current Production):
Deploy the original application version as the blue deployment with a label (e.g.,version: v1). A Kubernetes Service is created with a selector that matches this label, ensuring that all user traffic is routed to the blue Pods. -
Deploy the Green Version (New Release):
Deploy a separate green deployment that includes the new application version. Label these Pods withversion: v2. Although both blue and green deployments run concurrently, the Service continues routing traffic based on the label selector, initially favoring the blue version. -
Switch Traffic After Testing:
After thorough testing confirms that the green version is stable, update the Service’s label selector to point fromversion: v1toversion: v2. This update directs all incoming traffic to the green Pods, effectively switching the live environment.
Blue Deployment Example
The following YAML file defines the Service that initially directs traffic to the blue version:myapp-image:2.0) and labeling it as version: v2.
Once the green version has been rigorously tested, update the Service to switch traffic to it:


By utilizing blue-green deployments, you can reduce downtime and mitigate risks during application updates by ensuring the new version is fully tested before it takes over production traffic.