Jenkins Master & Agents
# Embrace Scalability with Jenkins Agents 🚀
👩💻 Hey there! I'm a DevOps engineer and a tech enthusiast with a passion for sharing knowledge and experiences in the ever-evolving world of software development and infrastructure. As a tech blogger, I love exploring the latest trends and best practices in DevOps, automation, cloud technologies, and continuous integration/delivery. Join me on my blog as I delve into real-world scenarios, offer practical tips, and unravel the complexities of creating seamless software pipelines. Let's build a strong community of tech enthusiasts together and embrace the transformative power of DevOps!
Introduction🌟
In the fast-paced world of DevOps, where agility and efficiency reign supreme, Jenkins stands tall as a trusted ally for continuous integration and continuous delivery (CI/CD). While Jenkins Master orchestrates the grand symphony of your CI/CD pipelines, Jenkins Agents are the talented performers who execute the tasks with finesse. Let's explore the dynamics of Jenkins Master and Agents, unveiling their pivotal roles in building scalable and efficient workflows.🌐
Jenkins Master: The Control Tower 🚀
The Jenkins master is the control center, the orchestrator of all things Jenkins. It holds the keys to essential configurations and keeps an eagle eye on your pipeline workflows.
The Jenkins Master, often referred to as the Jenkins server, is the heart and soul of your CI/CD environment. Think of it as the control tower at a bustling airport. Here's what makes it tick:
🔹Key Configurations:
The Jenkins Master holds all crucial configurations, making it the central repository for defining how your pipelines should work.
It's responsible for scheduling jobs, monitoring their execution, and overseeing the entire CI/CD process.
You interact with the Jenkins Master through its user-friendly web interface.
🔹Orchestrating Workflows:
The Master decides when and how jobs should run, providing a comprehensive view of the entire pipeline's progress.
It's your go-to for creating and managing jobs, setting up build environments, and configuring plugins.
You can think of the Master as the brain behind the operation, ensuring that your CI/CD processes flow seamlessly.
Jenkins Agent: The Hands-On Workforce 🛠️
The agent is the hands-on worker bee of the Jenkins ecosystem. It can be a machine or even a container that connects to the Jenkins master. This trusty agent gets its instructions from the master and executes the steps defined in your jobs. When you create a Jenkins job, you assign it to an agent, and that agent gets the job done.
When you trigger a Jenkins job, the real action unfolds on the agent node you've configured for that job. It's like having a team of specialized workers ready to tackle your tasks.
Here's why they're essential:
🔹Task Execution
When you create a Jenkins job, you assign it to an agent. This agent is responsible for executing the job's steps.
The agent acts as a dedicated worker, ensuring that your build, test, and deployment tasks are carried out efficiently.
It's like having a team of specialists who roll up their sleeves to get the job done.
🔹Scaling Possibilities
A single Jenkins Master can handle tasks for a small team with a limited number of projects. However, as your DevOps needs to grow, scalability becomes critical.
This is where Jenkins Agents shine. By connecting multiple agents to your Jenkins Master, you can distribute workloads, ensuring your CI/CD pipelines remain fast and responsive.
Agents enable parallelism, allowing multiple tasks to be executed concurrently, boosting productivity.
The Power of Scaling📈
The ability to scale your CI/CD workflows is one of the most significant advantages of employing Jenkins Agents. Instead of overburdening the Jenkins Master with executing build jobs and serving the UI, you delegate the execution to agents. The Master focuses on orchestrating, while agents handle the heavy lifting.
Scaling Up:
To scale your CI/CD workflows, you can set up additional agents. These agents can be physical machines, virtual machines, or containers.
Each agent can be specialized for specific tasks or have unique configurations to accommodate different project requirements.
This flexibility ensures that you can tackle larger projects and increased workloads without compromising efficiency.
In summary, Jenkins Master and Agents are a dynamic duo in the world of DevOps. The Master orchestrates the CI/CD symphony, while Agents deliver stellar performances. Their collaboration allows for seamless scaling, ensuring that your pipelines remain efficient and responsive as your DevOps journey evolves.
🎯 Task-01: Setting Up Your First Agent
Pre-requisites
When provisioning these EC2 instances, ensure that Jenkins and Java are installed as part of the setup process.
While creating an agent, be sure to separate rights, permissions, and ownership for Jenkins users.
Step 1: Generate two EC2 instances:
Launch two EC2 instances to serve as the primary "Master" and "Agent."

Step 2: Generate SSH keys on the “Jenkins-master” EC2 instance

Step 3: Add public key from “Jenkins-master” instance to “Jenkins-agent” instance under location “.ssh/authorized_keys”
Jenkins-master instance:

Jenkins-agent instance:

Step 4: Establish an agent by configuring a node within Jenkins
- Start by accessing the Jenkins dashboard and select "Manage Jenkins."

- Next, click on "Manage Nodes and Clouds."

- To initiate the creation of an agent, navigate to the left-hand side and click on "New Node."

- Begin the setup for your initial agent.

Add details of your node.

Choose the launching method as "Launch agents via SSH." Fill in the host field with the public IP address of the agent.

Under Credentials, click on “Add”.

Include the private key generated within the 'Jenkins-master' instance using the 'ssh-keygen' command.

Click the 'save' button to complete the node creation process. Once saved, you'll notice that the agent is now connected and online.
Your agent has been successfully set up.
🎯 Task-02: Unleash Your Previous Jobs
Remember those jobs you crafted on Days 28 and 29? It's time to put them to work on the new agent.
Use labels to associate jobs with the agent. Your master server should now trigger builds on the agent server.

Click on Save, and your project will be tied to Agent1.
Conclusion🌟
The beauty of this setup is scalability and efficiency. As your projects grow, simply add more agents to handle the load. Jenkins Agents are your DevOps workforce, ready to tackle any challenge you throw their way.
Share your thoughts on this journey, especially after four weeks of DevOps learning. Are you ready for what lies ahead? 🚀
