SlideShare a Scribd company logo
USING CONTAINERS FOR
CONTINUOUS INTEGRATION
AND
CONTINUOUS DELIVERY
Carlos Sanchez
/csanchez.org @csanchez
Watch online at carlossg.github.io/presentations
ABOUT ME
Engineer @ CloudBees, Scaling Jenkins
Author of Jenkins Kubernetes plugin
Contributor to Jenkins Mesos plugin & Jenkins and Maven
official Docker images
Long time OSS contributor at Apache Maven, Eclipse,
Puppet,…
DOCKER DOCKER
DOCKER
Using Containers for Continuous Integration and Continuous Delivery
USING CONTAINERS IS NOT TRIVIAL
Using Containers for Continuous Integration and Continuous Delivery
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 Enterprise
DOCKER AND JENKINS
RUNNING IN DOCKER
Using Containers for Continuous Integration and Continuous Delivery
Using Containers for Continuous Integration and Continuous Delivery
JENKINS DOCKER PLUGINS
Dynamic Jenkins agents with Docker plugin or Yet Another
Docker Plugin
No support yet for Docker Swarm mode
Isolated build agents and jobs
Agent image needs to include Java, downloads slave jar
from Jenkins master
JENKINS DOCKER PLUGINS
Multiple plugins for different tasks
Docker build and publish
Docker build step plugin
CloudBees Docker Hub/Registry Notification
CloudBees Docker Traceability
Great pipeline support
Using Containers for Continuous Integration and Continuous Delivery
Using Containers for Continuous Integration and Continuous Delivery
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}", 'app')
pcImg.push();
}
}
WHEN ONE MACHINE IS NO LONGER
ENOUGH
Running Docker across multiple hosts
In public cloud, private cloud, VMs or bare metal
HA and fault tolerant
Using Containers for Continuous Integration and Continuous Delivery
If you haven't automatically destroyed
something by mistake, you are not
automating enough
Using Containers for Continuous Integration and Continuous Delivery
Using Containers for Continuous Integration and Continuous Delivery
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
GROUPING CONTAINERS (PODS)
Example:
Jenkins agent
Maven build
Selenium Hub with
Firefox
Chrome
5 containers
STORAGE
Jenkins masters need persistent storage, agents (maybe)
Persistent volumes
GCE disks
GlusterFS
NFS
EBS
etc
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
PERMISSIONS
containers: [...]
securityContext:
fsGroup: 1000
volumes: [...]
Volumes which support ownership
management are modified to be owned
and writable by the GID specified in fsGroup
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)
Multiple :networking options
GCE, Flannel, Weave, Calico,...
One IP per Pod
Containers can find other containers in the same Pod using
localhost
MEMORY LIMITS
Scheduler needs to account for container memory
requirements and host available memory
Prevent containers for using more memory than allowed
Memory constraints translate to Docker --memory
https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-
pods-with-resource-limits-are-run
WHAT DO YOU THINK HAPPENS WHEN?
Your container goes over memory quota?
Using Containers for Continuous Integration and Continuous Delivery
NEW JVM SUPPORT FOR CONTAINERS
JDK 8u131+ and JDK 9
$ docker run -m 1GB openjdk:8u131 java 
-XX:+UnlockExperimentalVMOptions 
-XX:+UseCGroupMemoryLimitForHeap 
-XshowSettings:vm -version
VM settings:
Max. Heap Size (Estimated): 228.00M
Ergonomics Machine Class: server
Using VM: OpenJDK 64-Bit Server VM
Running a JVM in a Container Without Getting Killed
https://blog.csanchez.org/2017/05/31/running-a-jvm-in-a-container-without-getting-killed
NEW JVM SUPPORT FOR CONTAINERS
$ docker run -m 1GB openjdk:8u131 java 
-XX:+UnlockExperimentalVMOptions 
-XX:+UseCGroupMemoryLimitForHeap 
-XX:MaxRAMFraction=1 -XshowSettings:vm -version
VM settings:
Max. Heap Size (Estimated): 910.50M
Ergonomics Machine Class: server
Using VM: OpenJDK 64-Bit Server VM
Running a JVM in a Container Without Getting Killed
https://blog.csanchez.org/2017/05/31/running-a-jvm-in-a-container-without-getting-killed
CPU LIMITS
Scheduler needs to account for container CPU requirements
and host available CPUs
CPU requests translates into Docker --cpu-shares
CPU limits translates into Docker --cpu-quota
https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-
pods-with-resource-limits-are-run
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
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
JENKINS KUBERNETES PIPELINE
podTemplate(label: 'maven', containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine'
ttyEnabled: true, command: 'cat') ]) {
node('maven') {
stage('Get a Maven project') {
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
stage('Build a Maven project') {
sh 'mvn -B clean package'
}
}
}
}
}
Multi-language Pipeline
podTemplate(label: 'maven-golang', containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine',
ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'golang', image: 'golang:1.8.0',
ttyEnabled: true, command: 'cat')]) {
node('maven-golang') {
stage('Build a Maven project') {
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
sh 'mvn -B clean package'
}
}
stage('Build a Golang project') {
git url: 'https://github.com/hashicorp/terraform.git'
container('golang') {
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 CAVEATS
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 PLUGINS CAVEATS
One Shot Executor
Improved API to handle one off agents
Optimized for containerized agents
Plugins need to support it
MERCI
csanchez.org
csanchez
carlossg

More Related Content

What's hot (20)

PDF
Continuous Deployment with Jenkins on Kubernetes
Matt Baldwin
 
PDF
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Carlos Sanchez
 
PPTX
Automating Dev Environment - Introduction to Docker and Chef
kamalikamj
 
PDF
From Monolith to Docker Distributed Applications. JavaOne
Carlos Sanchez
 
PDF
Package your Java EE Application using Docker and Kubernetes
Arun Gupta
 
PDF
Docker, Kubernetes, and Google Cloud
Samuel Chow
 
PPTX
Docker toolbox
Yonghwee Kim
 
PDF
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
PDF
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
PDF
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Red Hat Developers
 
PDF
Scaling Docker with Kubernetes
Carlos Sanchez
 
PPTX
Installaling Puppet Master and Agent
Ranjit Avasarala
 
PDF
Docker and Kubernetes 101 workshop
Sathish VJ
 
PDF
Baking Docker Using Chef
Mukta Aphale
 
PDF
From Monolith to Docker Distributed Applications
Carlos Sanchez
 
PPTX
Scaling jenkins with kubernetes
Ami Mahloof
 
PDF
Using Docker with Puppet - PuppetConf 2014
Puppet
 
PDF
Docker by Example - Basics
Ganesh Samarthyam
 
PPTX
Docker Swarm scheduling in 1.12
Atharva Chauthaiwale
 
PPT
Amazon Web Services and Docker
Paolo latella
 
Continuous Deployment with Jenkins on Kubernetes
Matt Baldwin
 
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Carlos Sanchez
 
Automating Dev Environment - Introduction to Docker and Chef
kamalikamj
 
From Monolith to Docker Distributed Applications. JavaOne
Carlos Sanchez
 
Package your Java EE Application using Docker and Kubernetes
Arun Gupta
 
Docker, Kubernetes, and Google Cloud
Samuel Chow
 
Docker toolbox
Yonghwee Kim
 
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
Infrastructure testing with Jenkins, Puppet and Vagrant - Agile Testing Days ...
Carlos Sanchez
 
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Red Hat Developers
 
Scaling Docker with Kubernetes
Carlos Sanchez
 
Installaling Puppet Master and Agent
Ranjit Avasarala
 
Docker and Kubernetes 101 workshop
Sathish VJ
 
Baking Docker Using Chef
Mukta Aphale
 
From Monolith to Docker Distributed Applications
Carlos Sanchez
 
Scaling jenkins with kubernetes
Ami Mahloof
 
Using Docker with Puppet - PuppetConf 2014
Puppet
 
Docker by Example - Basics
Ganesh Samarthyam
 
Docker Swarm scheduling in 1.12
Atharva Chauthaiwale
 
Amazon Web Services and Docker
Paolo latella
 

Similar to Using Containers for Continuous Integration and Continuous Delivery (20)

PDF
Containerising bootiful microservices javaeeconf
Ivan Vasyliev
 
PDF
Dockerized maven
Matthias Bertschy
 
PDF
Docker + jenkins in the enterprise (3)
Kurt Madel
 
PDF
Achieving CI/CD with Kubernetes
Ramit Surana
 
PDF
Get you Java application ready for Kubernetes !
Anthony Dahanne
 
PDF
Fabric8: Better Software Faster with Docker, Kubernetes, Jenkins
Burr Sutter
 
PDF
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
Docker, Inc.
 
PDF
Cloud read java with kubernetes
Cesar Tron-Lozai
 
PDF
Microservices with Kubernetes, Docker, and Jenkins
Rafael Benevides
 
PDF
Microservices with Docker, Kubernetes, and Jenkins
Red Hat Developers
 
PDF
Javaone kubernetesjenkins
Pravat Bhusan Parida
 
PDF
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
PDF
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
NETWAYS
 
PDF
Kubernetes & Google Container Engine @ mabl
Joseph Lust
 
PDF
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Troublemaker Khunpech
 
PDF
Java one kubernetes, jenkins and microservices
Christian Posta
 
PPTX
Adapt or Die: A Microservices Story at Google
Apigee | Google Cloud
 
PPTX
Kubernetes 101
Vishwas N
 
PDF
A DevOps guide to Kubernetes
Paul Czarkowski
 
PPTX
Detailed Introduction To Docker
nklmish
 
Containerising bootiful microservices javaeeconf
Ivan Vasyliev
 
Dockerized maven
Matthias Bertschy
 
Docker + jenkins in the enterprise (3)
Kurt Madel
 
Achieving CI/CD with Kubernetes
Ramit Surana
 
Get you Java application ready for Kubernetes !
Anthony Dahanne
 
Fabric8: Better Software Faster with Docker, Kubernetes, Jenkins
Burr Sutter
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
Docker, Inc.
 
Cloud read java with kubernetes
Cesar Tron-Lozai
 
Microservices with Kubernetes, Docker, and Jenkins
Rafael Benevides
 
Microservices with Docker, Kubernetes, and Jenkins
Red Hat Developers
 
Javaone kubernetesjenkins
Pravat Bhusan Parida
 
DCSF 19 Building Your Development Pipeline
Docker, Inc.
 
OSDC 2018 | Three years running containers with Kubernetes in Production by T...
NETWAYS
 
Kubernetes & Google Container Engine @ mabl
Joseph Lust
 
CI/CD with Jenkins and Docker - DevOps Meetup Day Thailand
Troublemaker Khunpech
 
Java one kubernetes, jenkins and microservices
Christian Posta
 
Adapt or Die: A Microservices Story at Google
Apigee | Google Cloud
 
Kubernetes 101
Vishwas N
 
A DevOps guide to Kubernetes
Paul Czarkowski
 
Detailed Introduction To Docker
nklmish
 
Ad

More from Carlos Sanchez (16)

PDF
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
PDF
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
PDF
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
PDF
Using Docker for Testing
Carlos Sanchez
 
PPTX
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
PDF
Scaling Docker with Kubernetes
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
 
Divide and Conquer: Easier Continuous Delivery using Micro-Services
Carlos Sanchez
 
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
Using Docker for Testing
Carlos Sanchez
 
Scaling Jenkins with Docker and Kubernetes
Carlos Sanchez
 
Scaling Docker with Kubernetes
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
 
Ad

Recently uploaded (20)

PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
PDF
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
DOCX
Import Data Form Excel to Tally Services
Tally xperts
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
3uTools Full Crack Free Version Download [Latest] 2025
muhammadgurbazkhan
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
How Apagen Empowered an EPC Company with Engineering ERP Software
SatishKumar2651
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
An Introduction to ZAP by Checkmarx - Official Version
Simon Bennetts
 
유니티에서 Burst Compiler+ThreadedJobs+SIMD 적용사례
Seongdae Kim
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Capcut Pro Crack For PC Latest Version {Fully Unlocked} 2025
hashhshs786
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Import Data Form Excel to Tally Services
Tally xperts
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 

Using Containers for Continuous Integration and Continuous Delivery

  • 1. USING CONTAINERS FOR CONTINUOUS INTEGRATION AND CONTINUOUS DELIVERY Carlos Sanchez /csanchez.org @csanchez Watch online at carlossg.github.io/presentations
  • 2. ABOUT ME Engineer @ CloudBees, Scaling Jenkins Author of Jenkins Kubernetes plugin Contributor to Jenkins Mesos plugin & Jenkins and Maven official Docker images Long time OSS contributor at Apache Maven, Eclipse, Puppet,…
  • 5. USING CONTAINERS IS NOT TRIVIAL
  • 7. SCALING JENKINS Two options: More build agents per master More masters
  • 8. 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
  • 9. 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 Enterprise
  • 14. JENKINS DOCKER PLUGINS Dynamic Jenkins agents with Docker plugin or Yet Another Docker Plugin No support yet for Docker Swarm mode Isolated build agents and jobs Agent image needs to include Java, downloads slave jar from Jenkins master
  • 15. JENKINS DOCKER PLUGINS Multiple plugins for different tasks Docker build and publish Docker build step plugin CloudBees Docker Hub/Registry Notification CloudBees Docker Traceability Great pipeline support
  • 18. 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}", 'app') pcImg.push(); } }
  • 19. WHEN ONE MACHINE IS NO LONGER ENOUGH Running Docker across multiple hosts In public cloud, private cloud, VMs or bare metal HA and fault tolerant
  • 21. If you haven't automatically destroyed something by mistake, you are not automating enough
  • 24. 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
  • 25. GROUPING CONTAINERS (PODS) Example: Jenkins agent Maven build Selenium Hub with Firefox Chrome 5 containers
  • 26. STORAGE Jenkins masters need persistent storage, agents (maybe) Persistent volumes GCE disks GlusterFS NFS EBS etc
  • 27. 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
  • 28. PERMISSIONS containers: [...] securityContext: fsGroup: 1000 volumes: [...] Volumes which support ownership management are modified to be owned and writable by the GID specified in fsGroup
  • 29. 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)
  • 30. Multiple :networking options GCE, Flannel, Weave, Calico,... One IP per Pod Containers can find other containers in the same Pod using localhost
  • 31. MEMORY LIMITS Scheduler needs to account for container memory requirements and host available memory Prevent containers for using more memory than allowed Memory constraints translate to Docker --memory https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how- pods-with-resource-limits-are-run
  • 32. WHAT DO YOU THINK HAPPENS WHEN? Your container goes over memory quota?
  • 34. NEW JVM SUPPORT FOR CONTAINERS JDK 8u131+ and JDK 9 $ docker run -m 1GB openjdk:8u131 java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XshowSettings:vm -version VM settings: Max. Heap Size (Estimated): 228.00M Ergonomics Machine Class: server Using VM: OpenJDK 64-Bit Server VM Running a JVM in a Container Without Getting Killed https://blog.csanchez.org/2017/05/31/running-a-jvm-in-a-container-without-getting-killed
  • 35. NEW JVM SUPPORT FOR CONTAINERS $ docker run -m 1GB openjdk:8u131 java -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 -XshowSettings:vm -version VM settings: Max. Heap Size (Estimated): 910.50M Ergonomics Machine Class: server Using VM: OpenJDK 64-Bit Server VM Running a JVM in a Container Without Getting Killed https://blog.csanchez.org/2017/05/31/running-a-jvm-in-a-container-without-getting-killed
  • 36. CPU LIMITS Scheduler needs to account for container CPU requirements and host available CPUs CPU requests translates into Docker --cpu-shares CPU limits translates into Docker --cpu-quota https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how- pods-with-resource-limits-are-run
  • 37. WHAT DO YOU THINK HAPPENS WHEN? Your container tries to access more than one CPU Your container goes over CPU limits
  • 39. 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
  • 40. JENKINS KUBERNETES PIPELINE podTemplate(label: 'maven', containers: [ containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine' ttyEnabled: true, command: 'cat') ]) { node('maven') { stage('Get a Maven project') { git 'https://github.com/jenkinsci/kubernetes-plugin.git' container('maven') { stage('Build a Maven project') { sh 'mvn -B clean package' } } } } }
  • 41. Multi-language Pipeline podTemplate(label: 'maven-golang', containers: [ containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'), containerTemplate(name: 'golang', image: 'golang:1.8.0', ttyEnabled: true, command: 'cat')]) { node('maven-golang') { stage('Build a Maven project') { git 'https://github.com/jenkinsci/kubernetes-plugin.git' container('maven') { sh 'mvn -B clean package' } } stage('Build a Golang project') { git url: 'https://github.com/hashicorp/terraform.git' container('golang') { 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 """ } } }
  • 42. JENKINS PLUGINS CAVEATS 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
  • 43. JENKINS PLUGINS CAVEATS One Shot Executor Improved API to handle one off agents Optimized for containerized agents Plugins need to support it