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, Scaling Jenkins
Author of Jenkins Kubernetes plugin
Contributor to Jenkins, Maven official Docker images
OSS contributor at Apache Maven, Eclipse, Puppet,…
OUR USE CASE
Scaling Jenkins
Your mileage may vary
Isolated Jenkins masters
Isolated agents and jobs
Memory and CPU limits
BUT IT IS NOT TRIVIAL
SCALING JENKINS
Two options:
More agents per master
More masters
SCALING JENKINS: MORE 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 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
The best of both worlds
CloudBees Jenkins Operations Center with multiple
masters
Dynamic agent creation in each master
CLOUDBEES JENKINS ENTERPRISE
FIRST IMPLEMENTATION
Apache Mesos
Mesosphere Marathon
Terraform
Packer
&
We can run both Jenkins masters and agents in
Kubernetes
STORAGE
Handling distributed storage
Masters can move when they are restarted
Jenkins masters need persistent storage, agents
(typically) don't
Using PersistentVolumeClaim so you can
provide any implementation
CAVEATS
Performance
Lack of multi-AZ for block storage, ie. EBS AWS
"Worst-case scenario for just about any
commonly used network-based
storage"
NETWORKING
Jenkins masters open several ports
HTTP
JNLP agent
NETWORKING: HTTP
We use ingress rules and nginx ingress controller
Operations Center
Jenkins masters
Path based routing cje.example.com/master1
NETWORKING: JNLP
Agents started dynamically in cluster can connect to
masters internally
Agents manually started outside cluster connect
directly
Using NodePort
AGENTS WITH INFINITE* SCALE!
Dynamic Jenkins agents, running as Pods
Multi-container support
One Jenkins agent image, others custom
Jenkins Pipeline support for both agent Pod
definition and execution
Persistent workspace
Auto configured
Jenkins Kubernetes Plugin
ON DEMAND JENKINS AGENTS
podTemplate(label: 'mypod') {
node('mypod') {
sh 'Hello world!'
}
}
GROUPING CONTAINERS (PODS)
podTemplate(label: 'maven', containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-a
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'
}
}
}
}
}
USING DECLARATIVE PIPELINE
pipeline {
agent {
kubernetes {
label 'mypod'
containerTemplate {
name 'maven'
image 'maven:3.3.9-jdk-8-alpine'
ttyEnabled true
command 'cat'
}}}
stages {
stage('Run maven') {
steps {
container('maven') {
sh 'mvn -version'
}
}}}
}
MULTI-LANGUAGE PIPELINE
podTemplate(label: 'maven-golang', containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-a
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
"""
}}}}
PODS: SELENIUM
Example:
Jenkins agent
Maven build
Selenium Hub with
Firefox
Chrome
5 containers
podTemplate(label: 'maven-selenium', containers: [
containerTemplate(name:'maven-firefox',
image:'maven:3.3.9-jdk-8-alpine',
ttyEnabled: true, command: 'cat'),
containerTemplate(name:'maven-chrome',
image:'maven:3.3.9-jdk-8-alpine',
ttyEnabled: true, command: 'cat'),
containerTemplate(name: 'selenium-hub',
image: 'selenium/hub:3.4.0'),
// because containers run in the same network space, we need
// make sure there are no port conflicts
// we also need to adapt the selenium images because they we
// designed to work with the --link option
containerTemplate(name: 'selenium-chrome',
image: 'selenium/node-chrome:3.4.0', envVars: [
containerEnvVar(key: 'HUB_PORT_4444_TCP_ADDR', value: 'loc
containerEnvVar(key: 'HUB_PORT_4444_TCP_PORT', value: '444
containerEnvVar(key: 'DISPLAY', value: ':99.0'),
containerEnvVar(key: 'SE_OPTS', value: '-port 5556'),
]),
containerTemplate(name: 'selenium-firefox',
image: 'selenium/node-firefox:3.4.0', envVars: [
containerEnvVar(key: 'HUB_PORT_4444_TCP_ADDR', value: 'loc
containerEnvVar(key: 'HUB_PORT_4444_TCP_PORT', value: '444
containerEnvVar(key: 'DISPLAY', value: ':98.0'),
containerEnvVar(key: 'SE_OPTS', value: '-port 5557'),
])
node('maven-selenium') {
stage('Checkout') {
git 'https://github.com/carlossg/selenium-example.git'
parallel (
firefox: {
container('maven-firefox') {
stage('Test firefox') {
sh """
mvn -B clean test -Dselenium.browser=firefox 
-Dsurefire.rerunFailingTestsCount=5 -Dsleep=0
"""
}
}
},
chrome: {
container('maven-chrome') {
stage('Test chrome') {
sh """
mvn -B clean test -Dselenium.browser=chrome 
-Dsurefire.rerunFailingTestsCount=5 -Dsleep=0
"""
}
}
}
STORAGE
GCE disks
GlusterFS
NFS
EBS
etc
Persistent volumes
USING PERSISTENT VOLUMES
apiVersion: "v1"
kind: "PersistentVolumeClaim"
metadata:
name: "maven-repo"
namespace: "kubernetes-plugin"
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
podTemplate(label: 'maven', containers: [
containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-a
ttyEnabled: true, command: 'cat')
], volumes: [
persistentVolumeClaim(mountPath: '/root/.m2/repository',
claimName: 'maven-repo', readOnly: false)
]) {
node('maven') {
stage('Build a Maven project') {
git 'https://github.com/jenkinsci/kubernetes-plugin.git'
container('maven') {
sh 'mvn -B clean package'
}
}
}
}
RESOURCE REQUESTS AND
LIMITS
podTemplate(label: 'mypod', containers: [
containerTemplate(
name: 'maven', image: 'maven', ttyEnabled: true,
resourceRequestCpu: '50m',
resourceLimitCpu: '100m',
resourceRequestMemory: '100Mi',
resourceLimitMemory: '200Mi')]) {
...
}
DEPLOYING TO
KUBERNETES
If you haven't automatically destroyed
something by mistake, you are not
automating enough
podTemplate(label: 'deployer', serviceAccount: 'deployer',
containers: [
containerTemplate(name: 'kubectl',
image: 'lachlanevenson/k8s-kubectl:v1.7.8',
command: 'cat',
ttyEnabled: true)
]){
node('deployer') {
container('kubectl') {
sh "kubectl apply -f my-kubernetes.yaml"
}
}
}
kubernetes-pipeline-plugin
podTemplate(label: 'deploy', serviceAccount: 'deployer') {
stage('deployment') {
node('deploy') {
checkout scm
kubernetesApply(environment: 'hello-world',
file: readFile('kubernetes-hello-world-service.yaml'))
kubernetesApply(environment: 'hello-world',
file: readFile('kubernetes-hello-world-v1.yaml')) }}
stage('upgrade') {
timeout(time:1, unit:'DAYS') {
input id: 'approve', message:'Approve upgrade?'
}
node('deploy') {
checkout scm
kubernetesApply(environment: 'hello-world',
file: readFile('kubernetes-hello-world-v2.yaml'))
}}
}
Or Azure kubernetes-cd-plugin
kubernetesDeploy(
credentialsType: 'KubeConfig',
kubeConfig: [path: '$HOME/.kube/config'],
configs: '*.yaml',
enableConfigSubstitution: false,
)
THE FUTURE
Periodic snapshotting, ie. EBS volumes in AWS
Affinity
Dedicated workers for agents, infra autoscaling
Multi-region
Namespaces per team: quotas, isolation
THANKS
csanchez.org
csanchez
carlossg

More Related Content

What's hot

Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017
Carlos Sanchez
 
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Carlos Sanchez
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google CloudDocker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google Cloud
Samuel Chow
 
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech TalkKubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Red Hat Developers
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App EngineDocker, Inc.
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and AgentRanjit Avasarala
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Marcel Birkner
 
Intro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratchIntro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratch
John Culviner
 
Scaling jenkins with kubernetes
Scaling jenkins with kubernetesScaling jenkins with kubernetes
Scaling jenkins with kubernetes
Ami Mahloof
 
Amazon Web Services and Docker
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and Docker
Paolo latella
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
Sathish VJ
 
Deployment Automation with Docker
Deployment Automation with DockerDeployment Automation with Docker
Deployment Automation with Docker
Egor Pushkin
 
An Introduction to the Kubernetes API
An Introduction to the Kubernetes APIAn Introduction to the Kubernetes API
An Introduction to the Kubernetes API
Stefan Schimanski
 
Using Docker with Puppet - PuppetConf 2014
Using Docker with Puppet - PuppetConf 2014Using Docker with Puppet - PuppetConf 2014
Using Docker with Puppet - PuppetConf 2014
Puppet
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
Mathieu Buffenoir
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google Cloud
James Heggs
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
Ganesh Samarthyam
 
Docker
DockerDocker
Docker
Chen Chun
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
Ben Hall
 

What's hot (20)

Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017Testing Distributed Micro Services. Agile Testing Days 2017
Testing Distributed Micro Services. Agile Testing Days 2017
 
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
Scaling Jenkins with Docker: Swarm, Kubernetes or Mesos?
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
Docker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google CloudDocker, Kubernetes, and Google Cloud
Docker, Kubernetes, and Google Cloud
 
Kubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech TalkKubelet with no Kubernetes Masters | DevNation Tech Talk
Kubelet with no Kubernetes Masters | DevNation Tech Talk
 
Docker on Google App Engine
Docker on Google App EngineDocker on Google App Engine
Docker on Google App Engine
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and Agent
 
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and JenkinsContinuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
Continuous Delivery in Enterprise Environments using Docker, Ansible and Jenkins
 
Intro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratchIntro to Docker and clustering with Rancher from scratch
Intro to Docker and clustering with Rancher from scratch
 
Scaling jenkins with kubernetes
Scaling jenkins with kubernetesScaling jenkins with kubernetes
Scaling jenkins with kubernetes
 
Amazon Web Services and Docker
Amazon Web Services and DockerAmazon Web Services and Docker
Amazon Web Services and Docker
 
Docker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshopDocker and Kubernetes 101 workshop
Docker and Kubernetes 101 workshop
 
Deployment Automation with Docker
Deployment Automation with DockerDeployment Automation with Docker
Deployment Automation with Docker
 
An Introduction to the Kubernetes API
An Introduction to the Kubernetes APIAn Introduction to the Kubernetes API
An Introduction to the Kubernetes API
 
Using Docker with Puppet - PuppetConf 2014
Using Docker with Puppet - PuppetConf 2014Using Docker with Puppet - PuppetConf 2014
Using Docker with Puppet - PuppetConf 2014
 
The state of the swarm
The state of the swarmThe state of the swarm
The state of the swarm
 
Zero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google CloudZero to Continuous Delivery on Google Cloud
Zero to Continuous Delivery on Google Cloud
 
Docker by Example - Basics
Docker by Example - Basics Docker by Example - Basics
Docker by Example - Basics
 
Docker
DockerDocker
Docker
 
Architecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based DeploymentsArchitecting .NET Applications for Docker and Container Based Deployments
Architecting .NET Applications for Docker and Container Based Deployments
 

Similar to Using Containers for Continuous Integration and Continuous Delivery. KubeCon 2017

KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeAcademy
 
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
 
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
 
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Carlos Sanchez
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations Center
Jimmy Mesta
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !
Anthony Dahanne
 
Cloud-native applications with Java and Kubernetes - Yehor Volkov
 Cloud-native applications with Java and Kubernetes - Yehor Volkov Cloud-native applications with Java and Kubernetes - Yehor Volkov
Cloud-native applications with Java and Kubernetes - Yehor Volkov
Kuberton
 
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
 
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 ...
Paris Container Day
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
Antons Kranga
 
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
CI and CD at Scale: Scaling Jenkins with Docker and Apache MesosCI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
Carlos Sanchez
 
Running Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic BeanstalkRunning Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic Beanstalk
Amazon Web Services
 
Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015
Chef
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
Mukta Aphale
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
HungWei Chiu
 
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
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Amazon Web Services
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOps
Agile Spain
 
JDD2015: Kubernetes - Beyond the basics - Paul Bakker
JDD2015: Kubernetes - Beyond the basics - Paul BakkerJDD2015: Kubernetes - Beyond the basics - Paul Bakker
JDD2015: Kubernetes - Beyond the basics - Paul Bakker
PROIDEA
 
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
 

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

KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipelineKubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
KubeCon EU 2016: Leveraging ephemeral namespaces in a CI/CD pipeline
 
From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012From Dev to DevOps - FOSDEM 2012
From Dev to DevOps - FOSDEM 2012
 
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
 
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
Using Containers for Building and Testing: Docker, Kubernetes and Mesos. FOSD...
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations Center
 
Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !Get you Java application ready for Kubernetes !
Get you Java application ready for Kubernetes !
 
Cloud-native applications with Java and Kubernetes - Yehor Volkov
 Cloud-native applications with Java and Kubernetes - Yehor Volkov Cloud-native applications with Java and Kubernetes - Yehor Volkov
Cloud-native applications with Java and Kubernetes - Yehor Volkov
 
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
 
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 ...
 
Antons Kranga Building Agile Infrastructures
Antons Kranga   Building Agile InfrastructuresAntons Kranga   Building Agile Infrastructures
Antons Kranga Building Agile Infrastructures
 
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
CI and CD at Scale: Scaling Jenkins with Docker and Apache MesosCI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
CI and CD at Scale: Scaling Jenkins with Docker and Apache Mesos
 
Running Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic BeanstalkRunning Microservices on AWS Elastic Beanstalk
Running Microservices on AWS Elastic Beanstalk
 
Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015Baking Docker Using Chef - ChefConf 2015
Baking Docker Using Chef - ChefConf 2015
 
Baking docker using chef
Baking docker using chefBaking docker using chef
Baking docker using chef
 
Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)Build Your Own CaaS (Container as a Service)
Build Your Own CaaS (Container as a Service)
 
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
 
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
Running Microservices and Docker on AWS Elastic Beanstalk - August 2016 Month...
 
From Dev to DevOps
From Dev to DevOpsFrom Dev to DevOps
From Dev to DevOps
 
JDD2015: Kubernetes - Beyond the basics - Paul Bakker
JDD2015: Kubernetes - Beyond the basics - Paul BakkerJDD2015: Kubernetes - Beyond the basics - Paul Bakker
JDD2015: Kubernetes - Beyond the basics - Paul Bakker
 
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 ...
 

More from Carlos Sanchez

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
Carlos Sanchez
 
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
Carlos Sanchez
 
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed ApplicationsFrom Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
Carlos Sanchez
 
From Monolith to Docker Distributed Applications. JavaOne
From Monolith to Docker Distributed Applications. JavaOneFrom Monolith to Docker Distributed Applications. JavaOne
From Monolith to Docker Distributed Applications. JavaOne
Carlos Sanchez
 
Using Docker for Testing
Using Docker for TestingUsing Docker for Testing
Using Docker for Testing
Carlos Sanchez
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
Carlos Sanchez
 
Scaling Docker with Kubernetes
Scaling Docker with KubernetesScaling Docker with Kubernetes
Scaling Docker with Kubernetes
Carlos Sanchez
 
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
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 - 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
 
Eclipse IAM, Maven Integration For Eclipse
Eclipse IAM, Maven Integration For EclipseEclipse IAM, Maven Integration For Eclipse
Eclipse IAM, Maven Integration For Eclipse
Carlos Sanchez
 

More from Carlos Sanchez (13)

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
 
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
 
From Monolith to Docker Distributed Applications
From Monolith to Docker Distributed ApplicationsFrom Monolith to Docker Distributed Applications
From Monolith to Docker Distributed Applications
 
From Monolith to Docker Distributed Applications. JavaOne
From Monolith to Docker Distributed Applications. JavaOneFrom Monolith to Docker Distributed Applications. JavaOne
From Monolith to Docker Distributed Applications. JavaOne
 
Using Docker for Testing
Using Docker for TestingUsing Docker for Testing
Using Docker for Testing
 
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
 
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
 
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 - 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
 

Recently uploaded

Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Yara Milbes
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
abdulrafaychaudhry
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
Alina Yurenko
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 

Recently uploaded (20)

Top 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi ArabiaTop 7 Unique WhatsApp API Benefits | Saudi Arabia
Top 7 Unique WhatsApp API Benefits | Saudi Arabia
 
GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
Pro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp BookPro Unity Game Development with C-sharp Book
Pro Unity Game Development with C-sharp Book
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)GOING AOT WITH GRAALVM FOR  SPRING BOOT (SPRING IO)
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 

Using Containers for Continuous Integration and Continuous Delivery. KubeCon 2017

  • 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, Scaling Jenkins Author of Jenkins Kubernetes plugin Contributor to Jenkins, Maven official Docker images OSS contributor at Apache Maven, Eclipse, Puppet,…
  • 3. OUR USE CASE Scaling Jenkins Your mileage may vary
  • 4.
  • 5. Isolated Jenkins masters Isolated agents and jobs Memory and CPU limits
  • 6. BUT IT IS NOT TRIVIAL
  • 7. SCALING JENKINS Two options: More agents per master More masters
  • 8. SCALING JENKINS: MORE 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 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
  • 10. The best of both worlds CloudBees Jenkins Operations Center with multiple masters Dynamic agent creation in each master CLOUDBEES JENKINS ENTERPRISE
  • 11. FIRST IMPLEMENTATION Apache Mesos Mesosphere Marathon Terraform Packer
  • 12. &
  • 13. We can run both Jenkins masters and agents in Kubernetes
  • 14. STORAGE Handling distributed storage Masters can move when they are restarted Jenkins masters need persistent storage, agents (typically) don't Using PersistentVolumeClaim so you can provide any implementation
  • 15. CAVEATS Performance Lack of multi-AZ for block storage, ie. EBS AWS "Worst-case scenario for just about any commonly used network-based storage"
  • 16. NETWORKING Jenkins masters open several ports HTTP JNLP agent
  • 17. NETWORKING: HTTP We use ingress rules and nginx ingress controller Operations Center Jenkins masters Path based routing cje.example.com/master1
  • 18. NETWORKING: JNLP Agents started dynamically in cluster can connect to masters internally Agents manually started outside cluster connect directly Using NodePort
  • 19. AGENTS WITH INFINITE* SCALE! Dynamic Jenkins agents, running as Pods Multi-container support One Jenkins agent image, others custom Jenkins Pipeline support for both agent Pod definition and execution Persistent workspace Auto configured Jenkins Kubernetes Plugin
  • 20. ON DEMAND JENKINS AGENTS podTemplate(label: 'mypod') { node('mypod') { sh 'Hello world!' } }
  • 21. GROUPING CONTAINERS (PODS) podTemplate(label: 'maven', containers: [ containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-a 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' } } } } }
  • 22. USING DECLARATIVE PIPELINE pipeline { agent { kubernetes { label 'mypod' containerTemplate { name 'maven' image 'maven:3.3.9-jdk-8-alpine' ttyEnabled true command 'cat' }}} stages { stage('Run maven') { steps { container('maven') { sh 'mvn -version' } }}} }
  • 23. MULTI-LANGUAGE PIPELINE podTemplate(label: 'maven-golang', containers: [ containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-a 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 """ }}}}
  • 24. PODS: SELENIUM Example: Jenkins agent Maven build Selenium Hub with Firefox Chrome 5 containers
  • 25. podTemplate(label: 'maven-selenium', containers: [ containerTemplate(name:'maven-firefox', image:'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'), containerTemplate(name:'maven-chrome', image:'maven:3.3.9-jdk-8-alpine', ttyEnabled: true, command: 'cat'), containerTemplate(name: 'selenium-hub', image: 'selenium/hub:3.4.0'),
  • 26. // because containers run in the same network space, we need // make sure there are no port conflicts // we also need to adapt the selenium images because they we // designed to work with the --link option containerTemplate(name: 'selenium-chrome', image: 'selenium/node-chrome:3.4.0', envVars: [ containerEnvVar(key: 'HUB_PORT_4444_TCP_ADDR', value: 'loc containerEnvVar(key: 'HUB_PORT_4444_TCP_PORT', value: '444 containerEnvVar(key: 'DISPLAY', value: ':99.0'), containerEnvVar(key: 'SE_OPTS', value: '-port 5556'), ]),
  • 27. containerTemplate(name: 'selenium-firefox', image: 'selenium/node-firefox:3.4.0', envVars: [ containerEnvVar(key: 'HUB_PORT_4444_TCP_ADDR', value: 'loc containerEnvVar(key: 'HUB_PORT_4444_TCP_PORT', value: '444 containerEnvVar(key: 'DISPLAY', value: ':98.0'), containerEnvVar(key: 'SE_OPTS', value: '-port 5557'), ])
  • 28. node('maven-selenium') { stage('Checkout') { git 'https://github.com/carlossg/selenium-example.git' parallel (
  • 29. firefox: { container('maven-firefox') { stage('Test firefox') { sh """ mvn -B clean test -Dselenium.browser=firefox -Dsurefire.rerunFailingTestsCount=5 -Dsleep=0 """ } } },
  • 30. chrome: { container('maven-chrome') { stage('Test chrome') { sh """ mvn -B clean test -Dselenium.browser=chrome -Dsurefire.rerunFailingTestsCount=5 -Dsleep=0 """ } } }
  • 32. USING PERSISTENT VOLUMES apiVersion: "v1" kind: "PersistentVolumeClaim" metadata: name: "maven-repo" namespace: "kubernetes-plugin" spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi
  • 33. podTemplate(label: 'maven', containers: [ containerTemplate(name: 'maven', image: 'maven:3.3.9-jdk-8-a ttyEnabled: true, command: 'cat') ], volumes: [ persistentVolumeClaim(mountPath: '/root/.m2/repository', claimName: 'maven-repo', readOnly: false) ]) { node('maven') { stage('Build a Maven project') { git 'https://github.com/jenkinsci/kubernetes-plugin.git' container('maven') { sh 'mvn -B clean package' } } } }
  • 34. RESOURCE REQUESTS AND LIMITS podTemplate(label: 'mypod', containers: [ containerTemplate( name: 'maven', image: 'maven', ttyEnabled: true, resourceRequestCpu: '50m', resourceLimitCpu: '100m', resourceRequestMemory: '100Mi', resourceLimitMemory: '200Mi')]) { ... }
  • 36.
  • 37. If you haven't automatically destroyed something by mistake, you are not automating enough
  • 38. podTemplate(label: 'deployer', serviceAccount: 'deployer', containers: [ containerTemplate(name: 'kubectl', image: 'lachlanevenson/k8s-kubectl:v1.7.8', command: 'cat', ttyEnabled: true) ]){ node('deployer') { container('kubectl') { sh "kubectl apply -f my-kubernetes.yaml" } } }
  • 39. kubernetes-pipeline-plugin podTemplate(label: 'deploy', serviceAccount: 'deployer') { stage('deployment') { node('deploy') { checkout scm kubernetesApply(environment: 'hello-world', file: readFile('kubernetes-hello-world-service.yaml')) kubernetesApply(environment: 'hello-world', file: readFile('kubernetes-hello-world-v1.yaml')) }} stage('upgrade') { timeout(time:1, unit:'DAYS') { input id: 'approve', message:'Approve upgrade?' } node('deploy') { checkout scm kubernetesApply(environment: 'hello-world', file: readFile('kubernetes-hello-world-v2.yaml')) }} }
  • 40. Or Azure kubernetes-cd-plugin kubernetesDeploy( credentialsType: 'KubeConfig', kubeConfig: [path: '$HOME/.kube/config'], configs: '*.yaml', enableConfigSubstitution: false, )
  • 41. THE FUTURE Periodic snapshotting, ie. EBS volumes in AWS Affinity Dedicated workers for agents, infra autoscaling Multi-region Namespaces per team: quotas, isolation