Build Your Own

Continuous deployment

Infrastructure 

RootedCON, 2018-03-03

Your Host this Evening




@pinchito

Organizer at MadridJS

Backend developer at LogTrust

What We Will Cover


Testing


Integration


Deployment


Distributed Deployment


Monitoring

Tests


Who automatizes the automatizer?

Anonymous

types of Tests


Unit tests


Integration tests / system tests


Load tests



Automatic tests — are the bests!

Better than the rests!

Automate!


Design a control API

Start and stop the system using the API


Self-contained tests: clean-up


Three basic rules:

  • One single button
  • Fail fast and loudly
  • No human intervention


Make your life easier



Make your systems easy to test

Practical Session 1


Create project


Create test script


Run tests


Break tests


Fix tests

Success!

Integration


Everything is coming together nicely

Dr Frankenstein

Integration Environment


Between Development and Production


Also called: preproduction, replica, build env


Enough data to run all tests

Populated with a script

Self-contained

Continuous Integration


Store unit and integration tests


Run the whole suite with every change


Check if something has broken


For any new error, introduce a new test


Why Integrate All the Time?


Close the gap between development and tests


Safety net for developers


Notice errors when the code is fresh


Shorten development cycles!

Tooling


Jenkins

Travis-CI

Strider CD


(CD > CI)


Various proprietary dumpster fires

Practical Session 2


Create integration server


Create integration script


Run integration script


Add Webhook to GitHub


Add tests to deployment

Success!


Deployment


Amateurs talk about programming

Professionals care about deployment

Anonymous

Deploying Code


Put your code into production


Different servers, different rules


With node:

git pull
npm install
sudo service [name] restart

Automate!


Do the manual way...

Or do the cool way: with code


DevOps for the win!


Three basic rules:

  • One single button
  • Fail fast and loudly
  • No human intervention

Make your life easier



Make your systems easy to deploy

Continuous Deployment


Too much of a good thing?


Shorten deployment cycles


Don't let changes accumulate


Stability increases (paradoxically?)


Practice makes perfect!

Improving Your Life


Continuous Integration


Continuous Delivery


Continuous Deployment


Reject imitations!

Test Before Deploying


Run all test suites

Verify results

Certify quality


A small but essential addition:

git pull
npm install
npm test
sudo service [name] restart

Practical Session 3


Create a production server


Create script to deploy on production


Add deployment to production

(only if tests work)


Test that it works

Success!



Distributed

Deployment

From one Server to Many


Horizontal architecture


One deployment, many servers


Production: listen to signal


Integration: send signals

Overview


Dynamic List of Servers


Get from your cloud provider?


Use AWS/gcloud/Azure API


Integration finds all servers


Notify all production servers

Practical Session 4


Access AWS to get list of servers


Connect to all of them and update


Modify integration server


Run distributed deployment

Success!

Bonus Track


MONITORING

Proactive Monitoring


Let alarms, alerts and warnings come to you


Every alarm must have:

  • A cause
  • An alert system
  • An action associated

Make your life easier



Make your systems easy to monitor

Practical Session 5


Send a notification if deployment fails



Where To Go from here


Automatic rollback


Staged deployments


Canary deployments


Feature flags


Testing in Production

Thanks! We're Hiring!

@pinchito

Build Your Own Continuous Deployment Infrastructure

By Alex Fernández

Build Your Own Continuous Deployment Infrastructure

RootedCON, 2018-03-03

  • 2,392