DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Optimizing CI/CD Pipeline With Kubernetes, Jenkins, Docker, and Feature Flags
  • Implementing CI/CD Pipelines With Jenkins and Docker
  • How To Use Docker Volume To Build Angular Application With Jenkins Pipeline
  • Java CI/CD: From Local Build to Jenkins Continuous Integration

Trending

  • The Modern Data Stack Is Overrated — Here’s What Works
  • Comparing SaaS vs. PaaS for Kafka and Flink Data Streaming
  • Building Scalable and Resilient Data Pipelines With Apache Airflow
  • Power BI Embedded Analytics — Part 2: Power BI Embedded Overview
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Jenkins Cluster Setup With Docker Containers

Jenkins Cluster Setup With Docker Containers

Read this tutorial to see a Jenkins cluster merge with Docker containers for perfect harmony.

By 
Andre Tadeu de Carvalho user avatar
Andre Tadeu de Carvalho
·
Jul. 21, 16 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
15.9K Views

Join the DZone community and get the full member experience.

Join For Free

* For impatient readers, skip to Setting a Jenkins Cluster Manually.

* For the automated solution, skip to I Want it Automated!

Jenkins is one of the mostly used Continuous Integration tools for build automation due to its capacity in managing a great number of nodes, called slaves, with executors for a wide range of tasks related to project build and deploy. Each executor runs Jenkins jobs, alleviating Jenkins server from running all the tasks.

Jenkins' capacity of running jobs should not be constrained by the hardware where it runs, or by the OS, or even by the locality where the jobs need to run. In this way, Jenkins slaves can do these jobs in other machines, in other networks (as long these machines can communicate by HTTP), in other operating systems, such as Windows or Solaris, and in other more powerful hardware. For instance, we can compile an application in C++ for Solaris 9 and several other Java 8 applications using Jenkins. Since there is no Java 8 distribution for Solaris 9, setting a slave was crucial to undertake this activity.

In spite of having a native way to configure Jenkins slaves, it is something error-prone and tedious when done several times. Therefore, we will use a Jenkins installation with Jenkins Swarm plugin, which allows the slaves to form a cluster by auto-discovering the master and self-registering them in it. We will also use Docker and Jelastic cloud for this demo due to the simplicity to customize Docker images and to operate Jelastic control panel and create environments in it.

Docker is a paravirtualization solution for Linux to run distributed applications. Due to its success, Docker became a de facto standard in the software industry, having several images made by the community and stored in its registry. For this reason, several cloud vendors implement Docker solutions in their products, such as Jelastic. In this demo, we'll use some Docker images from Jenkins Swarm and Jenkins Swarm slaves.

Jelastic is a cloud PaaS that uses containers, and it's possible to run Docker containers in it. In this article, we'll start a Jenkins master and two Jenkins slaves using the Jelastic control panel. For people who don't want to do all the work by hand, either due to the repetition or because it's tedious, there will be a demonstration below detailing how to create a Jenkins environment with slaves by importing a JSON file in the control panel.

Docker Images

For the demo in this article, we're going to use some (custom) Docker images. Firstly, we'll use the Docker image jelastic/jenkins-swarm as a customization of the official Jenkins Docker image with the installed Jenkins Swarm plugin. In addition, we're going to use the Docker image jelastic/jenkins-swarm-slave, which is a modified version of the image csanchez/jenkins-swarm-slave from Carlos Sanchez, by hard-coding the parameters passed to the swarm-client in jenkins-slave.sh script, and setting start and stop functions to be called by running the script with start or stop as arguments.

Setting a Jenkins cluster manually

Setting a Jenkins cluster manually is by no means a laborious task, as the Jelastic console is very practical for setting up environments. We can setup a Jenkins cluster following these simple steps:

1. Click the New Environment button in the top left of Jelastic control panel and open the Docker tab.Select container in Jelastic


2. After that, click the Select Container button and search for jelastic/jenkins-swarm.Jelastic Application Servers


3. Select the image, click the Extra button and select the image jelastic/jenkins-swarm-slave.Select Docker Image in Jelastic


4. Link the Jenkins slave containers to the master. To link the containers, click Links in the configuration section, then click Add and set the alias to jenkins. After that, click Save and Apply.Link Containers in Jelastic


5. For this demo, you can use just one node of each Docker image and the default number of cloudlets. Now, set the name of your environment and click the Create button.Create Environment in Jelastic


Several minutes later, your Jenkins cluster will be configured and ready to use. You can access it by clicking the Open in browser button within the Jenkins swarm container node row.Open in Browser

Jenkins cluster in Jelastic

I Want it Automated!

There are enough steps in the previous section that can be automated. In the Jelastic platform, you can import environments definitions from JSON files. To do so, let's follow the three steps below:

1. Click the down arrow of the New environment button and choose Import.

Jelastic Environment Import


2. After that, go to the URL tab and add the following URL and click Import https://raw.githubusercontent.com/jelastic-jps/jelastic-jenkins-cluster/master/jenkins-cluster.json.

Import URL in Jelastic


3. Specify the environment name and click the Install button. It is effortless!Install Jenkins Cluster in Jelastic


4. After loading the JSON file, we can check the status of the nodes by clicking on Open in Browser button.Jenkins in Jelastic


Now, it's the right time to use Jenkins with slaves, configured without obscure command lines, arcane configuration procedures, or error-prone setups. Jelastic offers a set of different ways to implement this, whether you need to do it manually or automatically.

GitHub repositories:

https://github.com/jelastic-jps/jenkins-swarm

https://github.com/jelastic-jps/jenkins-swarm-slave-docker

https://github.com/carlossg/jenkins-swarm-slave-docker

https://github.com/jelastic-jps/jelastic-jenkins-cluster

Try to create Jenkins environments based on Docker containers and see how easy it is! Just register for free at any of our partners' platforms within the Jelastic Cloud Union.

Do you have any questions? Feel free to leave comments below.

Docker (software) Jenkins (software)

Published at DZone with permission of Andre Tadeu de Carvalho, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Optimizing CI/CD Pipeline With Kubernetes, Jenkins, Docker, and Feature Flags
  • Implementing CI/CD Pipelines With Jenkins and Docker
  • How To Use Docker Volume To Build Angular Application With Jenkins Pipeline
  • Java CI/CD: From Local Build to Jenkins Continuous Integration

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!