Scaling jenkins with kubernetes

13
Scaling Jenkins with Kubernetes 1.2

Transcript of Scaling jenkins with kubernetes

Page 1: Scaling jenkins with kubernetes

Scaling Jenkins with Kubernetes 1.2

Page 2: Scaling jenkins with kubernetes

About meSenior DevOps Engineer @ Glide

rubygems.org/profiles/amimahloof

Contribution to OpenSource via RubyGems and GitHub:

github.com/innovia

linkedin.com/in/amimahloof

Page 3: Scaling jenkins with kubernetes

Glide environment

Multiple Redis ServersMySQLDynamoDBMultiple Background Queue ProcessorsApp ServerMultiple Web Socket ServersCloudSearch

Page 4: Scaling jenkins with kubernetes

Previous Jenkins setupSingle Jenkins Master machine for Server code buildsSingle Jenkins Master Machine for Android client builds

Dedicated MySQL database per build

Dedicated port per build serviceEach build environment encapsulated and managed by Eye - process monitoringhttps://github.com/kostya/eye

Page 5: Scaling jenkins with kubernetes

Previous Jenkins IssuesUnder-utilized instances running 24/7 (expensive!)Port collisionsOut of memory issues - build failuresDatabases needed to be created and wiped per buildDebugging failed tests was extremely hardUpdating Jenkins ec2 image especially for Android was a challenge

Page 6: Scaling jenkins with kubernetes

NFS-SERVERPOD EBS Volume

Scaling Jenkins with Kubernetes

Jenkins Master BackEnd RC

Jenkins Master Android RC

Backend POD

Jenkins Ingress Controller

POD

nginx configmap

Jenkins SlavePOD

With KubeCtl

Backend Service (IP)

single elb for both CI’s

addresses

Page 7: Scaling jenkins with kubernetes

Current Jenkins Kubernetes Plugin

https://github.com/jenkinsci/kubernetes-pluginSupport single docker image(jenkins-slave docker image - it create’s a POD with that image)

Does not support multiple containers in a POD

Does not support Persistent Volumes

Page 8: Scaling jenkins with kubernetes

Modified Jenkins Kubernetes Pluginhttps://github.com/innovia/kubernetes-plugin

Support reading and parsing a POD template fileSupport multiple containers in a PODSupport Persistant Volumes, EBS, EmptyDir, HostPath VolumesDoes not support POD template per JOB (System global config)

Page 9: Scaling jenkins with kubernetes

Read POD Template

Start Build

Send POD Object

Jenkins SlavePOD

download JNLP file from Jenkins Master

Connect to Jenkins Master Slave Port

Build Flow Part 1

Pull Request

Page 10: Scaling jenkins with kubernetes

Build Flow Part 2

Jenkins Master Jenkins Slave

Start Job on Slave

git fetch and merge server code

create serviceJOB_NAME-BUILD_NUMBER

create PV - PVCJOB_NAME-BUILD_NUMBER start tests

teardown POD, SERVICE, PV, PVC

clean-up temp location

submit result to bitbucket

create PODJOB_NAME-BUILD_NUMBER wait for setup complete file

(check dependancies)

Page 11: Scaling jenkins with kubernetes

AdvantagesOn Demand PODs Complete test isolationSource controlled by developers flexible POD templateJobs queued up in Kubernetes Scheduler until node resources are available (running builds finish)Scalable Kubernetes Nodes Plugin keeps track of POD - if POD dies in the middle it launches up a new slave for that job Persistant Storage (EBS via NFS)Spot instances using node selectors

Page 12: Scaling jenkins with kubernetes

Kubernetes on Spot Instances

Save 70-90% over On Demand

Managed by Spot Fleet to reduce downtimeDifferent fleets for different types of Kubernetes Nodes, allowing dynamic pod allocation using Node Selector

Until implemented in Kubernetes 1.3, we have to create our own Fleets

eg.

https://github.com/kubernetes/kubernetes/issues/24472#issu

ecomment-211975112

Page 13: Scaling jenkins with kubernetes

Thank you!

Questions?Slides available

http://www.slideshare.net/AmiMahloof/scaling-jenkins-with-kubernetes