The original link: www.edureka.co/blog/jenkin…

The original author: www.edureka.co/blog/author…

Release Date: November 25, 2020

Jenkins is one of the most important tools in DevOps. Jenkins was used in the continuous integration phase of DevOps. In this blog post, I’ll talk about Jenkins’ master and slave architectures. The main points I will introduce are as follows.

  • What is Jenkins?
  • Jenkins architecture
  • How does the Jenkins master-slave architecture work?
  • Set up the slave with the Jenkins master

So let’s start with the first topic.

What is Jenkins?

Jenkins is an open source automation tool written in Java with plug-ins built for continuous integration purposes. Jenkins is used to continuously build and test your software projects, making it easier for developers to integrate changes to the project and for users to get new builds. It also allows you to continuously deliver your software by integrating it with a wide range of testing and deployment techniques.

With Jenkins, companies can accelerate the software development process through automation. Jenkins integrated various development lifecycle processes, including build, documentation, testing, packaging, phasing, deployment, static analysis, and more.

Jenkins implemented continuous integration with the help of plug-ins. Plug-ins allow the integration of various DevOps phases. If you want to integrate a particular tool, you need to install a plug-in for that tool. Examples include Git, Maven 2 projects, Amazon EC2, HTML publishers, and so on.

The good things about Jenkins are.

  • It is an open source tool with a large community support.
  • It’s too easy to install.
  • It has over 1000 plugins to ease your work. If a plugin doesn’t exist, you can code it and share it with the community.
  • It’s free.
  • It is built in Java, so it is portable to all major platforms.

Jenkins architecture

Let’s look at Jenkins’ architecture. The figure below illustrates the same situation.

This single Jenkins server is not sufficient to meet certain requirements, such as.

  • Sometimes you may need several different environments to test your build. This cannot be done by a single Jenkins server.

  • If larger, heavier projects are built frequently, a single Jenkins server cannot simply handle the entire load.

To address these requirements, the Jenkins distributed architecture was developed.

Jenkins Distributed Architecture

Jenkins uses a master-slave architecture to manage distributed builds. In this architecture, the master and slave servers communicate over the TCP/IP protocol.

Jenkins master server

Your main Jenkins server is the Master. The Master’s job is to handle.

  • Schedule build jobs.

  • Assign the build to the slave server for actual execution.

  • Monitor the slave servers (possibly bringing them online or offline as needed).

  • Document and present build results.

  • A master instance of Jenkins can also perform build jobs directly.

Jenkins slave system

A Slave is a Java executable that runs on a remote machine. Here are the characteristics of Jenkins Slave.

  • It hears the request from the Jenkins master instance.

  • Slave machines can run on a variety of operating systems.

  • The Slave’s job is to do what they are asked to do, which involves performing build jobs scheduled by the Master.

  • You can configure a project to always run on a particular slave machine or a particular type of slave machine, or simply let Jenkins pick the next available slave machine.

The figure below is self-explanatory. It consists of a Jenkins Master who manages three Jenkins slaves.

How does the Jenkins master and slave architecture work?

Now let’s look at an example where we use Jenkins to test in a variety of environments, such as Ubuntu, MAC, Windows, and so on.

The graph below represents the same situation.

The figure above represents the following functions.

  • Jenkins periodically checks the source code in the Git repository for changes.

  • Each build requires a different test environment, which is not possible for a single Jenkins server. For testing in different environments, Jenkins used a variety of slaves, as shown in the figure.

  • Jenkins Master requests these slaves to perform tests and generate test reports.

How to set up Jenkins Master and Slaves?

Go to the Manage Jenkins section and scroll down to the Manage Nodes section.

  1. Click “New Node”

  1. Give the node a name, select the permanent proxy option, and click OK.

  1. Enter details about the slave node. The “number of actuators” here refers to the number of jobs that the slave machine can run in parallel. In this case, let’s keep it at 2. Enter a label named “Slave1 “that can be used to configure the job to use this slave machine. Select “Usage” and use this node whenever possible. For the launch method, we select the option “launch the agent by connecting to the master”. If this option is not visible, go to the Jenkins home page -> Manage Jenkins-> Configure Global Security. From here, click Random in the agent section and save it. Now you will find the options you need. Enter the custom WorkDir path as the workspace for your slave node. Select “Keep this agent online as much as possible” in availability. Click Save.

Once you have completed the above steps, the new node machine will initially be offline, but if all the Settings on the previous screen are entered correctly, it will be online. People can take the node offline at any time if needed.

  1. Now that your slave is up and running, let’s perform a job on the slave. To do this, I already have an existing job that I’m going to run on this slave. Open the job and click Configure. Now in the “General” section, click “Limit where this project can run”. In Label Expression, enter the name of the slave and save it. Now click Build Now to see the output of this job. Everything is correct and you will see the output as success.

That concludes this blog post about Jenkins’ master-slave architecture. I hope you have understood all the concepts explained here.

Now that you understand what a Jenkins master-slave architecture is, take a look at this DevOps training provided by Edureka, a trusted online learning company with a global network of over 250,000 satisfied learners. The Edureka DevOps Certified Training course helps learners understand what DevOps is and gain expertise in various DevOps processes and tools, such as Puppet, Jenkins, Nagios, Ansible, Chef, Saltstack, and GIT. To automate the multiple steps of the SDLC.

Do you have any questions for us? Leave them in the comments section and we’ll get back to you.


www.deepl.com translation