Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

11
Blue/Green Deployments Andrew E. Rhyne Lead Engineer @ Jobstart github.com/thebigredgeek

Transcript of Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

Page 1: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

Blue/Green DeploymentsAndrew E. Rhyne

Lead Engineer @ Jobstartgithub.com/thebigredgeek

Page 2: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

– David Farley

“Releasing software is too often an art; it should be an engineering discipline.”

Page 3: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

What is blue/green?• Two identical production environments called blue

and green

• At any time, only one of the two environments is active.

• Deployment occurs against the environment that is not active.

• After a successful deployment, the load balancer is switched to point to the previously not active environment.

• Active switches between blue and green with each rollout

• Zero downtime deployments

Page 4: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

Why blue/green?• Requiring downtime to deploy a service is unnecessarily

painful.

• Blue/green deployment requires zero downtime in almost every case.

• With micro-services, zero-downtime deployments equates to less ops-level complexity.

• Docker Cloud & HAProxy provide abstraction that mitigates most of the complexity.

• Rollback doesn’t require a re-deploy. Simply scale back up the previously active cluster and switch HAProxy back over.

Page 5: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

How to blue/green• Every service should be divided into 2 variant

clusters, blue and green, with HAProxy load balancing the active cluster

• On deployment, CI should deploy to the non-active cluster. I.e., when blue is active CI should deploy to green.

• Non-active cluster should be scaled up to active scale and health-checked. If the non-active cluster is healthy, HAProxy should be unlinked with the active cluster and linked with the non-active cluster, reversing the roles.

• Finally, previously active cluster is scaled down to 1 instance.

Page 6: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

dockercloud/haproxy

org/service (blue - 3 containers)

org/service (green 1 container)

Before deployment

Page 7: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

dockercloud/haproxy

org/service (blue - 3 containers)

org/service (green 3 containers)

During deployment

Page 8: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

dockercloud/haproxy

org/service (blue - 1 container)

org/service (green 3 containers)

After deployment

Page 9: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

Docker Cloud makes it easy

• Docker Cloud’s HAProxy image will “automagically” redirect traffic from old links to new links at run time.

• This means that developers don’t really need anything from DevOps to make this work.

Page 10: Jobstart Lightning Talk - Docker Cloud Meetup SF 05/25

Resolving the active color

• https://github.com/thebigredgeek/dcbg - Command line tool that returns the inactive color code using Docker Cloud’s REST API.