Guide to Understanding Jenkins🧛‍♂️Master-Slave 👷‍♂️👷‍♀️ Architecture 🚀

Guide to Understanding Jenkins🧛‍♂️Master-Slave 👷‍♂️👷‍♀️ Architecture 🚀

Day 28 Task: 90DaysOfDevOps Challenge

Jenkins, the open-source automation server, is a powerhouse tool for continuous integration and continuous delivery (CI/CD). One of its standout features is the master-slave architecture, which empowers users to scale their build and deployment processes efficiently. 🏗️

🎆 Introduction

In this blog post, we'll deep dive into the Jenkins master-slave architecture, exploring its benefits, setting it up, and providing an example to illustrate its usage. 🌐

🧛‍♂️ Jenkins Master

Jenkins’s server or master node holds all key configurations. The Jenkins master server is like a control server that orchestrates all the workflow defined in the pipelines.

👇 Following are the characteristics of Jenkins Master:

  • Scheduling build jobs.

  • Dispatching builds to the slaves for the actual execution.

  • Monitor the slaves (possibly taking them online and offline as required).

  • Recording and presenting the build results.

  • A Master instance of Jenkins can also execute build jobs directly.

👷‍♂️👷‍♀️ Jenkins Slave/Workers

An agent is typically a Java executable that runs on a machine or container that connects to a Jenkins master and this agent actually executes all the steps mentioned in a Job.

When you create a Jenkins job, you have to assign an agent to it. Every agent has a label as a unique identifier.

When you trigger a Jenkins job from the master, the actual execution happens on the agent node that is configured in the job.

👇 Following are the characteristics of Jenkins Master:

  • It hears requests from the Jenkins Master.

  • Slaves can run on a variety of operating systems.

  • You can configure a project to always run on a particular Slave machine or a particular type of Slave machine.

🌟Benefits of Jenkins Master-Slave Architecture

🔹 Scalability: Master-slave architecture enables distributing workloads across multiple nodes, improving performance and accommodating larger projects.

🔹 Resource Optimization: Slaves can be configured on different machines with different operating systems and hardware, optimizing resource utilization.

🔹 Isolation: Build jobs on different slaves run in isolated environments, preventing dependencies or conflicts from affecting each other.

🔹 24/7 Availability: With dedicated slave nodes, builds and deployments can continue even if the master node experiences downtime.

🔹 Security: Sensitive code and data can be isolated on specific slave nodes, enhancing security.

⚙️Setting Up Jenkins Master-Slave Architecture

  1. Pre-requisites

    Let’s say we’re starting with a fresh Ubuntu 22.04 Linux. To get an agent working make sure you install Java (same version as Jenkins master server ) and Docker on it.

  2. Prepare Master and Slave Node

    Create two EC2 instances and name it Jenkins-master and Jenkins-slave1.

  3. Generate SSH keys on “Jenkins-master”

    1. Generate SSH keys on Jenkins-master by running

      ssh-keygen”. or if you face the SSH key format issue try with ssh-keygen -b 1024 -t rsa

    2. You can generate SSH keys on the slave node also and configure them accordingly.

    3. Now goto “.ssh” folder and there will be public and private keys generated in Jenkins-master.

  4. Configure Slave Nodes

    1. Add public key from “Jenkins-master” to “Jenkins-slave1” under location “.ssh/authorized_keys”.

  5. Connect Slave Nodes to Master

    1. Go to the Jenkins dashboard, and click on “Manage Jenkins”.

    2. Now, click on “Manage Nodes and Clouds”.

    3. Now, click on “+ New Node”.

    4. Enter the Node name and select Permanent Agent and click on create.

    5. Enter the required details as per your requirement.

    6. Make sure the Remote root directory you are specifying should be present in the slave node.

    7. Enter the Labels which is required.

    8. In the Usage Select as per your requirement I will select it here Use this node as much as possible.

    9. In Launch method Select as per your requirement I will select it here Launch agents via SSH.

    10. In the Host enter your Jenkins slave node public IP address .

    11. In Credentials Select your credentials or click on Add To add the credentials I will Add( and click on Jenkins pop-up) Here the new credentials.

    12. Select Domain as it is.

    13. In the Kind select SSH Username with private key .

    14. In the Username add what user you want to connect to the target server I will choose ubuntuas my target server user.

    15. Go to the Jenkins-master server in go to the .ssh/ open the id_rsa copy the secret key.

    16. In the Private Key Select Enter directly and click on Add .

    17. Enter/Paste the secret key carefully and enter the passphrase If you provided at the time of generating and click on Add .

    18. Now select the newly created credentials.

    19. Add other required details and click on Save.

    20. Now you will see slave node is added.

    21. Now click on the newly created slave node and click on Launch agent.

    22. Now, you can see the agent Authentication successful and Agent successfully connected and online also connected to Jenkins master.

🏍Running the Job/Project at the Jenkins-slave1 node

  1. Create a new project or you can tie the existing project with the Jenkins slave node.

  2. Now, go to configurations in your task or project scheduled in Jenkins, Select Restrict where this project can be run and add the Label as same with the name of Node.

  3. Click on Save, and your project will be tied to Jenkins-slave1.

  4. On the Dashboard you can see the slave node is also added

  5. Once you click on Build now the job will be executed by Jenkins slave1 nodesuccessfully.

🎉Conclusion

In this blog, we have seen how Jenkins master-slave architecture is an efficient and scalable CI/CD pipeline. It empowers teams to distribute workloads, optimize resources, and enhance security, all while ensuring consistent and reliable builds and deployments. By understanding and implementing this architecture, development teams can achieve greater productivity and streamline their software delivery process.


Thank you🙏🙏... for taking the time to read this blog. I hope you found the information helpful and insightful. So please keep yourself updated with my latest insights and articles on DevOps 🚀 by following me on

So, Stay in the loop and stay ahead in the world of DevOps!

Happy Learning !... Keep Learning ! 😊