Jenkins Master-Slave cluster for Linux OS on the top of AWS Cloud
I use AWS EC2 instances for this architecture :
- "The slave type is permanent Slave and Operating System is Linux".
- Distributed Scheduling cluster
Overview of Steup :
- I use aws Cloud EC2 (AMI-amazon linux2) for -> Master node on which i Install jenkins.
- For Slave i also same EC2 instance and connection by SSH .
- I use jenkins by webUI using public IP of instance and jenkins port no:8080.
Note:
For Adding Slave Node to jenkins follwing things need to do:
- java must installed on that Slave because jenkins made from java.
- SSH should be enable in that Slave.
- Jenkins Agent installed on that Slave.
- Jenkins Slave node store data by default on slave so we need to create Directory on Slave node for data store.
Install java on Slave:
sudo yum install java-17-amazon-corretto-devel
Now create Directory for workspace:
mkdir PSworkspace
Label : It helps to execute job on which slave Node by Label name of Slave.
Remote root directory : This Slave Location we created for store data of job on slave.
Number of executors: Jenkins job execute with help of Build Executors, It menas If Build Executor is 3 then 3 Job run at a time or concurrent on that SlaveNode.
Select "Launch method" is -->> "Launch agent by via SSH" ( Thsi is because we use linux os system and jenkins required agent download by SSH and Connect Master by SSH to SlaveNode.)
In "Host" -->> Fill public Ip of Slave Node
And select "Credentials" -->> ADD
In "Kind" -->> "SSH username and private key"
- Note:
The private key which is used during launch Slave Node that key download on Local machine open that key by Double tap and copy that key and paste in "private Key" option
- Host verification means When we connect any system by SSH 1st time they ask Yes or No so we select Non-verification strategy.
Now Slave is Connected to master :
Create "New item" and select Freestyle job.
In general there is option for select this job on which Slave execute and add here label which given to slave.
In "Build" in Execute shell (Because linux os have Shell) and add any command .
Note:
The command should be use sudo for admin power and intractive command give arguments otherwise job fails.
Build job :
we see details on console output of that job
We can also check on EC2 terminal of slave Node:
- before:
- After job execute git installed: