ElectricFlow was designed to enable teams to streamline and to simplify their DevOps processes – from the most mundane automation workflows to the most complex and large-scale scenarios. As part of that, we’ve set to revolutionize one of the most nail-biting parts of software releases: deployments.
Aiming to make this process as boring, repeatable and push-button as possible, ElectricFlow boasts the industry’s most robust deployment automation feature set, providing several out-of-the-box ways to deploy applications that are designed to take the stress, guess work, and complex, one-off, scripting out of the equation. These include deployment options such as Smart Deploy, staging artifacts, and automatic error handling or process branching, as well as advanced deployment strategies and deployment policies – such as rolling deployments, blue/green, canary, and dark launch.
In this blog series, I provide step-by-step tutorials for each deployment pattern – which you can implement for your own application releases using our free community edition!
In my previous post I described some of the use cases for when you may want to use these advanced deployment strategies as a way to minimize risk and provided instructions for setting up Rolling Deployments in ElectricFlow. This week, I’d like to focus on another deployment strategy: Blue/Green Deployments.
What are Blue/Green Deployments
This deployment strategy reduces downtime and risk by running two identical Production environments, referred to as Blue and Green. The key difference between Rolling Deployment and Blue/Green Deployment is that there are two physically separate environments. At any given time, only one of these environments is ‘live’, serving all of the Production traffic.
Let’s say the currently live Production environment is the Green one. We will spin up a duplicate of that – the Blue environment – and deploy new versions of the application to that, which is currently not serving live traffic. Once the version deployed on Blue has been thoroughly tested and validated, and we see that it is stable and that the application is operating correctly, then all end-user Production traffic will be diverted to that environment, which is now live. After the switch, the Green environment becomes inactive, and can be either decommissioned, or used for deploying the next release that needs to be tested. Then the process is repeated when we’re ready to make the switch in Production, again.
Blue/Green deployment strategy is especially compelling when using cloud environment, where the resources can be dynamically spun up/decommissioned depending on the need. This is in contrast to on-premises data centers or physical hardware, where you would need to over-provision and keep the hardware for the duplicated environment, even when it is idle. The Blue/Green strategy is also useful when it is advantageous – and for some organizations even mandatory from a regulatory perspective – to maintain a separate mirrored environment for disaster recovery.
While Blue/Green deployments makes it much simpler to recover from unforeseen deployment errors, as there are two separate environments, it does come with a higher resource costs, due to the environment duplication. This may make it less feasible for extremely large Production environments/footprint.
How to set up Blue/Green Deployments in ElectricFlow:
ElectricFlow allows you to model and trigger Blue/Green deployments in multiple ways, depending on your processes and environment setup. For this tutorial, we’ll cover the most straightforward option: creating separate Blue and Green environments in the product’s GUI.
- The separate environments we’re creating are identical in every respect, and each is modeled and set up independently.
- The environments can be created either prior to the deployment (if they are using static resources), or dynamically at the deployment runtime using environment templates.
- Modeling Blue and Green as separate environments also allows us to keep track of the component inventory independently so that users can always know what is deployed to the Blue vs. Green environments at any given time.
- Once the environment models for Blue and Green are defined, we will map them to the applications, and can then execute the Blue/Green deployment process, like any other deployments in ElectricFlow.
In the below example, we’re using Blue/Green Deployment to deploy to Production the “shopping cart” application of an eCommerce site. The current deployment process requires that the application is tested in Dev and QA environments before it is deployed to the Production environment – where the Blue/Green strategy is used.
Here are the steps for modeling Blue/Green deployment for this use case:
- Create four environments
- Map the environments to the application
- Create a pipeline with three stages
- Create three tasks for the PROD stage
- Run the pipeline
! Note: If you’re new to ElectricFlow and the platform’s object model and key areas of the application, you may want to start with this video and our step-by-step in-product tutorials (look for the Tutorials popup when you log in to the product).
Create four environments named DEV, QA, BLUE, and GREEN.
Note: DEV, QA, BLUE, and GREEN are names for the environments in this use case. You can use any names you want for them as long as it is clear how they map to BLUE and GREEN.
Select the ShoppingCart application (comes seeded in the product), and then map the application tiers to the corresponding environment tiers in DEV, QA, BLUE, and GREEN.
Create a pipeline with three stages named DEV, QA and PROD.
In the PROD stage, create three tasks, with the below details (the Task name is in bold):
- DeployShoppingCart – This is another process task similar to what is in the DEV and QA stages with the environment name parameterized. The system will automatically switch deployments between the BLUE and GREEN environments.
- CertifyDeployment – This is a manual step to review and certify the deployment.
- completePostCertificationTasks – This is an automation task to run any post-certification tasks, such as updating the load balancer and switching the environment in preparation for the next pipeline run (for example, update the TargetEnv parameter)
In a Blue/Green deployment, before you run the pipeline, the GREEN environment is serving all of the Production traffic, and the BLUE environment is ready to be upgraded to the new software version.
- Before starting the deployment, set the RollingDeploy/TargetEnv property on the project to the first environment to which you want to deploy.
RollingDeploy/TargetEnv will be set to
BLUEbecause the GREEN environment is currently catering to end-user traffic.
When the pipeline starts:
- The pipeline will start at the DEV stage and continue to the PROD stage.
- Once the deployment reaches the PROD stage, the application process task will deploy to the BLUE environment based on the property value
$[/myProject/RollingDeploy/TargetEnv] , which was set to
BLUEat the beginning of the run.
- Once the deployment task has completed, there is a manual step to functionally verify the deployment.If there was a need for some automated testing, those tasks can easily be added to the pipeline stage.
- Once the deployment completes successfully, switch the user traffic to the BLUE servers, and update the
RollingDeploy/TargetEnv property to
GREEN. Setting the property value to
GREENwill ensure that the next deployment will happen to the GREEN environment while the BLUE environment serves Production traffic.
Deploy Anything, Anywhere. FREE.
Download ElectricFlow Community Edition
One moment... form is processing.
If you experience problems with the form, contact
Latest posts by Avantika Mathur (see all)
- Go with the Flow: Deployment Automation - March 19, 2018
- New! JFrog Artifactory Plugin for ElectricFlow - March 9, 2018
- Go with the Flow: Microservices and Containers Done Right! - February 21, 2018