Day 28- Jenkins Agents/90days of DevOps challenge
Jenkins is an open-source automation server that is widely used for continuous integration and continuous delivery (CI/CD) pipelines. It allows developers to automate various tasks such as building, testing, and deploying software applications.
In Jenkins, there are two main components: the Jenkins master and Jenkins agents (also known as Jenkins slaves). Let's take a closer look at each of them:
A single, monolithic Jenkins installation can work great for a small team with a relatively small number of projects. As your needs grow, however, it often becomes necessary to scale up. Jenkins provides a way to do this called “master to agent connection.” Instead of serving the Jenkins UI and running build jobs all on a single system, you can provide Jenkins with agents to handle the execution of jobs while the master serves the Jenkins UI and acts as a control node.
When a job is triggered in Jenkins, the master selects an available agent based on certain criteria (such as labels or job requirements) and assigns the job to that agent. The agent then performs the build steps or executes the pipeline on its own environment. The master and agents communicate with each other to exchange information about the job status and progress.
Pre-requisites:
Let’s say we’re starting with a fresh Ubuntu 22.04 Linux installation.
To get an agent working make sure you install Java ( same version as Jenkins master server ) and Docker on it.
Task-1
Jenkins, a powerful automation server, can significantly boost its performance by distributing build workloads across multiple machines using a master-slave setup. This step-by-step guide is tailored for beginners and aims to help you seamlessly establish a Jenkins master-slave architecture, complete with the use of RSA keys for secure authentication. Let's dive in!
Create an agent by setting up a node on Jenkins
Create a new AWS EC2 Instance and connect it to the master(Where Jenkins is installed)
The connection of the master and agent requires SSH and the public-private key pair exchange.
Verify its status under the "Nodes" section.
Step1:
The first step is to create two EC2 instances and name them accordingly, I named them Jenkins_master and Jenkins_agent.
Now Go to the jenkins_master instance install docker and Jenkins , add $USER and Jenkins to docker group using
sudo usermod -aG docker $USER
sudo usermod -aG docker jenkins
Step 2:
Generate RSA Key Pair on Master Server
ssh-keygen
cd .ssh
ls
cat id_rsa.pub #public key
Step 3:
Step 4: Connect to Slave from Master Server
Come to the Jenkins_master instance and try to connect to the Jenkins_agent via ssh.
领英推荐
Congratulations we have established a connection between two systems using SSH.
Now we can proceed with the next step, let's set up the agent on the master Jenkins server.
Step 1: Go to the Jenkins dashboard and set up an agent. ( if you don't see that go to manage Jenkins> Nodes ).
create a new node, name it (as you required) checkmark on the permanent agent, click on the create button, and it's created !!
Then on the next page, you will be asked to enter a few details such as description, remote directory, Host IP, and credentials
Configure the node settings:
Step 6: Launch the Agent
Task-02
Run your previous Jobs (which you built on Day 26, and Day 27) on the new agent
Use labels for the agent, your master server should trigger builds for the agent server.
Step 7: Create and Run a Pipeline
Save it and click on the build now button on the job's dashboard page.
Thank you for ??reading my blog, ??Like it and share it ?? with your friends.
Happy learning ???? !!!!