How to Set Up Jenkins Master-Slave Nodes ?
Efficient Configuration Strategies for Enhanced Jenkins Workflows
Jenkins Master-Slave Relationship
When you install Jenkins, the master takes charge of all build system tasks by default. However, when managing multiple projects with various job requirements, configuring slaves becomes essential. These slaves connect to the Jenkins master using the Java Network Launch Protocol (JNLP).
Jenkins Master and Slave Architecture
The Jenkins master orchestrates job scheduling, slave assignment, and dispatches builds to execute tasks. Monitoring slave status, collecting build responses, and displaying results on the console, it efficiently delegates the job workload across multiple slaves.
Steps to Configure Jenkins Master and Slave Nodes
Install Java on Master and Slave Nodes:
- Ensure that Java is installed on both the master and slave machines. Jenkins requires Java to operate.
sudo apt update
sudo apt install fontconfig openjdk-17-jre -y
Install Jenkins on Master Node:
Setup Jenkins on Master Node:
Configure SSH Keys:
Generate SSH keys on the master node using
ssh-keygen
.Copy the public key (
id_
rsa.pub
) to each worker node to allow secure communication.Master Jenkins
Worker Jenkins
Add Slave Nodes in Jenkins:
Create folder in Worker Jenkins.
Access the Master Jenkins dashboard.
Go to
Manage Jenkins
>Manage Nodes and Clouds
>New Node
.Enter a node name, choose
Permanent Agent
, and input configuration details like labels, number of executors, and usage.Setup Jenkins Credential
Master Jenkins
Save the configuration.
Launch Agent