Spotinst raises $15M Series A Led By Intel Capital and Vertex Ventures Read The Official Press Release

Implementing Blue/Green deployments with Elastigroup on AWS

Deploying a new version: Solved.

Aharon Twizer
Spotinst, Co-Founder and CTO

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 server 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.

g-flow-04

How does it work?

  1. 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)
  2. From your Elastigroup click on “Actions” and select “Deploy”
    image-073
  3. This will take you to the deployment page showing a history of deployments. Click on “Deploy”
    image-074
  4. Choose your batch size percentage and grace period between deployments then click “ROLL”
    image-075
  5. Elastigroup will spin up new (green) instances into your cluster and will monitor its status using ELB Health Checks.
  6. Once Elastigroup determines the health state of the newly registered instances, it scales down old (blue) instances.
  7. This process repeats itself until the entire cluster is replaced.
  8. 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:

image-078

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 here https://spotinst.atlassian.net/wiki/display/API/Roll+Instances.

$ curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer ${TOKEN}" -d @group_roll https://api.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.

Aharon Twizer
Spotinst, Co-Founder and CTO

Stay current

Sign up for our newsletter, and we'll send you the latest updates on Spotinst, tips, tutorials and more cool stuff!