How Blue/Green deployments work
- The current version is marked with a color (e.g blue)
- A new deployment is performed with brand new pods and is marked with the new color (i.e. green)
- 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
- Different types of tests (e.g. smoke tests) can be performed on the new version with no impact to existing users
- 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
- 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
- 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:
- Pausing a deployment and resuming it after a user-defined set of tests have succeeded
- Advanced traffic switching methods that take advantage of services meshes available on the Kubernetes cluster
- Creation of a preview service that can be used for verifying the new color (i.e smoke testing before the traffic switch takes place)
- Inclusion of Anti-affinity rules for better cluster utilization
- Easy management of the rollout status via the ArgoCD CLI