#Day28: Jenkins Agents

#Day28: Jenkins Agents

ยท

4 min read

๐Ÿš€ 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:

  1. Java: Install Java on your system. Make sure it's the same version as your Jenkins Master server. โ˜•

  2. 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

ย