

How do we ensure 100% uptime of our applications and also allow for deployment of new code without interruptions? An important technique for reducing this risk is known as Blue-Green Deployments. The current live production environment called “blue” while the new environment with the new version of your software called “green”. With Elastigroup, we support this type of deployment natively and you can even set a percentage of your Elastigroup to deploy, these servers will first pass an ELB health check and then a (configurable) grace period will need to elapse prior to deploying new servers. Let’s take a closer look.
How does it work?
- When you deploy a new version you can simply change your current AMI or user-data (Startup scripts) setting in your Elastigroup (via Elastigroup UI, API, CloudFormation or Terraform)
- From your Elastigroup click on “Actions” and select “Deploy”
- This will take you to the deployment page showing a history of deployments. Click on “Deploy”
- Choose your batch size percentage and grace period between deployments then click “ROLL”
- Elastigroup will spin up new (green) instances into your cluster and will monitor its status using ELB Health Checks.
- Once Elastigroup determines the health state of the newly registered instances, it scales down old (blue) instances.
- This process repeats itself until the entire cluster is replaced.
- Note – In case the first instances deployment wasn’t successful for any reason and the instances didn’t get into a healthy state in the ELB, Elastigroup will stop the Blue/Green process and will send an immediate notification.
See it in action through an amazing UI experience:
Blue / Green Deployment via API
Alternatively, you can also deploy your instances via API. In the example below, we are using curl to roll the group with a text file that has the roll specs (percentage, graceperiod, and action). You can find more information on our API docs
$ curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d @group_roll https://help.spotinst.io/aws/ec2/group/<GROUP_ID>/roll $ cat group_roll { "batchSizePercentage" : 20, "gracePeriod" : 300, "strategy": { "action":"RESTART_SERVER" } }
We hope you like the Blue / Green deployment function of our Platform!
Best Regards,
The Spotinst Team.