continuous delivery with jenkins, docker and exoscale
TRANSCRIPT
Continuous Delivery with Jenkins, Docker and
ExoscaleJulia Mateo
@juliamateodc@duchessswiss http://jduchess.ch/
Thursday, April 16, 15
Goal
Thursday, April 16, 15
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
Continuous Delivery
Source : http://xebia.github.io/cd-with-docker/#/
Thursday, April 16, 15
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
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
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
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
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Node 1
Node 2
Thursday, April 16, 15
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
The web app to deploy
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Thursday, April 16, 15
Docker publish plugin
Thursday, April 16, 15
Using Docker into Docker
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Thursday, April 16, 15
Docker private repository
• Add the registry’s location to the repository name : my.registry.address:port/repositoryname
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Thursday, April 16, 15
Deploy with Docker : test environment
Localhost
docker publish plugin
ssh jenkins plugin
Thursday, April 16, 15
Jenkins ssh plugin
Thursday, April 16, 15
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
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
Demo
Thursday, April 16, 15
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
Deploying to production
• Canary releasing
• Blue Green deployment
Thursday, April 16, 15
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
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
Thank you !
QUESTIONS
?
Thursday, April 16, 15