SlideShare a Scribd company logo
FROM MONOLITH TO DOCKER
DISTRIBUTED APPLICATIONS
Carlos Sanchez
@csanchez csanchez.org
ABOUT ME
Senior So ware Engineer @ CloudBees
Author of Jenkins Kubernetes plugin
Long time OSS contributor at Apache Maven, Eclipse,
Puppet,…
DOCKER DOCKER DOCKER
From Monolith to Docker Distributed Applications
OUR USE CASE
Scaling Jenkins
Your mileage may vary
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
A 2000 JENKINS MASTERS CLUSTER
3 Mesos masters (m3.xlarge: 4 vCPU, 15GB, 2x40 SSD)
317 Mesos slaves (c3.2xlarge, m3.xlarge, m4.4xlarge)
7 Mesos slaves dedicated to ElasticSearch: (c3.8xlarge: 32
vCPU, 60GB)
12.5 TB - 3748 CPU
Running 2000 masters and ~8000 concurrent jobs
ARCHITECTURE
From Monolith to Docker Distributed Applications
Isolated Jenkins masters
Isolated build agents and jobs
Memory and CPU limits
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
CLUSTER SCHEDULING
Distribute tasks across a cluster of hosts
Running in public cloud, private cloud, VMs or bare metal
HA and fault tolerant
With Docker support of course
APACHE MESOS
A distributed systems kernel
ALTERNATIVES
Docker Swarm / Kubernetes
MESOSPHERE MARATHON
TERRAFORM
TERRAFORM
resource "aws_instance" "worker" {
count = 1
instance_type = "m3.large"
ami = "ami-xxxxxx"
key_name = "tiger-csanchez"
security_groups = ["sg-61bc8c18"]
subnet_id = "subnet-xxxxxx"
associate_public_ip_address = true
tags {
Name = "tiger-csanchez-worker-1"
"cloudbees:pse:cluster" = "tiger-csanchez"
"cloudbees:pse:type" = "worker"
}
root_block_device {
volume_size = 50
}
}
TERRAFORM
State is managed
Runs are idempotent
terraform apply
Sometimes it is too automatic
Changing image id will restart all instances
From Monolith to Docker Distributed Applications
IF YOU HAVEN'T AUTOMATICALLY
DESTROYED SOMETHING BY
MISTAKE,
YOU ARE NOT AUTOMATING ENOUGH
STORAGE
Handling distributed storage
Servers can start in any host of the cluster
And they can move when they are restarted
DOCKER VOLUME PLUGINS
Flocker
GlusterFS
NFS
EBS
KUBERNETES
GCE disks
Flocker
GlusterFS
NFS
EBS
PERMISSIONS
Containers should not run as root
Container user id != host user id
i.e. jenkins user in container is always 1000 but matches
ubuntu user in host
MEMORY
Scheduler needs to account for container memory
requirements and host available memory
Prevent containers for using more memory than allowed
Memory constrains translate to Docker --memory
WHAT DO YOU THINK HAPPENS
WHEN?
Your container goes over memory quota?
From Monolith to Docker Distributed Applications
WHAT ABOUT THE JVM?
WHAT ABOUT THE CHILD
PROCESSES?
CPU
Scheduler needs to account for container CPU requirements
and host available CPUs
WHAT DO YOU THINK HAPPENS
WHEN?
Your container tries to access more than one CPU
Your container goes over CPU limits
Totally different from memory
Mesos/Kubernetes CPU translates into Docker --cpu-
shares
NETWORKING
Multiple services running in the same ports
Must redirect from random ports in the host
Services running in one host need to access services in other
hosts
NETWORKING: SOFTWARE DEFINED
NETWORKS
Create new custom networks on top of physical networks
Allow grouping containers in subnets
NETWORKING: SOFTWARE DEFINED
NETWORKS
Battlefield: Calico, Flannel, Weave and Docker Overlay
Network
http://chunqi.li/2015/11/15/Battlefield-Calico-Flannel-
Weave-and-Docker-Overlay-Network/
SCALING
New and interesting problems
AWS
Resource limits: VPCs, S3 snapshots, some instance sizes
Rate limits: affect the whole account
Retrying is your friend, but with exponential backoff
EMBRACE FAILURE!
JENKINS PLUGINS
JENKINS DOCKER PLUGINS
Dynamic Jenkins agents with Docker plugin or Yet Another
Docker Plugin
No support yet for Docker 1.12 Swarm mode
Agent image needs to include Java, downloads slave jar
from Jenkins master
Multiple plugins for different tasks
Docker build and publish
Docker build step plugin
CloudBees Docker Hub/Registry Notification
CloudBees Docker Traceability
Great pipeline support
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
JENKINS DOCKER PIPELINE
def maven = docker.image('maven:3.3.9-jdk-8');
stage 'Mirror'
maven.pull()
docker.withRegistry('https://secure-registry/', 'docker-registry-login'
stage 'Build'
maven.inside {
sh "mvn -B clean package"
}
stage 'Bake Docker image'
def pcImg = docker.build("examplecorp/spring-petclinic:${env.BUILD_TAG}"
pcImg.push();
}
JENKINS MESOS PLUGIN
Dynamic Jenkins agents, both Docker and isolated
processes
Agent image needs to include Java, grabs slave jar from
Mesos sandbox
Can run Docker commands on the host, outside of Mesos
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
JENKINS MESOS PLUGIN
Can use Docker pipelines with some tricks
Need Docker client installed
Shared docker.sock from host
Mount the workspace in the host, visible under same dir
MESOS PLUGIN AND PIPELINE
node('docker') {
docker.image('golang:1.6').inside {
stage 'Get sources'
git url: 'https://github.com/hashicorp/terraform.git', tag: "v0.6.15"
stage 'Build'
sh """#!/bin/bash -e
mkdir -p /go/src/github.com/hashicorp
ln -s `pwd` /go/src/github.com/hashicorp/terraform
pushd /go/src/github.com/hashicorp/terraform
make core-dev plugin-dev PLUGIN=provider-aws
popd
cp /go/bin/terraform-provider-aws .
"""
stage 'Archive'
archive "terraform-provider-aws"
}
}
JENKINS KUBERNETES PLUGIN
Dynamic Jenkins agents, running as Pods
Multiple container support
One jnlp image, others custom
Pipeline support for both agent Pod definition and
execution will be in next version
JENKINS KUBERNETES PIPELINE
podTemplate(label: 'mypod', containers: [
[name: 'jnlp', image: 'jenkinsci/jnlp-slave:alpine', args: '${compute
[name: 'maven', image: 'maven:3-jdk-8', ttyEnabled: true, command:
[name: 'golang', image: 'golang:1.6', ttyEnabled: true, command:
]) {
node ('mypod') {
stage 'Get a Maven project'
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
stage 'Build a Maven project'
sh 'mvn clean install'
}
stage 'Get a Golang project'
git url: 'https://github.com/hashicorp/terraform.git'
container('golang') {
stage 'Build a Go project'
sh """
mkdir -p /go/src/github.com/hashicorp
ln -s `pwd` /go/src/github.com/hashicorp/terraform
cd /go/src/github.com/hashicorp/terraform && make core-dev
"""
}
}
JENKINS PLUGINS RECAP
Dynamic Jenkins agent creation
Using JNLP slave jar
In complex environments need to use the tunnel
option to connect internally
Using the Cloud API
Not ideal for containerized workload
Agents take > 1 min to start provision and are kept
around
Agents can provide more than one executor
СПАСИБО
csanchez.org
csanchez
carlossg

More Related Content

What's hot (20)

PDF
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
PPTX
Docker toolbox
Yonghwee Kim
 
PDF
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Docker, Inc.
 
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
PPTX
Getting started with Docker
Ravindu Fernando
 
PPTX
A Survey of Container Security in 2016: A Security Update on Container Platforms
Salman Baset
 
PDF
Docker Security Deep Dive by Ying Li and David Lawrence
Docker, Inc.
 
PPTX
Comprehensive Monitoring for Docker
Christian Beedgen
 
PDF
Continuous Deployment with Jenkins on Kubernetes
Matt Baldwin
 
PDF
Container Days Boston - Kubernetes in production
Mike Splain
 
PDF
Automated Deployment with Capistrano
Sumit Chhetri
 
PDF
Securing Containers, One Patch at a Time - Michael Crosby, Docker
Docker, Inc.
 
PPT
Amazon Web Services and Docker
Paolo latella
 
PDF
Docker security introduction-task-2016
Ricardo Gerardi
 
PPTX
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
PPTX
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Docker, Inc.
 
PDF
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
PDF
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Carlos Sanchez
 
PDF
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
Julia Mateo
 
PDF
Introduction to Docker and deployment and Azure
Jérôme Petazzoni
 
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
Docker toolbox
Yonghwee Kim
 
The Golden Ticket: Docker and High Security Microservices by Aaron Grattafiori
Docker, Inc.
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
Getting started with Docker
Ravindu Fernando
 
A Survey of Container Security in 2016: A Security Update on Container Platforms
Salman Baset
 
Docker Security Deep Dive by Ying Li and David Lawrence
Docker, Inc.
 
Comprehensive Monitoring for Docker
Christian Beedgen
 
Continuous Deployment with Jenkins on Kubernetes
Matt Baldwin
 
Container Days Boston - Kubernetes in production
Mike Splain
 
Automated Deployment with Capistrano
Sumit Chhetri
 
Securing Containers, One Patch at a Time - Michael Crosby, Docker
Docker, Inc.
 
Amazon Web Services and Docker
Paolo latella
 
Docker security introduction-task-2016
Ricardo Gerardi
 
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
Orchestration? You Don't Need Orchestration. What You Want Is Choreography by...
Docker, Inc.
 
Deploying Docker (Provisioning /w Docker + Chef/Puppet) - DevopsDaysPGH
Erica Windisch
 
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Carlos Sanchez
 
Continuous delivery with Jenkins, Docker and Mesos/Marathon - jbcnconf
Julia Mateo
 
Introduction to Docker and deployment and Azure
Jérôme Petazzoni
 

Viewers also liked (18)

PPTX
designing distributed scalable and reliable systems
Mauro Servienti
 
PDF
Dockerized maven
Matthias Bertschy
 
PPT
Jenkins on Docker
Craig Trim
 
PDF
What is this "docker"
Jean-Marc Meessen
 
PPTX
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
NLJUG
 
PPTX
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
tdc-globalcode
 
PDF
Continuous Deployment with Kubernetes, Docker and GitLab CI
alexanderkiel
 
PDF
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Carlos Sanchez
 
PDF
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
PDF
Continuous Integration using Docker & Jenkins
B1 Systems GmbH
 
PPT
Design principles of scalable, distributed systems
Tinniam V Ganesh (TV)
 
PDF
Jenkins Docker
Alex Soto
 
PPTX
Micro Service Architecture
Eduards Sizovs
 
PDF
Using Docker for Testing
Carlos Sanchez
 
PDF
Docker for Java Developers
Imesh Gunaratne
 
PDF
Dockercon State of the Art in Microservices
Adrian Cockcroft
 
PDF
Principles of microservices velocity
Sam Newman
 
PPTX
Faster Java EE Builds with Gradle
Ryan Cuprak
 
designing distributed scalable and reliable systems
Mauro Servienti
 
Dockerized maven
Matthias Bertschy
 
Jenkins on Docker
Craig Trim
 
What is this "docker"
Jean-Marc Meessen
 
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
NLJUG
 
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
tdc-globalcode
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
alexanderkiel
 
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Carlos Sanchez
 
Developing Java based microservices ready for the world of containers
Claus Ibsen
 
Continuous Integration using Docker & Jenkins
B1 Systems GmbH
 
Design principles of scalable, distributed systems
Tinniam V Ganesh (TV)
 
Jenkins Docker
Alex Soto
 
Micro Service Architecture
Eduards Sizovs
 
Using Docker for Testing
Carlos Sanchez
 
Docker for Java Developers
Imesh Gunaratne
 
Dockercon State of the Art in Microservices
Adrian Cockcroft
 
Principles of microservices velocity
Sam Newman
 
Faster Java EE Builds with Gradle
Ryan Cuprak
 
Ad

Similar to From Monolith to Docker Distributed Applications (20)

PPTX
Docker Ecosystem on Azure
Patrick Chanezon
 
PPTX
Docker training
Kiran Kumar
 
PDF
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
PPTX
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
PPTX
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
PDF
Orchestrating Docker with OpenStack
Erica Windisch
 
PPTX
Docker and kubernetes
Dongwon Kim
 
POTX
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Swaminathan Vetri
 
PPTX
Docker DANS workshop
vty
 
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Carlos Sanchez
 
PDF
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
PPTX
Docker and Microservice
Samuel Chow
 
PDF
Docker in practice
Geert Pante
 
PPT
Docker and CloudStack
Sebastien Goasguen
 
PPTX
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
Patrick Chanezon
 
PPTX
Getting Started With Docker: Simplifying DevOps
demoNguyen
 
PDF
Introduction to Docker
Bardia Heydari
 
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
PDF
codemotion-docker-2014
Carlo Bonamico
 
PDF
Docker From Scratch
Giacomo Vacca
 
Docker Ecosystem on Azure
Patrick Chanezon
 
Docker training
Kiran Kumar
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
Docker Seattle Meetup April 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
Docker New York Meetup May 2015 - The Docker Orchestration Ecosystem on Azure
Patrick Chanezon
 
Orchestrating Docker with OpenStack
Erica Windisch
 
Docker and kubernetes
Dongwon Kim
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Swaminathan Vetri
 
Docker DANS workshop
vty
 
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Carlos Sanchez
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Docker and Microservice
Samuel Chow
 
Docker in practice
Geert Pante
 
Docker and CloudStack
Sebastien Goasguen
 
Docker San Francisco Meetup April 2015 - The Docker Orchestration Ecosystem o...
Patrick Chanezon
 
Getting Started With Docker: Simplifying DevOps
demoNguyen
 
Introduction to Docker
Bardia Heydari
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
codemotion-docker-2014
Carlo Bonamico
 
Docker From Scratch
Giacomo Vacca
 
Ad

More from Carlos Sanchez (16)

PDF
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
PDF
Using Containers for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
PDF
Scaling Docker with Kubernetes
Carlos Sanchez
 
PPTX
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
PDF
Scaling Docker with Kubernetes
Carlos Sanchez
 
PDF
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
PDF
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
KEY
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
PDF
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
KEY
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
KEY
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
KEY
From Dev to DevOps - Apache Barcamp Spain 2011
Carlos Sanchez
 
KEY
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
KEY
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
KEY
Eclipse IAM, Maven Integration For Eclipse
Carlos Sanchez
 
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
Using Containers for Continuous Integration and Continuous Delivery
Carlos Sanchez
 
Scaling Docker with Kubernetes
Carlos Sanchez
 
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
Scaling Docker with Kubernetes
Carlos Sanchez
 
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
From Dev to DevOps - Apache Barcamp Spain 2011
Carlos Sanchez
 
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Eclipse IAM, Maven Integration For Eclipse
Carlos Sanchez
 

Recently uploaded (20)

PPTX
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
PPTX
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PDF
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PDF
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PDF
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PDF
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
PPTX
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 
Customise Your Correlation Table in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
MiniTool Partition Wizard Free Crack + Full Free Download 2025
bashirkhan333g
 
Finding Your License Details in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Build It, Buy It, or Already Got It? Make Smarter Martech Decisions
bbedford2
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
IDM Crack with Internet Download Manager 6.42 Build 43 with Patch Latest 2025
bashirkhan333g
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Generic or Specific? Making sensible software design decisions
Bert Jan Schrijver
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
[Solution] Why Choose the VeryPDF DRM Protector Custom-Built Solution for You...
Lingwen1998
 
AEM User Group: India Chapter Kickoff Meeting
jennaf3
 

From Monolith to Docker Distributed Applications

  • 1. FROM MONOLITH TO DOCKER DISTRIBUTED APPLICATIONS Carlos Sanchez @csanchez csanchez.org
  • 2. ABOUT ME Senior So ware Engineer @ CloudBees Author of Jenkins Kubernetes plugin Long time OSS contributor at Apache Maven, Eclipse, Puppet,…
  • 5. OUR USE CASE Scaling Jenkins Your mileage may vary
  • 10. A 2000 JENKINS MASTERS CLUSTER 3 Mesos masters (m3.xlarge: 4 vCPU, 15GB, 2x40 SSD) 317 Mesos slaves (c3.2xlarge, m3.xlarge, m4.4xlarge) 7 Mesos slaves dedicated to ElasticSearch: (c3.8xlarge: 32 vCPU, 60GB) 12.5 TB - 3748 CPU Running 2000 masters and ~8000 concurrent jobs
  • 13. Isolated Jenkins masters Isolated build agents and jobs Memory and CPU limits
  • 16. CLUSTER SCHEDULING Distribute tasks across a cluster of hosts Running in public cloud, private cloud, VMs or bare metal HA and fault tolerant With Docker support of course
  • 17. APACHE MESOS A distributed systems kernel
  • 21. TERRAFORM resource "aws_instance" "worker" { count = 1 instance_type = "m3.large" ami = "ami-xxxxxx" key_name = "tiger-csanchez" security_groups = ["sg-61bc8c18"] subnet_id = "subnet-xxxxxx" associate_public_ip_address = true tags { Name = "tiger-csanchez-worker-1" "cloudbees:pse:cluster" = "tiger-csanchez" "cloudbees:pse:type" = "worker" } root_block_device { volume_size = 50 } }
  • 22. TERRAFORM State is managed Runs are idempotent terraform apply Sometimes it is too automatic Changing image id will restart all instances
  • 24. IF YOU HAVEN'T AUTOMATICALLY DESTROYED SOMETHING BY MISTAKE, YOU ARE NOT AUTOMATING ENOUGH
  • 25. STORAGE Handling distributed storage Servers can start in any host of the cluster And they can move when they are restarted
  • 28. PERMISSIONS Containers should not run as root Container user id != host user id i.e. jenkins user in container is always 1000 but matches ubuntu user in host
  • 29. MEMORY Scheduler needs to account for container memory requirements and host available memory Prevent containers for using more memory than allowed Memory constrains translate to Docker --memory
  • 30. WHAT DO YOU THINK HAPPENS WHEN? Your container goes over memory quota?
  • 32. WHAT ABOUT THE JVM? WHAT ABOUT THE CHILD PROCESSES?
  • 33. CPU Scheduler needs to account for container CPU requirements and host available CPUs
  • 34. WHAT DO YOU THINK HAPPENS WHEN? Your container tries to access more than one CPU Your container goes over CPU limits
  • 35. Totally different from memory Mesos/Kubernetes CPU translates into Docker --cpu- shares
  • 36. NETWORKING Multiple services running in the same ports Must redirect from random ports in the host Services running in one host need to access services in other hosts
  • 37. NETWORKING: SOFTWARE DEFINED NETWORKS Create new custom networks on top of physical networks Allow grouping containers in subnets
  • 38. NETWORKING: SOFTWARE DEFINED NETWORKS Battlefield: Calico, Flannel, Weave and Docker Overlay Network http://chunqi.li/2015/11/15/Battlefield-Calico-Flannel- Weave-and-Docker-Overlay-Network/
  • 40. AWS Resource limits: VPCs, S3 snapshots, some instance sizes Rate limits: affect the whole account Retrying is your friend, but with exponential backoff
  • 43. JENKINS DOCKER PLUGINS Dynamic Jenkins agents with Docker plugin or Yet Another Docker Plugin No support yet for Docker 1.12 Swarm mode Agent image needs to include Java, downloads slave jar from Jenkins master Multiple plugins for different tasks Docker build and publish Docker build step plugin CloudBees Docker Hub/Registry Notification CloudBees Docker Traceability Great pipeline support
  • 48. JENKINS DOCKER PIPELINE def maven = docker.image('maven:3.3.9-jdk-8'); stage 'Mirror' maven.pull() docker.withRegistry('https://secure-registry/', 'docker-registry-login' stage 'Build' maven.inside { sh "mvn -B clean package" } stage 'Bake Docker image' def pcImg = docker.build("examplecorp/spring-petclinic:${env.BUILD_TAG}" pcImg.push(); }
  • 49. JENKINS MESOS PLUGIN Dynamic Jenkins agents, both Docker and isolated processes Agent image needs to include Java, grabs slave jar from Mesos sandbox Can run Docker commands on the host, outside of Mesos
  • 55. JENKINS MESOS PLUGIN Can use Docker pipelines with some tricks Need Docker client installed Shared docker.sock from host Mount the workspace in the host, visible under same dir
  • 56. MESOS PLUGIN AND PIPELINE node('docker') { docker.image('golang:1.6').inside { stage 'Get sources' git url: 'https://github.com/hashicorp/terraform.git', tag: "v0.6.15" stage 'Build' sh """#!/bin/bash -e mkdir -p /go/src/github.com/hashicorp ln -s `pwd` /go/src/github.com/hashicorp/terraform pushd /go/src/github.com/hashicorp/terraform make core-dev plugin-dev PLUGIN=provider-aws popd cp /go/bin/terraform-provider-aws . """ stage 'Archive' archive "terraform-provider-aws" } }
  • 57. JENKINS KUBERNETES PLUGIN Dynamic Jenkins agents, running as Pods Multiple container support One jnlp image, others custom Pipeline support for both agent Pod definition and execution will be in next version
  • 58. JENKINS KUBERNETES PIPELINE podTemplate(label: 'mypod', containers: [ [name: 'jnlp', image: 'jenkinsci/jnlp-slave:alpine', args: '${compute [name: 'maven', image: 'maven:3-jdk-8', ttyEnabled: true, command: [name: 'golang', image: 'golang:1.6', ttyEnabled: true, command: ]) { node ('mypod') { stage 'Get a Maven project' git 'https://github.com/jenkinsci/kubernetes-plugin.git' container('maven') { stage 'Build a Maven project' sh 'mvn clean install' } stage 'Get a Golang project' git url: 'https://github.com/hashicorp/terraform.git' container('golang') { stage 'Build a Go project' sh """ mkdir -p /go/src/github.com/hashicorp ln -s `pwd` /go/src/github.com/hashicorp/terraform cd /go/src/github.com/hashicorp/terraform && make core-dev """ } }
  • 59. JENKINS PLUGINS RECAP Dynamic Jenkins agent creation Using JNLP slave jar In complex environments need to use the tunnel option to connect internally Using the Cloud API Not ideal for containerized workload Agents take > 1 min to start provision and are kept around Agents can provide more than one executor