MitocGroup / deepify

software development tool-chain that abstracts package management of cloud native web applications
https://www.deep.mg
Mozilla Public License 2.0
3 stars 0 forks source link

Blue-green deployments process #219

Open eistrati opened 8 years ago

eistrati commented 8 years ago

I would like to bring back an older conversation about blue-green deployments and implement it as deepify command(s):

eistrati commented 8 years ago

In order to use the serverless approach, we must setup the following weighted traffic in Route53:

Limitations:

  1. S3 website endpoint doesn't support HTTPS, therefore we must enforce somehow HTTP-only during blue/green deployment period (idea: explore "Evaluate Target Health" feature from Route53)
  2. S3 website endpoint as A alias record in Route53 will only work if S3 bucket name will be the same with (sub)domain name (e.g. www.adtechmedia.io)
eistrati commented 7 years ago

We have identified some use cases that we didn't cover before: 1) If blue-green ratio is 0:1, deepify publish must swap environments and turn off Lambda@Edge Notes

eistrati commented 7 years ago

Here below is my understanding of improved functionality:

  1. Change CNAME of blue CF into wildcarded (www.deep.mg => .deep.mg). If CNAME already exists, stop with message "In order to avoid DNS lags and unexpected behavior, deepify publish requires wildcarded SSL (e.g. .mydomain.com) during blue-green deployment process. Please release it from other CloudFront distribution and try again."

  2. Create new CF that points to blue S3 bucket, with CNAME of blue CF (e.g www.deep.mg). It will be running Lambda@Edge and returning HTTP 302 to blue CF or green CF based on traffic ration (e.g 1:9, 2:9, 1:3, 1:0, etc). Wait for status=deployed.

  3. In worse case scenario, if Lambda@Edge doesn't return HTTP 302, catch the response and allow the request to pass through by returning the data from origin. From this point of view, new CF is the "clone" of blue CF.

  4. Check green CF to have the right CNAME (www2.deep.mg). If not, prompt user to change CNAME (Y/n)?

  5. Create (if exists, update) Route53 A Aliases of www to new CF, www1 to blue CF and www2 to green CF. If ratio is 1:0 or 0:1, keep www1 and www2 records (obviously, www as well) by changing to the CF that remains active.

  6. If deepify doesn't have access to Route53 or another DNS provider, ask users to manually make DNS changes and re-run the command. Obviously, think through above functionality, to make sure it supports external DNS changes that will be done manually, but don't wait on those changes. Return the right informative message on how CNAMEs should look like and finish script's execution.

NOTE: Let's create separate parameter (e.g. --cleanup) that, if enabled, will clean up CF and Route53 resources. We should also mention somewhere and/or prompt an Y/N confirmation because using this parameter by default might create DNS lags or other unexpected behavior. It is HIGHLY recommended to use --cleanup only couple of hours/days after --ration 0:1 was executed.

avozicov commented 7 years ago

Testing actions is blocked by the following issue : https://github.com/MitocGroup/deepify/issues/365