Well-Architected Framework
Zero-downtime infrastructure deployments
Properly managing changes to your infrastructure, such as updating network policies or upgrading your Kubernetes cluster, is important to ensure the reliability of your upgraded application and achieve zero-downtime deployments.
Blue/green deployment limits downtime and reduces risk by maintaining two identical production environments — one live, one idle. You deploy to the idle environment, test thoroughly, then switch traffic over. If problems occur, you can roll back immediately by switching traffic back.
Blue/green infrastructure
Blue/green deployments require two identical application infrastructure environments, a method for deploying your application to your two environments, and a way to route your traffic between them.
The following diagram shows a basic blue/green deployment. The blue environment is the infrastructure where your current application runs. The green environment is identical, except that you have upgraded it to host the new version of the application.
You set up the blue and green environments as similar as possible. Infrastructure as code (IaC) lets you describe your environment as code and consistently deploy identical environments.
IaC makes your operations more cost-effective by allowing you to easily build and remove resources when you do not need them. Using IaC also lets you spin up your green environment whenever you need it. Instead of letting your blue and green environments persist indefinitely or allocating time to build them, you deploy your green infrastructure environment when you want to deploy your new software application. Once your green environment is stable, you can tear down your blue environment.
HashiCorp's Terraform is an infrastructure as code tool that can help you deploy and manage blue/green infrastructure environments. By using Terraform modules, you can consistently deploy identical infrastructure using the same code but in different environments through variables. You can also define feature toggles in your Terraform code to create a blue and green deployment environment simultaneously. You can then test your application in your new green environment, and then, when you are ready, set the toggle in your code to destroy your blue environment.
HashiCorp resources:
- Read the use Application Load Balancers for blue-green and canary deployments tutorial.
- Feature Toggles, Blue-Green Deployments & Canary Tests with Terraform blog by Rosemary Wang
External resources:
- Blue Green Deployment blog by Martin Fowler
- Continuous Blue-Green Deployments With Kubernetes blog by Tomas Fernandez
Next steps
In this section of Zero-downtime deployments, you learned about methods to deploy infrastructure changes with zero-downtime. Zero-downtime deployments is part of the Define and automate processes pillar.