Deploying Infrastructure as Code
Though it may seem confusing, some may not realize the benefits we can receive when a code is an infrastructure. With the innovation of infrastructure automation, reproducible environments become a possibility. We can then use the same automation scripts to deploy exact copies of production to development, test, and production environments. Finally, with these consistent deployments, we are able to achieve the ever-elusive development-to-prod parity, finally putting an end to the “it worked on my machine!” problems.
Blue/Green Deployments
For the pinnacle of infrastructure automation, we look at what is called the Blue/Green deployment strategy. This strategy enables zero downtime deployments and allows for us to run live tests before releasing our changes to our users. These Blue/Green Deployments take advantage of our ability to run exact copies of our environments in parallel and deploy a new, isolated copy of our environment. This new, copied environment is thusly named “Green” and is our release candidate. It will contain our new changes and is isolated from the live environment, which we then call “Blue”. This Green environment is configured for production and is then ready to go live, but it is launched darkly – that is, no traffic is routed to Green.
Next, we then run our acceptance tests against the live Green environment. If we do by a chance encounter an error, we can simply log the error, remove the Green environment and go back to the drawing board. No users will ever know the difference, as we never routed any live traffic to Green. If the acceptance tests do pass, we then promote our Green environment to be the new live environment. This will be done by changing a DNS entry to point at the Green environment or by removing the Blue environment from our load balancer and adding the Green environment to the load balancer.
Remember, you don’t have to be Netflix or Airbnb to take advantage of devops practices. Many fortune 500 companies and government agencies are adopting these patterns so that they can recover from failure quicker, deploy more often and quickly. The prerequisite to practicing these fantastic modern devops techniques is Infrastructure as Code.