Jenkins Master–Slave Architecture
Jenkins Master and Slave (Agent) – Real-World Scenario
Imagine Jenkins Master as a manager and Slaves (Agents) as workers.
-
Master decides what to build and when
-
Slaves actually do the work
-
Communication happens via SSH
-
Each slave can run builds independently
-
Load is distributed → faster builds, no overload
Why Master–Slave is Used
-
Distributes builds across machines
-
Reduces load on Jenkins master
-
Supports parallel builds
-
Allows builds on different OS platforms
Key Concepts
-
Master: Scheduling, job control, UI
-
Slave (Agent): Executes builds
-
Java: Mandatory on slave
-
Labels: Used to target jobs to specific slaves
-
Executors: Number of parallel jobs a slave can run
Setting Up Jenkins Slave (Agent)
Step 1: Create a Server and Install Java & Maven
Run these commands on the slave server:
⚠️ Important Note
Do not install Java 17 unless required by the build:
Step 2: Configure Slave in Jenkins UI
Path:
Dashboard → Manage Jenkins → Nodes → New Node
Fill the configuration:
-
Node Name:
abc -
Type: Permanent Agent
-
Executors:
3(parallel builds) -
Remote Root Directory:
/tmp -
Labels:
slave1 -
Usage: Use this node as much as possible
-
Launch Method: Launch agents via SSH
-
Host: Slave private IP
-
Credentials:
-
Kind: SSH username with private key
-
Username:
ubuntu -
Private key:
.pemfile
-
-
Host Key Verification: Non-verifying
Save the node.
Step 3: Run Job on Slave
-
Open Job → Configure
-
Enable Restrict where this project can be run
-
Enter label:
slave1 -
Save and build
✅ Job will now execute on the slave machine.
Comments
Post a Comment