๐ Exploring Jenkins: Master and Agent ๐
Are you ready to dive into the world of Jenkins? ๐ Well, you're in the right place! In this blog, we're going to talk about the heart and soul of Jenkins - the Jenkins Master and its trusty sidekick, the Jenkins Agent. ๐ต๏ธโโ๏ธ
Jenkins Master (Server) ๐งโโ๏ธ
Picture the Jenkins Master as the supreme commander of your Jenkins world. ๐ This server holds all the key configurations, making it the control tower ๐ผ that orchestrates all the workflows defined in your pipelines. From scheduling jobs to monitoring their progress, the Jenkins Master is your go-to hero. ๐ฆธโโ๏ธ
Jenkins Agent ๐ค
Now, meet the Jenkins Agent! ๐ค This Agent isn't a secret spy, but rather a machine or container that partners with the Jenkins Master to execute the steps defined in a job. ๐โโ๏ธ Every Jenkins job needs an Agent buddy to do the heavy lifting. ๐๏ธโโ๏ธ Each Agent has a unique label, helping Jenkins identify who's who in the Jenkinsverse. ๐ท๏ธ
When you hit that Jenkins job trigger button on the Master, all the action takes place on the Agent node configured for that job. It's like a dynamic duo, working together to get things done! ๐ฆธโโ๏ธ๐ค
Scaling Up Your Jenkins Game ๐
For small teams with a handful of projects, a single Jenkins installation might do the trick. But as your empire grows, you'll want to level up your Jenkins game. That's where the "master to agent connection" comes into play. ๐
Instead of cramming everything on one system, you can enlist Agents to handle job executions while the Master remains the UI wizard ๐งโโ๏ธ and control node. It's like having a team of superheroes to tackle your tasks! ๐ฆธโโ๏ธ๐ผ
Pre-requisites ๐ ๏ธ
Before embarking on your Jenkins journey, let's talk pre-requisites. If you're starting with a fresh Ubuntu 22.04 Linux installation, here's your checklist:
Java: Install Java on your system. Make sure it's the same version as your Jenkins Master server. โ
Docker: Get Docker up and running. It's like your Agent's superpower suit! ๐ณ
Remember, while creating an Agent, don't forget about permissions and ownership for Jenkins users. We want harmony in our Jenkins universe! ๐ค๐
So there you have it, a brief tour of the Jenkins Master and Agent dynamic duo. Stay tuned for more Jenkins adventures! ๐ Until next time, happy building! ๐๏ธ๐
Task-01
Create an agent by setting up a node on Jenkins
Create a new AWS EC2 Instance and connect it to master(Where Jenkins is installed)
The connection of master and agent requires SSH and the public-private key pair exchange.
Verify its status under "Nodes" section.
step -1: Create EC2 instances - Jenkins-server, Jenkins-agent
Step 2: Generate SSH keys on โJenkins-Masterโ using the โssh-keygenโ command**.**
step 3: Now go to the โ.sshโ folder and there will be public and private key in Jenkins Master server - id_rsa.pub & id_rsa
COPY
cd .ssh
Step 4: Go to the Jenkins agent server , Add the public key from โJenkins-Masterโ to โJenkins-agent-1โ under location โ.ssh/authorized_keysโ
In Jenkins master : Copy the public_key
In Jenkins agent :
Paste the public_key in the authorized_keys.
step 5: Now, go to the Jenkins dashboard, and click on โManage Jenkinsโ.
step 6: Now, click on โ Nodes โ
step 7: Click on new-Node.
step 8: Add details to add second node, accordingly.
step 9: Add Credentials >> kind: SSH with private_key & enter the details accordingly.
step 10: To enter the private_key, In Jenkin-Master:
COPY
cat id_rsa
Copy & Paste the Private_key
step 11: Connection is Successfull.
Task-02
Run your previous Jobs (which you built on Day 26, and Day 27) on the new agent
Use labels for the agent, your master server should trigger builds for the agent server.
step 12: Now build a job, here restrict the job to the particular agent.
step 13: Build Now