SlideShare ist ein Scribd-Unternehmen logo
1 von 60
Downloaden Sie, um offline zu lesen
USING CONTAINERS FOR BUILDING AND
TESTING
DOCKER, KUBERNETES AND MESOS
Carlos Sanchez
/csanchez.org @csanchez
Watch online at carlossg.github.io/presentations
ABOUT ME
Engineer @ CloudBees, Private SaaS Edition Team
Contributor to Jenkins Mesos plugin & Jenkins and Maven
official Docker images
Author of Jenkins Kubernetes plugin
Long time OSS contributor at Apache, Eclipse, Puppet,…
Google Cloud Platform Expert
DOCKER DOCKER
DOCKER
BUT IT IS NOT TRIVIAL
CLUSTER SCHEDULING
Running in public cloud, private cloud, VMs or bare metal
HA and fault tolerant
With Docker support of course
A distributed systems kernel
APACHE MESOS
Started before 2011
Runs tasks, any binary or Docker, rkt, appc images
Frameworks run on top of Mesos
Mesosphere Marathon: long running services
Apache Aurora: long running services
Chronos: distributed cron-like system
Used in Twitter, Airbnb, eBay, Apple, Verizon, Yelp,...
DOCKER SWARM
DOCKER SWARM
By Docker Inc.
Uses the same Docker API
No need to modify existing tooling
DOCKER ENGINE SWARM MODE
New in Docker 1.12
No need to install extra so ware, each daemon can run as
a Swarm member
New service object to describe distributed containers
Existing tooling needs to be updated
Swarm mode
KUBERNETES
Based on Google Borg
Run in local machine, virtual, cloud
Google provides Google Container Engine (GKE)
Other services run by stackpoint.io, CoreOS Tectonic,
Azure,...
Minikube for local testing
SCALING JENKINS
Two options:
More build agents per master
More masters
SCALING JENKINS: MORE BUILD
AGENTS
Pros
Multiple plugins to add more agents, even dynamically
Cons
The master is still a SPOF
Handling multiple configurations, plugin versions,...
There is a limit on how many build agents can be
attached
SCALING JENKINS: MORE MASTERS
Pros
Different sub-organizations can self service and operate
independently
Cons
Single Sign-On
Centralized configuration and operation
Covered by CloudBees Jenkins Operations Center and
CloudBees Jenkins Platform Private SaaS Edition
If you haven't automatically destroyed
something by mistake, you are not
automating enough
RUNNING IN DOCKER
CLUSTER SCHEDULING
Isolated build agents and jobs
Using Docker
Capabilities can be dropped
GROUPING CONTAINERS
Example:
Jenkins agent
Maven build
Selenium testing in
Firefox
Chrome
Safari
5 containers
GROUPING CONTAINERS
Mesos Experimental in 1.1.0
Swarm Supports grouping through Docker
Compose
Can force execution in the same host
Kubernetes Supports the concept of Pods natively
All running in the same host
MESOS-2449
MEMORY LIMITS
Scheduler needs to account for container memory
requirements and host available memory
Prevent containers for using more memory than allowed
Mesos required
Swarm optional
Kubernetes optional (plus namespaces)
Memory constrains translate to Docker --memory
WHAT DO YOU THINK HAPPENS WHEN?
Your container goes over memory quota?
WHAT ABOUT THE JVM?
WHAT ABOUT THE CHILD PROCESSES?
CPU LIMITS
Scheduler needs to account for container CPU requirements
and host available CPUs
Mesos required
Swarm optional
Kubernetes optional (plus namespaces)
CPU translates into Docker --cpu-shares
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
STORAGE
Handling distributed storage
Jenkins masters need persistent storage, agents (typically)
don't
Mesos in 1.0+
Swarm Docker volume plugins: RexRay, Convoy,
Flocker,...
Kubernetes
Docker volume support
Persistent volumes
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
CAVEATS
Only a limited number of EBS volumes can be mounted
Docs say /dev/sd[f-p], but /dev/sd[q-z] seem to
work too
NFS users must be centralized and match in cluster and NFS
server
NETWORKING
Jenkins masters open several ports
HTTP
JNLP Build agent
SSH server (Jenkins CLI type operations)
Jenkins agents connect to master:
inbound (SSH)
outbound (JNLP)
Allows getting one IP per container
Mesos : Calico, Weave
Swarm , and others from plugins
Kubernetes Multiple : GCE, Weave,
Calico,...
Network Isolator Modules
Docker overlay
networking options
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
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 DOCKER SLAVES PLUGIN
Use any Docker image, no need for Java
Definition in pipeline
Can have side containers
Building Maven
dockerNode("maven:3.3.3-jdk-8") {
sh "mvn -version"
}
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
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
Persistent workspace in the next version
JENKINS KUBERNETES PIPELINE
podTemplate(label: 'mypod', containers: [
[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
JENKINS ONE SHOT EXECUTOR
Improved API to handle one off agents
Optimized for containerized agents
Plugins need to support it
THANKS
csanchez.org
csanchez
carlossg

Weitere ähnliche Inhalte

Was ist angesagt?

Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
Docker, Inc.
 
Automating Dev Environment - Introduction to Docker and Chef
Automating Dev Environment - Introduction to Docker and ChefAutomating Dev Environment - Introduction to Docker and Chef
Automating Dev Environment - Introduction to Docker and Chef
kamalikamj
 

Was ist angesagt? (20)

From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed ApplicationsFrom Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
 
Scaling Jenkins with Docker and Kubernetes
Scaling Jenkins with Docker and KubernetesScaling Jenkins with Docker and Kubernetes
Scaling Jenkins with Docker and Kubernetes
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google CloudDocker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google Cloud
 
Scaling Jenkins with Docker and Kubernetes
Scaling Jenkins with Docker and KubernetesScaling Jenkins with Docker and Kubernetes
Scaling Jenkins with Docker and Kubernetes
 
Package your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and KubernetesPackage your Java EE Application using Docker and Kubernetes
Package your Java EE Application using Docker and Kubernetes
 
Docker toolbox
Docker toolboxDocker toolbox
Docker toolbox
 
Continuous Deployment with Jenkins on Kubernetes
Continuous Deployment with Jenkins on KubernetesContinuous Deployment with Jenkins on Kubernetes
Continuous Deployment with Jenkins on Kubernetes
 
Docker Ecosystem on Azure
Docker Ecosystem on AzureDocker Ecosystem on Azure
Docker Ecosystem on Azure
 
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
Using Containers for Continuous Integration and Continuous Delivery. KubeCon ...
 
Integration with Docker and .NET Core
Integration with Docker and .NET CoreIntegration with Docker and .NET Core
Integration with Docker and .NET Core
 
Docker 101 Checonf 2016
Docker 101 Checonf 2016Docker 101 Checonf 2016
Docker 101 Checonf 2016
 
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2daysUsing Kubernetes for Continuous Integration and Continuous Delivery. Java2days
Using Kubernetes for Continuous Integration and Continuous Delivery. Java2days
 
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on AzureDevoxx France 2015 - The Docker Orchestration Ecosystem on Azure
Devoxx France 2015 - The Docker Orchestration Ecosystem on Azure
 
Containerization and Docker
Containerization and DockerContainerization and Docker
Containerization and Docker
 
DCSF19 Containers for Beginners
DCSF19 Containers for BeginnersDCSF19 Containers for Beginners
DCSF19 Containers for Beginners
 
What’s New in Docker - Victor Vieux, Docker
What’s New in Docker - Victor Vieux, DockerWhat’s New in Docker - Victor Vieux, Docker
What’s New in Docker - Victor Vieux, Docker
 
Using Containers for Continuous Integration and Continuous Delivery
Using Containers for Continuous Integration and Continuous DeliveryUsing Containers for Continuous Integration and Continuous Delivery
Using Containers for Continuous Integration and Continuous Delivery
 
Automating Dev Environment - Introduction to Docker and Chef
Automating Dev Environment - Introduction to Docker and ChefAutomating Dev Environment - Introduction to Docker and Chef
Automating Dev Environment - Introduction to Docker and Chef
 
How to Improve Your Image Builds Using Advance Docker Build
How to Improve Your Image Builds Using Advance Docker BuildHow to Improve Your Image Builds Using Advance Docker Build
How to Improve Your Image Builds Using Advance Docker Build
 

Andere mochten auch

禪心慧語3
禪心慧語3禪心慧語3
禪心慧語3
foonkok
 

Andere mochten auch (20)

Containers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. KubernetesContainers orchestrators: Docker vs. Kubernetes
Containers orchestrators: Docker vs. Kubernetes
 
Container Orchestration Wars
Container Orchestration WarsContainer Orchestration Wars
Container Orchestration Wars
 
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
Build, Publish, Deploy and Test Docker images and containers with Jenkins Wor...
 
Musings on Mesos: Docker, Kubernetes, and Beyond.
Musings on Mesos: Docker, Kubernetes, and Beyond.Musings on Mesos: Docker, Kubernetes, and Beyond.
Musings on Mesos: Docker, Kubernetes, and Beyond.
 
Dockerized maven
Dockerized mavenDockerized maven
Dockerized maven
 
Jenkins on Docker
Jenkins on DockerJenkins on Docker
Jenkins on Docker
 
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm ModeContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
ContainerDayVietnam2016: Lesson Leanred on Docker 1.12 and Swarm Mode
 
Continuous delivery with docker
Continuous delivery with dockerContinuous delivery with docker
Continuous delivery with docker
 
What is this "docker"
What is this  "docker" What is this  "docker"
What is this "docker"
 
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
Using Docker to Develop, Test and Run Maven Projects - Wouter DanesUsing Docker to Develop, Test and Run Maven Projects - Wouter Danes
Using Docker to Develop, Test and Run Maven Projects - Wouter Danes
 
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
TDC2016SP - Testes unitários e testes de integração de aplicações Java utiliz...
 
ContainerDayVietnam2016: Containers with OpenStack
ContainerDayVietnam2016: Containers with OpenStackContainerDayVietnam2016: Containers with OpenStack
ContainerDayVietnam2016: Containers with OpenStack
 
Workshop mesos docker devoxx fr 2016
Workshop mesos docker devoxx fr 2016Workshop mesos docker devoxx fr 2016
Workshop mesos docker devoxx fr 2016
 
ContainerDayVietnam2016: Docker at scale with Mesos
ContainerDayVietnam2016: Docker at scale with MesosContainerDayVietnam2016: Docker at scale with Mesos
ContainerDayVietnam2016: Docker at scale with Mesos
 
Platform as a Service with Kubernetes and Mesos
Platform as a Service with Kubernetes and Mesos Platform as a Service with Kubernetes and Mesos
Platform as a Service with Kubernetes and Mesos
 
Building and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and MarathonBuilding and deploying a distributed application with Docker, Mesos and Marathon
Building and deploying a distributed application with Docker, Mesos and Marathon
 
禪心慧語3
禪心慧語3禪心慧語3
禪心慧語3
 
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
ContainerDays NYC 2015: "Container Orchestration Compared: Kubernetes and Doc...
 
Docker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developersDocker, Kubernetes, and Mesos recipes for Java developers
Docker, Kubernetes, and Mesos recipes for Java developers
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 

Ähnlich wie Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSDEM 2017

Ähnlich wie Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSDEM 2017 (20)

Using containers for continuous integration and continuous delivery - Carlos ...
Using containers for continuous integration and continuous delivery - Carlos ...Using containers for continuous integration and continuous delivery - Carlos ...
Using containers for continuous integration and continuous delivery - Carlos ...
 
Docker in practice
Docker in practiceDocker in practice
Docker in practice
 
Using Docker for Testing
Using Docker for TestingUsing Docker for Testing
Using Docker for Testing
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...Why everyone is excited about Docker (and you should too...) -  Carlo Bonamic...
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
 
codemotion-docker-2014
codemotion-docker-2014codemotion-docker-2014
codemotion-docker-2014
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: IntroductionAgile Brown Bag - Vagrant & Docker: Introduction
Agile Brown Bag - Vagrant & Docker: Introduction
 
Docker dDessi november 2015
Docker dDessi november 2015Docker dDessi november 2015
Docker dDessi november 2015
 
Docker intro
Docker introDocker intro
Docker intro
 
Docker
DockerDocker
Docker
 
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local BengaluruDeploying .net core apps to Docker - dotnetConf Local Bengaluru
Deploying .net core apps to Docker - dotnetConf Local Bengaluru
 
Docker 1.9 Workshop
Docker 1.9 WorkshopDocker 1.9 Workshop
Docker 1.9 Workshop
 
Introduction to Docker
Introduction to DockerIntroduction to Docker
Introduction to Docker
 
Hands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbiesHands on introduction to docker security for docker newbies
Hands on introduction to docker security for docker newbies
 
Using Kubernetes for Continuous Integration and Continuous Delivery
Using Kubernetes for Continuous Integration and Continuous DeliveryUsing Kubernetes for Continuous Integration and Continuous Delivery
Using Kubernetes for Continuous Integration and Continuous Delivery
 
Docker - fundamental
Docker  - fundamentalDocker  - fundamental
Docker - fundamental
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with Docker
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with Docker
 
Docker In Brief
Docker In BriefDocker In Brief
Docker In Brief
 
Docker
DockerDocker
Docker
 
Docker navjot kaur
Docker navjot kaurDocker navjot kaur
Docker navjot kaur
 

Mehr von Carlos Sanchez

Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
Carlos Sanchez
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
Carlos Sanchez
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011
Carlos Sanchez
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 

Mehr von Carlos Sanchez (15)

Divide and Conquer: Easier Continuous Delivery using Micro-Services
Divide and Conquer: Easier Continuous Delivery using Micro-ServicesDivide and Conquer: Easier Continuous Delivery using Micro-Services
Divide and Conquer: Easier Continuous Delivery using Micro-Services
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero ClicksHow to Develop Puppet Modules: From Source to the Forge With Zero Clicks
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012Puppet for Java developers - JavaZone NO 2012
Puppet for Java developers - JavaZone NO 2012
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
 
From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011From Dev to DevOps - Apache Barcamp Spain 2011
From Dev to DevOps - Apache Barcamp Spain 2011
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
 
Eclipse IAM, Maven Integration For Eclipse
Eclipse IAM, Maven Integration For EclipseEclipse IAM, Maven Integration For Eclipse
Eclipse IAM, Maven Integration For Eclipse
 

Kürzlich hochgeladen

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Kürzlich hochgeladen (20)

Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 

Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSDEM 2017

  • 1. USING CONTAINERS FOR BUILDING AND TESTING DOCKER, KUBERNETES AND MESOS Carlos Sanchez /csanchez.org @csanchez Watch online at carlossg.github.io/presentations
  • 2. ABOUT ME Engineer @ CloudBees, Private SaaS Edition Team Contributor to Jenkins Mesos plugin & Jenkins and Maven official Docker images Author of Jenkins Kubernetes plugin Long time OSS contributor at Apache, Eclipse, Puppet,… Google Cloud Platform Expert
  • 4.
  • 5. BUT IT IS NOT TRIVIAL
  • 6. CLUSTER SCHEDULING Running in public cloud, private cloud, VMs or bare metal HA and fault tolerant With Docker support of course
  • 7.
  • 9. APACHE MESOS Started before 2011 Runs tasks, any binary or Docker, rkt, appc images Frameworks run on top of Mesos Mesosphere Marathon: long running services Apache Aurora: long running services Chronos: distributed cron-like system Used in Twitter, Airbnb, eBay, Apple, Verizon, Yelp,...
  • 11. DOCKER SWARM By Docker Inc. Uses the same Docker API No need to modify existing tooling
  • 12. DOCKER ENGINE SWARM MODE New in Docker 1.12 No need to install extra so ware, each daemon can run as a Swarm member New service object to describe distributed containers Existing tooling needs to be updated Swarm mode
  • 13.
  • 14. KUBERNETES Based on Google Borg Run in local machine, virtual, cloud Google provides Google Container Engine (GKE) Other services run by stackpoint.io, CoreOS Tectonic, Azure,... Minikube for local testing
  • 15. SCALING JENKINS Two options: More build agents per master More masters
  • 16. SCALING JENKINS: MORE BUILD AGENTS Pros Multiple plugins to add more agents, even dynamically Cons The master is still a SPOF Handling multiple configurations, plugin versions,... There is a limit on how many build agents can be attached
  • 17. SCALING JENKINS: MORE MASTERS Pros Different sub-organizations can self service and operate independently Cons Single Sign-On Centralized configuration and operation Covered by CloudBees Jenkins Operations Center and CloudBees Jenkins Platform Private SaaS Edition
  • 18.
  • 19. If you haven't automatically destroyed something by mistake, you are not automating enough
  • 21.
  • 22.
  • 23. CLUSTER SCHEDULING Isolated build agents and jobs Using Docker Capabilities can be dropped
  • 24. GROUPING CONTAINERS Example: Jenkins agent Maven build Selenium testing in Firefox Chrome Safari 5 containers
  • 25. GROUPING CONTAINERS Mesos Experimental in 1.1.0 Swarm Supports grouping through Docker Compose Can force execution in the same host Kubernetes Supports the concept of Pods natively All running in the same host MESOS-2449
  • 26. MEMORY LIMITS Scheduler needs to account for container memory requirements and host available memory Prevent containers for using more memory than allowed Mesos required Swarm optional Kubernetes optional (plus namespaces) Memory constrains translate to Docker --memory
  • 27. WHAT DO YOU THINK HAPPENS WHEN? Your container goes over memory quota?
  • 28.
  • 29. WHAT ABOUT THE JVM? WHAT ABOUT THE CHILD PROCESSES?
  • 30. CPU LIMITS Scheduler needs to account for container CPU requirements and host available CPUs Mesos required Swarm optional Kubernetes optional (plus namespaces) CPU translates into Docker --cpu-shares
  • 31. WHAT DO YOU THINK HAPPENS WHEN? Your container tries to access more than one CPU Your container goes over CPU limits
  • 33. STORAGE Handling distributed storage Jenkins masters need persistent storage, agents (typically) don't Mesos in 1.0+ Swarm Docker volume plugins: RexRay, Convoy, Flocker,... Kubernetes Docker volume support Persistent volumes
  • 34. 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
  • 35. CAVEATS Only a limited number of EBS volumes can be mounted Docs say /dev/sd[f-p], but /dev/sd[q-z] seem to work too NFS users must be centralized and match in cluster and NFS server
  • 36. NETWORKING Jenkins masters open several ports HTTP JNLP Build agent SSH server (Jenkins CLI type operations) Jenkins agents connect to master: inbound (SSH) outbound (JNLP)
  • 37. Allows getting one IP per container Mesos : Calico, Weave Swarm , and others from plugins Kubernetes Multiple : GCE, Weave, Calico,... Network Isolator Modules Docker overlay networking options
  • 39. 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
  • 40.
  • 41.
  • 42.
  • 43.
  • 44. 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(); }
  • 45. JENKINS DOCKER SLAVES PLUGIN Use any Docker image, no need for Java Definition in pipeline Can have side containers
  • 46.
  • 48. 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
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. 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
  • 55. 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" } }
  • 56. 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 Persistent workspace in the next version
  • 57. JENKINS KUBERNETES PIPELINE podTemplate(label: 'mypod', containers: [ [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 """ } } }
  • 58. 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
  • 59. JENKINS ONE SHOT EXECUTOR Improved API to handle one off agents Optimized for containerized agents Plugins need to support it