Day 24 Task: Jenkins Agent for DevOps Engineers.
Dear Engineers in today topic we will discuss on the topic Jenkins Agents in DevOps.
Jenkins Master (Server):-
Jenkins is an open source automation server, that helps for software engineers,building,testing and deploy software. Jenkins will used the Master and Slave architecture. In which master server server is responsible for managing and coordinating the entire build process.
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.
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.
Note:- While creating an agent, be sure to separate rights, permissions, and ownership for jenkins users.
Now let us discuss with the help of Task-1 & Task-2:-
Create an agent by setting up the node on Jenkins.
Create a new AWS Ec2 Instance and connect it to master( where Jenkins is installed).
The Connection of master and agent requires SSH and the public-private key pair exchange.
Now at the end verify the status under nodes section.
Let's move forward with below steps:-
1 Create 2 Ec2 Instances for Master and Agent.
A) Jenkins Master EC2 Instance.
B) Jenkins-Agent EC2 Instance.
C) In Jenkins-agent instance install the Jenkins and docker.Here are the few steps to install the docker and jenkins in the diagram
D) Generate SSH keys on “Jenkins-master” EC2 instance
Add public key from “Jenkins-master” instance to “Jenkins-agent” instance under location “.ssh/authorized_keys”
Jenkins Master Instance .ssh key:-
Jenkins Agent Instance .ssh key (I will add master key to agent with the help od authorised key option. Mention in the below Diagram:-
2 Create a agent by setting up a node in Jenkins.With below steps.
Recommended by LinkedIn
Go to the Jenkins dashboard and click on the Manage Jenkins, then
Click on the "Manage nodes and clouds"
To create a node click on "New Node" on right side.
Create your first agent.
Add details of your node, accordingly.
Add credentials for jenkins:
Add private key that we created in 'jenkins-master' instance using ssh-keygen.
after creating the private key enter in these key column and save the description.
Below we select ubuntu for credentials.
Click on 'save' that will create node.
You can see agent will be connected and online.
Thank you for reading this Article !! Stay Connected!!
Happy Learning!!
Next Topic:
Day 25 Task: Jenkins Interview Questions.