Jenkins Master & Slave Configuration
Jenkins Master (Server)
Jenkins’s server or master node holds all key configurations. The Jenkins master server is like a control server that orchestrates all the workflow defined in the pipelines. For example, scheduling a job, monitoring the jobs, etc.
Jenkins Slave (Node)
An agent is typically a machine or container that connects to a Jenkins master and this agent executes all the steps mentioned in a Job. When you create a Jenkins job, you have to assign an agent to it. Every agent has a label as a unique identifier.
When you trigger a Jenkins job from the master, the actual execution happens on the agent node that is configured in the job.
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:
Master:
Install java - sudo apt install openjdk-11-jre
Install jenkins - sudo apt install jenkins
Create ssh -keygen
Port should be open from security of virtual machine
Slave:
Install java
Copy public key of master in agent .ssh/authorized_keys
Check whether your master server Jenkins is running or not
Connect master to slave
Click - Manage Jenkins - Manage nodes and clouds - New node add
Give a node name and tick on permanent agent and create
Give description and Remote root directory as "/home/ibrahims/jenkins"
Give the label "dev" and Usage to " use this node much as possible" and Launch method to " Launch agents via SSH " and copy Host as slave server virtual machine IP address like this and paste it there.
Generate the SSH in slave nodes ssh-keygen
Slave node id_rsa.pub
copy to authorized_keys.
Jenkins provided the credentials
Copy the slave node id_rsa key and paste it here
Add the credentials
Save the setup
Finally, check the node is added
Create a freestyle pipeline to print "Slave Configured!!
Click Build now successfully run the command
I checked the slave server the mentioned path