Slide 1

Slide 1 text

Cyansible Blending Blue/Green Deployments @Betterment

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

Techcrunch Disrupt May 2010 90,000 customers, more every minute. Fastest growing automated investing service $2B+ Who are we?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

betterment : investing :: devops : engineering

Slide 7

Slide 7 text

it’s 2012. let’s ship some code.

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Betterment@2012

Slide 10

Slide 10 text

A Better Migration: From Snowflakes to Stormtroopers Wednesday, July 22, 6:30p - 8:00p @ AWS Pop-up Loft | NYC Shameless Plug:

Slide 11

Slide 11 text

it’s 2015. let’s ship new code… without interrupting production

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

● Predictable ● Repeatable ● Minimal Human Interaction ● Zero User Interruption ● Contained Failure Dream Delivery

Slide 14

Slide 14 text

Blue/Green Deployments http://martinfowler.com/bliki/BlueGreenDeployment.html

Slide 15

Slide 15 text

DNS ELB

Slide 16

Slide 16 text

Pre-flight Checklist ❏ Stateless Servers ❏ Server Health Check ❏ Duplicate Full Stack including RDS Replica

Slide 17

Slide 17 text

Wait. Two Databases? “There's still the issue of dealing with missed transactions while the green environment was live, but depending on your design you may be able to... ● feed transactions to both environments in such a way as to keep the blue environment as a backup when the green is live. Or you may be able to... ● put the application in read-only mode before cut-over, run it for a while in read-only mode, and then switch it to read-write mode.” http://martinfowler.com/bliki/BlueGreenDeployment.html

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

“Code always works on Schema +1 ” (A.K.A. old code works on new schema)

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Publish, Migrate, Deploy

Slide 22

Slide 22 text

Jenkins’ Job 1. Build 2. Test 3. Package 4. Publish 5. Run Migrations 6. Invoke Ansible 7. Cull Zombies

Slide 23

Slide 23 text

Ansible’s Job 1. Check for S3 deliverables 2. Spin up new EC2 Instance(s) 3. Apply role(s) to instance(s) 4. Find instance(s) in ELB 5. Add new instance(s) to ELB & tag ○ status: in-use 6. Remove & tag instances ○ status: zombie

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Bootstrapping Ansible ./exec/ directory contains Jenkins entry points Ansible code lives in the repo it provisions. Publish it like an app.

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

./exec/brochure-deploy.sh

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

brochure-deploy.yml you are here. 00:00:10.888

Slide 31

Slide 31 text

provision-new-ec2-instances brochure-deploy >

Slide 32

Slide 32 text

identify-elb-AZs brochure-deploy > provision-new-ec2-instances >

Slide 33

Slide 33 text

ec2-deploy brochure-deploy > provision-new-ec2-instances >

Slide 34

Slide 34 text

AMI Hierarchy

Slide 35

Slide 35 text

brochure-deploy.yml you are here. 00:01:18.415

Slide 36

Slide 36 text

configure-instances brochure-deploy >

Slide 37

Slide 37 text

roles/deploy/brochure/tasks/main.yml brochure-deploy > configure-instances

Slide 38

Slide 38 text

brochure-deploy.yml you are here. 00:04:49.414

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

brochure-deploy.yml you are here. 00:04:50.188

Slide 42

Slide 42 text

find-instances-in-elb brochure-deploy >

Slide 43

Slide 43 text

brochure-deploy.yml you are here. 00:04:50.911

Slide 44

Slide 44 text

add-instances-to-elb brochure-deploy >

Slide 45

Slide 45 text

brochure-deploy.yml you are here. 00:05:06.295

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

decommission-instances brochure-deploy >

Slide 48

Slide 48 text

brochure-deploy.yml you are here. 00:05:21.226

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

EC2 INSTANCE

Slide 55

Slide 55 text

● Predictable ● Repeatable ● Minimal Human Interaction ● Zero User Interruption ● Contained Failure Dream Delivery Achieved

Slide 56

Slide 56 text

The Future ● Long Running Instances + Docker ○ Huge speed improvement ● Post Monolith, Abandon Jenkins? ○ Travis CI for Build/Test ○ Tower for Deployment Orchestration ● Ansible Galaxy?

Slide 57

Slide 57 text

Questions? [email protected] @nonrational github.com/nonrational

Slide 58

Slide 58 text

[email protected] All code snippets & diagrams contained in this presentation are property of Betterment, but please learn from them. All photographs / GIFs used in this presentation are someone else’s. Street Fighter, Back To The Future, Indiana Jones, Futurama, and Arrested Development are someone else’s property too.