35
Continuous Delivery with Jenkins, Docker and Exoscale Julia Mateo @juliamateodc @duchessswiss http://jduchess.ch/ Thursday, April 16, 15

Continuous delivery with jenkins, docker and exoscale

Embed Size (px)

Citation preview

Page 1: Continuous delivery with jenkins, docker and exoscale

Continuous Delivery with Jenkins, Docker and

ExoscaleJulia Mateo

@juliamateodc@duchessswiss http://jduchess.ch/

Thursday, April 16, 15

Page 2: Continuous delivery with jenkins, docker and exoscale

Goal

Thursday, April 16, 15

Page 3: Continuous delivery with jenkins, docker and exoscale

Continuous deployment vs Continuous Delivery

• Continuous delivery : series of practices designed to ensure that code can be rapidly and safely deployed to production

• Continuous deployment is the next step of continuous delivery: Every change that passes the automated tests is deployed to production automatically

Thursday, April 16, 15

Page 4: Continuous delivery with jenkins, docker and exoscale

Continuous Delivery

Source : http://xebia.github.io/cd-with-docker/#/

Thursday, April 16, 15

Page 5: Continuous delivery with jenkins, docker and exoscale

What is Docker ?

• Open platform for developers and sysadmins to build, ship, and run distributed applications.

From https://www.docker.com/whatisdocker/

Thursday, April 16, 15

Page 6: Continuous delivery with jenkins, docker and exoscale

Docker vs VMs

Server

Host OS

Hypervisor

GuestOS

Guest OS

Guest OS

Guest OS

Libs/Bins

Libs/Bins

Libs/Bins

App 1 App 2 App 3 App 4

Libs/Bins

Server

Host OS

Docker Engine

Libs/Bins Libs/Bins

App 1 App 2 App 3 App 4

c1 c2 c3 c4

VM1 VM2 VM3 VM4

Thursday, April 16, 15

Page 7: Continuous delivery with jenkins, docker and exoscale

Containers and images

DockerImages Docker

Images

libcontainer, Union Filesystem

Centos Ubuntu

Jetty

add App.war

Container 1

OracleDB

Container 2

Read only

WritableWritable

Read only

Thursday, April 16, 15

Page 8: Continuous delivery with jenkins, docker and exoscale

Using Docker for Continuous Delivery

• Simple : container as deployment unit

• Fast : Only need to build/upload the ∆ image

• Robust : less scope of error than custom deployment scripts

• Other advantages : docker facilitates fast rollback

Thursday, April 16, 15

Page 9: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Node 1

Node 2

Thursday, April 16, 15

Page 10: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Node 1

Node 2

Container 1

Container 2

Container 3

Container 4

Container 5

Thursday, April 16, 15

Page 11: Continuous delivery with jenkins, docker and exoscale

The web app to deploy

Thursday, April 16, 15

Page 12: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

Thursday, April 16, 15

Page 13: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

Thursday, April 16, 15

Page 14: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

Thursday, April 16, 15

Page 15: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

Thursday, April 16, 15

Page 16: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

Thursday, April 16, 15

Page 17: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

Thursday, April 16, 15

Page 18: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Thursday, April 16, 15

Page 19: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Thursday, April 16, 15

Page 20: Continuous delivery with jenkins, docker and exoscale

Docker publish plugin

Thursday, April 16, 15

Page 21: Continuous delivery with jenkins, docker and exoscale

Using Docker into Docker

Thursday, April 16, 15

Page 22: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Thursday, April 16, 15

Page 23: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Thursday, April 16, 15

Page 24: Continuous delivery with jenkins, docker and exoscale

Docker private repository

• Add the registry’s location to the repository name : my.registry.address:port/repositoryname

Thursday, April 16, 15

Page 25: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Thursday, April 16, 15

Page 26: Continuous delivery with jenkins, docker and exoscale

Deploy with Docker : test environment

Localhost

docker publish plugin

ssh jenkins plugin

Thursday, April 16, 15

Page 27: Continuous delivery with jenkins, docker and exoscale

Jenkins ssh plugin

Thursday, April 16, 15

Page 28: Continuous delivery with jenkins, docker and exoscale

SSH agent forward into a docker container

>> docker run --privileged=true -i -t -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v /home/hortis/docker/jenkins:/jenkins -p 8900:8080 --link sonarMysql:sonar_mysql --link sonar:sonar --link docker-registry:docker-registry -d hortis/jenkins:latest

Thursday, April 16, 15

Page 29: Continuous delivery with jenkins, docker and exoscale

SSH agent forward into a docker container

>> docker run --privileged=true -i -t -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent -e SSH_AUTH_SOCK=/ssh-agent -v /home/hortis/docker/jenkins:/jenkins -p 8900:8080 --link sonarMysql:sonar_mysql --link sonar:sonar --link docker-registry:docker-registry -d hortis/jenkins:latest

Thursday, April 16, 15

Page 30: Continuous delivery with jenkins, docker and exoscale

Demo

Thursday, April 16, 15

Page 31: Continuous delivery with jenkins, docker and exoscale

Multi container apps• Link containers with alias

docker run -v /home/hortis/docker/sonar/logs:/opt/sonar/logs/ -v /home/hortis/docker/sonar/extensions:/opt/sonar/extensions -p 9000:9000 --link sonarMysql:mysql --name sonar -d hortis/sonar:latest

• Use docker compose (old Fig)

Thursday, April 16, 15

Page 32: Continuous delivery with jenkins, docker and exoscale

Deploying to production

• Canary releasing

• Blue Green deployment

Thursday, April 16, 15

Page 33: Continuous delivery with jenkins, docker and exoscale

Blue Green Deployment

DatabaseWeb app

DatabaseWeb appWeb app Database

Web app Database

Userrequests

Router

Old Version

New Version

Source : http://martinfowler.com/bliki/BlueGreenDeployment.html

Thursday, April 16, 15

Page 34: Continuous delivery with jenkins, docker and exoscale

Canary releasing

DatabaseWeb app

DatabaseWeb appWeb app Database

Web app Database

Userrequests

Router

Old Version

New Version

Most users95%

Some users5%

Source : http://martinfowler.com/bliki/CanaryRelease.html

Thursday, April 16, 15

Page 35: Continuous delivery with jenkins, docker and exoscale

Thank you !

QUESTIONS

?

Thursday, April 16, 15