Professional Documents
Culture Documents
Advanced
DevOps Toolchain eMag Issue 28 - May 2015
Managing Build
Jobs for Continuous
Delivery
The number of jobs in a continuous inte-
gration tool can range from a few to sev-
eral thousand, all performing various
functions. There is an approach to manage
these jobs in a more efficient manner.
Service Discovery
Building microservices using immutable infrastructure means that
your services need to be reconfigured with the location of the other
services they need to connect to. This process is called Service Dis-
covery. This article compares the approaches by several key con-
tenders, from Zookeeper to Consul, Etcd, Eureka and rolling your
own.
FOLLOW US CONTACT US
GENERAL FEEDBACK feedback@infoq.com
ADVERTISING sales@infoq.com
EDITORIAL editors@infoq.com
facebook.com @InfoQ google.com linkedin.com
/InfoQ /+InfoQ company/infoq
MANUEL isofInfoQs DevOps Lead Editor and an enthusiast
Continuous Delivery and Agile practices.
PAIS Manuel Pais tweets @manupaisable
A LETTER FROM
and weaknesses of containers when compared to
THE EDITOR the more established virtual machines. He also high-
lights the expanding ecosystem around Docker, in-
cluding tools and libraries for networking, composi-
tion and orchestration of containers.
Many companies haven taken the route of au-
tomating delivery of traditional ops services such as
provisioning infrastructure, deploying to production
environments, adding metrics to monitor or creat-
The edition follows in the footsteps of the previous ing test environments as similar as possible to pro-
DevOps Toolchain for Beginners eMag. Once an duction. This decision often comes from reaching a
organization has acquired the essential skill set to bottleneck in operations workload as development
provision and manage infrastructure, set up delivery teams are empowered to deploy and own their ap-
pipelines and analyze logs and metrics, it will then plications through their entire lifecycle in a DevOps
gradually face more complex decisions. Decisions mindset. Brian Carpio describes his technical jour-
that depend much more on the type of systems ar- ney into creating such a self-service platform.
chitecture and organizational structure than on indi- When teams reap the benefits of continuous
vidual tool choices. delivery, they want more of it. On every project. Ev-
In this eMag we provide both implementation ery component. The number of jobs in the contin-
examples and comparisons of different possible ap- uous integration/delivery server explodes and a
proaches on a range of topics from immutable infra- maintenance nightmare ensues if care is not taken.
structure to self-service ops platforms and service Automated job creation and update becomes cru-
discovery. In addition, we talk about the Docker eco- cial to keep pace and avoid development teams get-
system and the different aspects to consider when ting bogged down by build and deployment issues.
moving to this increasingly popular system for ship- Martin Peston provides an overview and practical
ping and running applications. examples on this topic.
In the immutable infrastructure virtual panel we When adopting immutable infrastructure the
learn from both advocates and skeptics on the pros need to (re)connect services dynamically becomes
and cons of this disposable approach to infrastruc- a priority. This process is called Service Discovery.
ture changes. Instead of trying to converge machines Microservice architectures further exacerbate the
to a desired state, outdated machine are simply de- importance of reliably discovering and connecting
stroyed and replaced by a brand new machine with an increasing number of standalone services. The
the new changes applied. Simplicity Itself team analyzed the main solutions
Chris Swan gives us a rundown of the increas- available, as well as the pros and cons of (trying to)
ingly popular Docker tool, outlining the strengths do this on your own.
By Manuel Pais
THE PANELISTS
Chad Fowleris an internationally known software developer, trainer, manager, speaker, and
musician. Over the past decade, he has worked with some of the worlds largest companies
and most admired software developers. Chad is CTO of 6 Wunderkinder. He is the author or
co-author of a number of popular software books, including Rails Recipes and The Passionate
Programmer: Creating a Remarkable Career in Software Development.
Mark Burgessis the CTO and founder of CFEngine, formerly professor of network and system
administration at Oslo University College, and the principal author of the CFEngine software.
Hes the author of numerous books and papers on topics from physics to network and system
administration to fiction.
Mitchell Hashimotois best known as the creator of Vagrant and founder of HashiCorp. He is
also an OReilly author and professional speaker. He is one of the top GitHub users by followers,
activity, and contributions. Automation obsessed, Mitchell strives to build elegant, powerful
DevOps tools at HashiCorp that automate anything and everything. Mitchell is probably the only
person in the world with deep knowledge of most virtualization hypervisors.
Mitchell Hashimoto, another in functional programming have. one: it would be frozen and noth-
panelist, sees immutable infra- Infrastructure components, like ing would happen). What the
structure as an enabler for re- in-memory data structures, are term tries to capture is the idea
peatable environments (through running components that can that one should try to predeter-
configuration management be accessed concurrently. So the mine as many of the details as
tools) and extremely fast deploy- same problems of shared state possible of a server configuration
ments times (through pre-built exist. at the disk-image stage, so that
static images) and service or- In my definition of im- no configuration is needed.
chestration times (through de- mutable infrastructure, servers Then the idea supposes that this
centralized orchestration tools). (or whatever) are deployed once will make it fast and reliable to
This idea has been deemed and not changed. If they are spin up machines. When some-
utopian by Mark Burgess, our changed for some reason, they thing goes wrong, you just dis-
third panelist, due to the large are marked for garbage collec- pose of the machine and rebuild
number of external dependen- tion. Software is never upgraded a new one from scratch. That is
cies in any system today. Burgess on an existing server. Instead, my understanding of what peo-
criticizes the abuse of the notion the server is replaced with a new, ple are trying to say with this
of immutability. functionally equivalent server. phrase.
InfoQ reached out to them Mitchell: Immutable infrastruc- I believe there are a number
to ask about their definition and ture is treating the various com- of things wrong with this argu-
borders of immutable infrastruc- ponents of your infrastructure ment though. The idea of what it
ture as well as its benefits and as immutable, or unchangeable. means to fix the configuration is
drawbacks, in particular when Rather than changing any com- left very unclear and this makes
compared to desired state con- ponent, you create a new one the proposal unnecessarily con-
figuration management solu- with the changes and remove tentious. First of all, predeter-
tions. Is it a step forward or back- the old one. As such, you can be mining everything about a host
wards in effective infrastructure certain (or more confident) that is not possible. Proper configura-
management? if your infrastructure is already tion management deals with dy-
functioning, a change to config namic as well as static host state.
management, for example, wont Take the IP address and network-
break whats already not broken. ing config, for instance this
InfoQ: Can you briefly ex- Immutable infrastructure has to be set after the machine
plain your definition of im- is also sometimes referred to as is spun up. What about execut-
mutable infrastructure? phoenix servers but I find that ing new programs on demand?
term to be less general, since im- What if programs crash, or fail to
mutability can also apply at the start? Where do we draw the line
Chad: I wrote about this on service level, rather than just the between what can and cant be
my blog several months ago in server level. done after the machine has been
detail, but to me the high-level Mark: The term immutable is spun up? Can we add a package?
essence of immutable infrastruc- really a misnomer (if infrastruc- Should we allow changes from
ture shares the same qualities ture were really immutable, it DHCP but not from CFEngine or
that immutable data structures would not be much use to any- Puppet? Why? In my view, this is
Chris Swanis CTO atCohesiveFT, a provider of cloud networking software. Previously, he spent
a dozen years in financial services as a technologist to bankers and banker to technologists. He
spent most of that time at large Swiss banks wrangling infrastructure for app servers, compute
grids, security, mobile, and cloud. Chris also enjoys tinkering with the Internet of Things,
including a number of Raspberry Pi projects.
Docker is a toolset for Linux containers designed to build, ship, and run
distributed applications, first released as an open-source project by dotCloud
in March 2013. The project quickly became popular, leading dotCloud to
rebrand as Docker, the company (and ultimatelyselling off their original PaaS
business). The company released Docker 1.0 in June 2014 and has since
sustained the monthly release cadence that led up to the June release.
The 1.0 release marked the point sion of Docker can be used with zon, Google, and Microsoft. It is
where the company considered any other version (with both for- almost ubiquitously available
the platform sufficiently mature ward and backward compatibil- wherever Linux can be found. In
for use in production (with the ity), something that provides a addition to the big names, many
company and partners selling stable foundation for Docker use startups are growing up around
support options). The monthly despite rapid change. Docker or changing direction to
release of point updates shows The growth of Docker into better align with Docker. Those
that the project is still evolving one of the most popular open- partnerships (large and small)
quickly, adding new features, source projects could be per- are helping to drive rapid evo-
and addressing issues as they are ceived as hype, but there is a lution of the core project and its
found. The project has success- great deal of substance. Dock- surrounding ecosystem.
fully decoupled ship from run, er has attracted support from A brief technical overview
so images sourced from any ver- the industry, including Ama- of Docker
Brian Carpio is a technical leader in the IT space with over 15 years of experience Brian designed
and supported solutions for multiple Fortune 500 and 100 companies. His specialty is in large
scale environments where automation is a must. Brian loves working with new technology like
NoSQL and AWS.
The current buzz in the industry is how DevOps is changing the world and
how the traditional role of operations is changing. These discussions lead to
building self-service automation tools that let developers deploy and support
their own code. I want to discuss a little the work I did at a previous company
and how it changed the way the company did business.
AWS architecture service). One of our most heated other open standards. Initially,
We used AWS as the foundation discussions was over what AWS this wasnt a well-accepted view-
of our platform, but using AWS services we actually wanted to point because many of our de-
isnt the be-all and end-all; if any- support. I was a huge advocate velopers wanted to play with as
thing, it presented its own chal- of keeping it simple and sticking many AWS services as they could,
lenges to the self-service plat- strictly to EC2-related services but this paid off in the long run.
form we ended up designing. (compute, storage, load balanc-
ing, and public IPs). The reason Environments
Cloud-agnostic was simple: I knew that eventual- AWS doesnt provide an environ-
Amazon provides a wide range ly our AWS expense would grow ments concept, so the first archi-
of services from basic EC2 fea- so much that it might eventually tectural decision was on envi-
tures like instance creation to make sense to build our own pri- ronments. Having spent the last
full blown DBaaS (database as a vate cloud using OpenStack or 15 years working in operations, I
Features
Over time, the number of fea-
tures grew. Here is the list of
features that finally seemed to
provide the most value across 70
development teams around the
globe.
Martin Pestonis a build and continuous-integration manager forGamesys, the UKs leading
online and mobile-gaming company, owners of the popular bingo brandJackpotjoyand social
gaming success Friendzys on Facebook.
Martin has 15 years of cross-sector IT experience, including work in aerospace, defence, health,
and gambling. He has dedicated around half his career to build management and is passionate
about bringing continuous-delivery best practices to software-development companies.
In his spare time, Martin is a keen amateur astronomer and is author of A Users Guide to the
Meade LXD55 and LXD75 Telescopes, published by Springer in 2007.
There is a wealth of information build tool will subsequently run The number of jobs in a
describing CI processes but there jobs that compile and test the build tool can range from just a
is little information for the many code. The built artifact is then few to perhaps several thousand,
different CI tools and build jobs uploaded to a central reposito- all performing various func-
that compile and test the code, ry ready for further deployment tions. Fortunately, there is a way
which are central to the CI pro- and testing. to manage all of these jobs in a
cess. Hence, it is the role of jobs in more efficient manner.
In typical CI processes, de- the CI tool to manage the contin-
velopers manually build and test uous modifications of the source Automatic creation of
source code on their own ma- code, run tests, and manage the build jobs
chines. They then commit their logistics of artifact transporta- So why should we set up a facility
modifications to a source-con- tion through the deployment to automate the creation of other
trol-management system. A pipeline. jobs?
of jobs in the build tool will ciple should be the same for For clarity, I will talk only
inevitably increase. building applications for any lan- about Hudson but the informa-
2 Projects with existing jobs guage, such as Java, .NET, etc. tion is equally relevant for Jen-
may have issues. Consider Introducing the job-cre- kins.
two scenarios of dealing with ation build form The Hudson CI tool has
existing jobs in the build tool: The build form is a means to become popular among build
Delete the existing jobs pass information from the build managers looking to minimise
and recreate them with the tool directly to another feature their development resource
job-creation utility, thereby or back-end scripts that perform budget and who do not want to
losing all historical build in- the job-creation tasks. be tied down with expensive li-
formation and logs. Ideally, as much project cences.Hudson defines its build
Keep the existing jobs and information should be provid- job-configuration in XML format.
attempt to modify their con- ed up front. This will reduce any Typically, this XML file is acces-
figuration to match the job later effort required to add extra sible from the top-level page of
configuration created by the configurations to newly created the job URL, i.e. http://hostname/
job-creation utility. build jobs. Information such as job-name/config.xml
In any case, there is always going project title, location of source Most of the sections in the
to be some overhead with main- code, and specific build switch- config file are self-explanatory.
taining legacy build jobs. es are normally required.A push Sections are added by plugins in
of the Build button creates the the config file only when they are
Setting up self-service jobs just a few moments later. used in the Hudson GUI.
job creation in a build These config files can be
tool Build-tool made into templates by replac-
We have talked about the advan- implementation ing specific project information
tages of automatically creating Two tools with which I have set in them with tokens. Several
build jobs, so now lets discuss up automated job creation are templates can be used to carry
how we can implement such a Hudson and AnthillPro 3. out different tasks, e.g. checkout
feature in a build tool. The prin- Hudson/Jenkins
of source code from different An example of a Hudson has create job privileges,
SCMs such as Subversion or Git. API create-job upload command otherwise the upload will fail
Now we need to link the cre- is shown below: authentication.
ate-job build form to the scripts. curl H Content-Type:applica- 2 If Hudson tabs are used to
Diagram 1 shows the workflow. tion/xml s data @config.xml view specific groups of jobs,
The build form passes the ${HUDSONURL}/create- it will not be possible to au-
information to the scripts, which Item?name=hudsonjobname tomatically place any of the
substitute the tokens in the tem- (see Figure 1) newly created jobs under
plates with the relevant infor- The jobs can be manually those tabs, except for the ge-
mation. The config files are then added to a new view. (see Figure neric all tab (or any tab that
uploaded to the Hudson tool via 2) uses a regex expression).The
an API. More details about the There are a few points to Hudson master-configura-
API can be found in Hudson by note: tion file will require updating
adding the string api to the URL 1 If the Hudson security sec- as well as a manual restart of
in the browser, i.e. http://host- tion is configured, ensure the Hudson interface. Once
name/job-name/api. that the anonymous user the jobs are created, they can
AnthillPro
AnthillPro is a licensed build and CI tool from
UrbanCode (now part of IBM) that provides the
user almost complete custom control of build
jobs via a GUI and an extensive API library.
The latest incarnation from UrbanCode is
uBuild, which is essentially a cut-down version of
AnthillPro and is geared primarily towards the CI
building of products whereas its parent product
was originally designed to manage an entire CD
pipeline. uBuild does not have the API capability
that AnthillPro has but it is possible to create a
plugin that can do a similar thing.
Build jobs in AnthillPro are called work-
flows, which essentially are pipelines of individu-
al job tasks executed in a specific order (in series
or parallel).
AnthillPros API-scripting language, Bean-
Shell, is based on standard Java methods.
BeanShell scripts are stored within the Ant-
hillPro graphic user interface and called from
within a job task. The latest version of AnthillPro
allows developers to custom-build plugins with
any programming language.
An AnthillPro job task is created using API
calls that essentially construct all the necessary
functions of that workflow. The script can be par-
ticularly long, as every aspect of the workflow
configuration has to be populated with data.
Just like Hudson, a build form collects build-job
information and executes a master workflow,
calling on the BeanShell scripts to create the rel-
evant workflow. (Figure 3 & 4)
A typical Java BeanShell script: Code 2
Note: It is also possible to create a self-con-
tained package of Java BeanShell scripts such as
a jar file, which is placed in a folder on the Ant-
hillPro application server. Direct calls to classes
within the jar file can then be made from a shell
task within the application. This works well, es-
pecially because the scripts can be uni-tested
before being applied in a live development en-
vironment.
28
001 private static Project createProject(User user) throws Exception {
002 // get the values from the buildlife properties
003 String groupId = getAnthillProperty(GROUPID);
004 String artifactId = getAnthillProperty(ARTIFACTID);
005 String build_farm_env_name = linux-build-farm;
006
007 String branchName = branchName;
008
009 Workflow[] workflows = new Workflow[3];
010 // Set up Project
011 Project project = new Project(artifactId + _ + branchName);
012
013 // determine whether the project already exists and is active
014 boolean isProjectActive;
015 try {
016 Project projectTest =
017 getProjectFactoryInstance(artifactId + _ + branchName);
018 isProjectActive = projectTest.isActive();
019 } catch (Exception err) {
020 isProjectActive = false;
021 }
022
023 if (!isProjectActive) {
024 project.setFolder(getFolder(groupId, artifactId));
025 setLifeCycleModel(project);
026 setEnvironmentGroup(project);
027 setQuietConfiguration(project);
028
029 String applications = getAnthillProperty(APPS);
030 // create project properties
031 createProjectProperty(project, artifactId, artifactId, false, false);
032 // set the server group for the workflow and add environment properties
033 addPropertyToServerGroup(project, build_farm_env_name, applications);
034
035 project.store();
036
037 ...
038 ...
039
040 // Create the CI Build workflow
041 String workflowName = CI-build;
042 workflows[0] = createWorkflow(
043 project,
044 workflowName,
045 perforceClientFor(branchName, groupId, artifactId, workflowName)
+ buildLifeId,
046 perforceTemplateFor(branchName, groupId, artifactId,
workflowName),
047 ${stampContext:maven_version},
048 build_farm_env_name,
049 CI-build Workflow Definition
050 );
051
052 // add trigger url to commit-build branch
053 addRepositoryTrigger(workflows[0]);
054
055 // Create the Branch workflow
056 workflowName = Branch;
057 workflows[1] = createWorkflow(
Other tools matically create and tear down should be adopted as part of
As long there exists the ability to jobs on a build tool, so I cannot everyday software develop-
create jobs via an API or a tem- detail the technical challenges ment.
plate feature, the implementa- to implement such a task. How- Automatic creation of jobs
tion described here can be simi- ever, everything that has been saves time and allows the
larly applied to other build tools discussed here can lead to imple- developer to get on with
such as Go, TeamCity, and Bam- menting such a solution. In fact, more important tasks.
boo to name but a few. Atlassians Bamboo build tool Consistent build-job config-
Ultimate build-tool agility: can detect branch creation from uration leads to easier job
Implementing the lean build- a main baseline and automati- maintenance and drives con-
tool philosophy cally create an appropriate job to sistent development practic-
An advantage mentioned build it. es across a company.
earlier in this article is automat- Automatic job creation can
ically creating on-demand CI Summary ultimately lead to a true agile
projects and tearing them down We have discussed how to set up adoption of software devel-
after completion. This would sig- facilities to create other jobs that opment right down to the
nificantly reduce the amount of form part of the continuous de- build-tool level.
build jobs in the build tool. livery strategy for a business:
I have yet to implement An automated approach to
an agile, lean method to auto- creating jobs in a build tool
Service Discovery
These properties together This concept is one of the managers, have some form of
mean that your services need to key underpinnings of micros- service discovery.
be reconfigured with the loca- ervice architecture. Attempting There are current-
tion of the other services they to create microservices without ly several key contenders to
need to connect to. This recon- a service-discovery system will choose from: ZooKeeper, Con-
figuration needs to be able to lead to pain and misery, as you sul,etcd,Eureka, androlling your
happen on the fly, so that when will in effect be working as a own solution.
a new service instance is created, manual replacement.
the rest of the network can auto- As well as the standalone ZooKeeper
matically find it and start to com- solutions presented here, most ZooKeeper is an Apache project
munication with it. This process platforms, whether full PaaS that provides a distributed, even-
is calledservice discovery. or the more minimal container tually consistent, hierarchical
configuration store.
26
QCon London
2015 Report
25
Next Generation HTML5
and JavaScript
27 Technical Debt
and Software
Craftsmanship
24
Technology and Already a
Commodity?
This eMag discusses some familiar and some not too fa-
miliar development approaches and hopefully will give
you a helping hand while defining the technology stack
for your next mobile application.