elastic build environment

72
©2013 CloudBees, Inc. All Rights Reserved 1 ©2013 CloudBees, Inc. All Rights Reserved Next Step in Automation: Elastic Build Environment Kohsuke Kawaguchi / CloudBees, Inc. [email protected] / @kohsukekawa

Upload: cachet-software-solutions-ltd

Post on 08-May-2015

388 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 1©2013 CloudBees, Inc. All Rights Reserved

Next Step in Automation:Elastic Build EnvironmentKohsuke Kawaguchi / CloudBees, [email protected] / @kohsukekawa

Page 2: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 2

Have You Met Jenkins? http://jenkins-ci.org/

Page 3: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 3

32%

Page 4: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 4

18%

Page 5: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 5

Page 6: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 6

My Jenkins around 2006

Page 7: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 7

Page 8: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 8

Page 9: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 9

Workload

http://www.flickr.com/photos/gbyrnes/912576883/

Page 10: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 10

If only we had more computers…

• Just building & testing them all…• Running tests more frequently• Testing individual commits

Page 11: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 11

What you don’t wanthttp://www.flickr.com/photos/drocpsu/8546730021/

Page 12: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 12

Just enough computersjust in time

Elasticity

Page 13: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 13

My Jenkins around 2007

Page 14: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 14

Page 15: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 15

Page 16: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 16

Page 17: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 17http://www.flickr.com/photos/drocpsu/8546730021/

Page 18: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 18

18

But not this, either

Page 19: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 19

Just enough computersof the right kind

just in time

Elasticity!

Page 20: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 20http://www.flickr.com/photos/82219206@N00/7003641975/

Page 21: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 21

Correct answer

• Test assumes a fixture running on port 8080– Doesn’t check if it’s already being used

• If another test runs at the same time…?

Page 22: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 22http://www.flickr.com/photos/82219206@N00/7003641975/

Page 23: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 23

Correct answer

• Because of “pkill -f -9 tomcat” cleanup

Page 24: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 24

Isolation

http://www.flickr.com/photos/jumilla/8667648797/

Page 25: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 25

Isolation

• At odds with large multi-core systems

• x86 virtual machines• User isolation• Kernel containers

Page 26: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 26

!

Page 27: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 27http://www.flickr.com/photos/82219206@N00/7003641975/

Page 28: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 28

Correct answer

• Same Maven ID, two different jars

• Different projects designate different ones• Local cache gets cleaned up periodically

• Whichever first runs after cache cleanup “wins”

Page 29: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 29http://www.flickr.com/photos/82219206@N00/7003641975/

Page 30: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 30

Correct answer

• Test script leaves background daemon process behind

• Over time it’ll slowly choke slaves

Page 31: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 31

Page 32: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 32

Throw away & create new

Elasticity!

Page 33: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 33

Page 34: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 34

Ladder to Cloud

Single

MultipleElastic

Page 35: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 35

Parallel Testing

Test Group #1 Test Group #2 Test Group #3

Page 36: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 36

Parallel Testing

foo #10 Test Group #1

foo #11 Test Group #2

foo #12 Test Goup #3

Page 37: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 37

Validated Merge: Jenkins Enterprise by CloudBees

upstreamrepo

gate repo

Page 38: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 38

Recap: Elasticity Benefits

• Just-in-time capacity• Diversity without overhead• Isolation• Productivity gain– parallel testing– validated merge– keep failed tests on the side

Page 39: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 39

Solid OSS Elasticity Plugins

• EC2 plugin• Jclouds plugin– OpenStack, CloudStack

• Launch and tear down slaves on demand

Page 40: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 40Image © http://sfcitizen.com/blog/wp-content/uploads/2011/11/6302790910_c4eb865892_o-copy.jpg

©2013 CloudBees, Inc. All Rights Reserved

Demo

Page 41: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 41

• Master– Serves HTTP requests– Stores all important info

• Slaves– 280KB single jar– Assumed to be

unreliable– Scale to 100s

Distributed builds with Jenkins

Master

slave1

slave2

slave3

slave4

slave5

slave6

slave7

slave8

Page 42: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 42

Lots More Way To Deploy Slaves

• Good old shell scripting

$ java -jar slave.jar -jnlpUrl URL

Page 43: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 43

How Flexible Does It Get?

• Slave agent is a little Java program– Runs locally on the machine that it controls– Access files, fork processes, etc., on behalf

of master

• Communication with master– Just needs a bi-di byte stream

• No shared file system, no network topology constraints, etc

Page 44: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 44

Static Virtual Machines As Build Slaves

• Allocate lots of identical VMs– Better consistency, lower overhead

• Curve up 1 big machine to small VMs• Throw away > maintain

Page 45: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 45

Labels

• Refer to slavesbut not by name

Name: alphaLabel: windows 32bit

Name: bravoLabel: linux 32bit

Name: charlieLabel: linux 64bit

Page 46: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 46

Labels

Name: alphaLabel: windows 32bit

Name: bravoLabel: linux 32bit

Name: charlieLabel: linux 64bit

This job needs to run on “linux”

Page 47: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 47

Labels

Name: alphaLabel: windows 32bit

Name: bravoLabel: linux 32bit

Name: charlieLabel: linux 64bit

This job needs to run on “linux && 32bit”

Page 48: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 48

More Label Benefits

• Labels can be anything– Geographic locations– Availability of proprietary software

installed

• Better resource utilization– Jenkins have maximum freedom

• Resilient to node addition/removal– Treat servers like livestocks, not like pets

Page 49: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 49

Load Statistics Monitoring

49

Page 50: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 50

“Cloud” plugin

Page 51: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 51

EC2 Plugin

• Label → Amazon Machine Image (AMI)• Integrates with various AWS features– Spot Instance– Identity and Access Management (IAM)– Virtual Private Cloud (VPC)

Page 52: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 52

jclouds plugin

• CloudStack, OpenStack, and many more

• “One-time use” support

Jenkins jclouds cloud

Page 53: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 53

Then Adjust Capacity based on it

Page 54: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 54

Jenkins Enterprise by CloudBees

• VMWare auto-scaling plugin– Snapshot– Power on-off management– Hypervisor-aware scheduling– Folder based pooling– VMWare tools integration– One-time use support

Page 55: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 55

Mansion

Slave Slave

Slave Slave

CloudBees DEV@cloud

Page 56: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 56

Maven

Git

Ant

Mercurial

Gradle

Subversion

Linux Kernel

Hardware

Linux Container = zero cost virtualization

Page 57: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 57

For OS X

Maven

Git

XCode

Git

XCode

Subversion

OS X OS X OS X

QEMU QEMU QEMU

Linux Kernel

Apple Hardware

Page 58: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 58

Kernel Same-page Merging

OS X OS X OS X

Page 59: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 59

Page 60: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 60

Mansion

Slave

Slave

Slave

Workspace 1

Workspace 2

Workspace 3

Workspace 4

Page 61: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 61

Slave

Slave

Workspace

Workspace’’

Workspace’

Page 62: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 62

Slave

Slave

~/.m2/repository

~/.m2/repository

~/.m2/repository

Page 63: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 63

この苦しみから解脱する方法はないかと

• お釈迦様の絵

• 徐々に蓄積してきたノウハウ・ツールを大公開

Elasticity Nirvana?

Page 64: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 64

Page 65: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 65

Testing things in piecesTraditional Approach

Page 66: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 66

Testing the whole is hard

• Database• Load balancer• Messaging layer• Identity service• …

Page 67: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 67http://www.flickr.com/photos/46471983@N00/339605220/

Substitute vs Mock

Page 68: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 68

What you really want = real deal!

Test and production environment should be identical

… which means automating:– Database– Load balancer–Messaging layer– Identity service–…

Page 69: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 69

The Challenge

Infrastructure as Code

Page 70: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 70

The Real Challenge

Elasticity

Page 71: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 71

Single

MultipleElastic

The same evolution ladder

aka PaaS

Page 72: Elastic build environment

©2013 CloudBees, Inc. All Rights Reserved 72