Continuous deployment

Tek-Tank

Your Host this Evening




@pinchito

Organizer at MadridJS

Backend developer at Devo

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

Hints


npm init 
Creates package.json

npm test 
Runs the tests

Empty tests are fine!

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

Hints


Create a second project

Create http server

After a request, run script

childProcess.exec('command') 
runs a command

Show result with socket.end(message)

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 tests to deployment


Add deployment to production (only if tests work)


Test that it works

Hints


Run all tasks after a request

Connect to a second server using SSH

Deploy on second server

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

Hints


Use api.js to simplify the task

api.getInstances(prefix, callback) 
gets the list of servers 

api.deploy(instances, path, callback) 
deploys on the given servers

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!

@pinchito

Continuous Deployment Workshop Tek-Tank

By Alex Fernández

Continuous Deployment Workshop Tek-Tank

Continuous Deployment workshop for Tek-Tank, 2018-06-14

  • 1,953