Create a quick Distributed multi nodes Cluster with Jenkins using a Master node in Rhel8 Os and 3 slaves nodes (one Ec2 instance of AWS, one Guest Os of Windows and my local ubuntu machine)

Introduction

Why we need distributed or Multi nodes Cluster of Jenkins?

What is my plan?

Plan of work

Setup Master Node

i) sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

ii) sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key "If you’ve previously imported the key from Jenkins, the rpm --import will fail because you already have a key. Please ignore that and move on."
iii) yum install jenkins
  • Step2: Download the Java package
iv) sudo yum install jenkins java-1.8.0-openjdk-devel
  • Step3: Start the service of Jenkins
sudo systemctl daemon-reload 
sudo systemctl restart jenkins
jenkins successfully started and running on port 8080
  • Step4: Access the jenkins webui on your local machine:
sudo systemctl stop firewalld
ipconfig => to know the ip of your guest machine
Accessing jenkins webUi on my local machine browser.
Master node

Setup my local ubuntu machine as worker node1 :

  • I will set my local ubuntu machine as worker node1 and for that i need :
  • So first install the “ssh build agent” in the Master node by clicking Dashboard > Manage Jenkins > under System Configuration > select Manage Plugin > and under tab available > search ‘‘ssh’’ in the filter box and after click download to install it.
After install the plugin you will have to restart the jenkins service .
  • Now to set a worker node we need first to click under Dashboard>Nodes> click New Node like:
  • Now after you will be present to a page to set name for your worker node and select Permanent Agent button and then click ok:
  • So at next page, you will be prompt like this:
worker node1 successfully setup
  • Now let’s launch a job to test our configuration are working
You can see that a job has been launched in our worker node1.

Setup a second worker node with Windows guest Os from VB:

  • Step1) Install java jdk on the windows machine and check if it exist like:
  • Step2) Go to Master Node and and a second node :
after click save and continue
Under Launch method, you have to choose “Launch agent by connecting to master” as method of connection because the node is a windows machine and it will contact the Master node to instantiate a connection.
  • Now The second node come but not connected so we have to disable some security control:
  • Click on “Go to security configuration screen and change it” to modify security control. And after , under “Agents” choose “Random” point and Save.
  • After go and click again on the “Windows node2”, you will see:
After typing in the console the cmd you will be presented with above output
  • Master connected successfully:
2 Nodes connected successfully to Master Node

Setup a third node with AWS ec2 instances:

  • First login to your ec2 instance and install Java jdk because Jenkins agent works on java:
  • After login, install with sudo yum install java-1.8.0-openjdk:
  • Now go to Master Node in jenkins to add one more node like:
After typing the name click and save
  • Now let’s test our ec2 instance node by launching a jobs in Master which will install docker and launch one container inside of our slave node:
docker installed and container launched successfully from a job of Master node
  • Clicking on aws ec2Linux node, you can see the recent job tied successfully
  • Login again and check a container was launched successfully by our Master node

CONCLUSION

--

--

CI/CD Tech Explorer / ( DevOps & Cybersecurity Enthusiast ) on Lunar Planet🚀

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Edmond Tchamie

CI/CD Tech Explorer / ( DevOps & Cybersecurity Enthusiast ) on Lunar Planet🚀