There are multiple application deployment strategies that help in minimizing the impact of frequent deployments on the availability of information and on business. Each strategy has its pros and cons. Selecting the right one is determined by the needs and constraints of IT & business. These strategies range from Big Bang Deployment, Phased/Ramped Deployment to Blue-Green Deployment, Canary and A/B testing deployment.
The Blue-Green Deployment Strategy is a popular technique. It has two identical production environments, usually named Blue and Green. The use of identical environments is to reduce risk and downtime. Blue-Green Deployment Strategy fully supports the continuous delivery model. Under this strategy, any work that may be ongoing on apps does not (ever) hamper the availability of the apps. At any time, one of the environments, such as blue, is live and current. During an update, the non-live version of the environments is updated and readied (green) and tested. Once final, the green production environment is made live.
The blue-green strategy is often used to deploy microservices applications on cloud or in-house infrastructure. Pivotal Cloud Foundry (PCF), a cloud-native platform for deploying and operating modern applications, enables the in-house infrastructure to serve as a cloud and infrastructure as a service:
Let’s consider that we have a microservice named “notes-service” for which we need to implement the blue-green deployment.
Implementation of a blue-green deployment strategy with PCF requires the following steps:
‘Live route’ handles current live traffic and routes to the application version deployed in the blue environment
‘Temporary route’ handles the new application version deployed in the green environment. Once it’s running, internal testing is completed to validate its functionality before routing the live traffic to this version.
After steps 1 and 2 in the CF dashboard, navigate to the routes section, and it will provide the following routes:
This will start routing the live traffic on both blue and green environments rendering both application versions active.
Once the new version is stable and working, unmap the blue environment from the current live route to keep live requests now being served through the new application version (green).
Up till this step, both live and temporary routes can be used to access the new application version. Once the new version is determined to be stable, remove the temporary route so that the new version is accessible only through the live route. The blue is now the temp environment and kept available as part of the rollback strategy.
Plugging the ‘blue-green deployment strategy’ in the DevOps pipeline DevOps is crucial to the software development life cycle, the blue-green deployment strategy can be plugged into a DevSecOps pipeline to automate the preparation and the availability of the green environment with a new version, boosting the testing in the green environment and then rolling out the new version to market quickly. Building the deployment strategy as part of the DevSecOps pipeline also helps in ensuring the application quality and validating the application on several security aspects before turning it for production live traffic and hence is gaining momentum in making it an integral part of DevSecOps pipeline.
For instance, negative testing on applications, integrated with the DevSecOps pipeline, will validate if the application behaves securely; at the same time, it receives a corrupted or vulnerable data request. These tests would be useful to streamline the vulnerabilities management. When a vulnerability is identified in the current live (blue) environment, a patch is deployed on the green instance to resolve the vulnerability and then taken live, ensuring there is no downtime for the users.
Here is an example of blue-green deployment strategy using the Jenkins pipeline in the “notes-service” application mentioned above:
Follow the below mentioned sample Jenkins pipeline script to set up a blue and green pipeline
Integration test cases need to be set up to automate the deployment completely with integration testing and traffic routes switchover to combine the green and blue-green switch pipeline together.
Follow the below sample Jenkins pipeline script for blue-green switch pipeline to setup:
Deploy the green (new version) to the staging environment
Execute Integration Test cases in the staging environment
Switch routes to route the live production traffic to the green (new version) application code
The blue-green deployment strategy is immensely beneficial, and it can play an integral role in bringing agility in application deliveries and supporting business continuity. It helps automate the deployment process with zero downtime along with the automated integration testing of a new version in a production ready environment. The one drawback, at least for some businesses, is that it increases the overall cost of infrastructure to host two identical application environments. But, the business benefits from shorter deployment cycles lead to reduced time to market, customers get product value in less time, and customer feedback reaches the product team faster which meant it can fix problems faster.
Need help in implementing your blue-green deployment strategy? Then reach out to our experts here.