Day 28 Jenkins Master & Agents

What is Jenkins Master (Server):

Jenkins Configure Master and Slave Nodes | Medium

In Jenkins, a "master" refers to the central server in a Jenkins automation setup. It is the core component responsible for managing and coordinating the entire Jenkins environment. The master server:

  1. Manages jobs: It schedules and executes jobs or tasks as defined in Jenkins pipelines and projects.

  2. Distributes work: If configured with multiple agents or nodes, the master distributes tasks to these agents for parallel execution.

  3. Provides the web interface: The Jenkins master hosts the web-based user interface where users can configure jobs, view build results, and manage Jenkins settings.

  4. Controls security: It manages user authentication, authorization, and access control for Jenkins.

  5. Logs and monitors: The master records build logs and provide monitoring and reporting capabilities for the entire Jenkins system.

What is Jenkins Agent?

Day 28 Task: Jenkins Agents

In Jenkins, an "agent" (also known as a "node" or "slave") is a worker machine that carries out tasks and builds as directed by the Jenkins master. Agents are used to distribute and parallelize work in Jenkins automation pipelines. Here's what agents do:

  1. Execution of Jobs: Agents are responsible for executing jobs or tasks that are defined in Jenkins pipelines or projects. When a job is scheduled for execution, the master assigns it to an available agent.

  2. Parallelization: Agents allow Jenkins to perform multiple tasks concurrently. For example, if you have several builds or tests to run, each can be assigned to a separate agent, speeding up the overall process.

  3. Diversity of Environments: Agents can run on different machines with various operating systems, software configurations, and hardware specifications. This allows Jenkins to support a wide range of build and test environments.

  4. Isolation: Agents provide isolation between different builds or jobs. This isolation ensures that one failing build or job doesn't affect others running on different agents.

  5. Scalability: Jenkins can be set up with multiple agents, allowing you to scale your automation infrastructure as needed. You can add or remove agents to handle varying workloads.

Task-01:

  • Create an agent by setting up a node on Jenkins

  • Launch two EC2 instances to serve as the primary "Master" and "Agent."

  • Generate SSH keys on the “Jenkins-master” EC2 instance

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

  • Jenkins-master instance:

  • Jenkins-agent instance:

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

    Click on new-Node.

Add details to add a second node, accordingly.\

step 9: Add Credentials >> kind: SSH with private_key & enter the details accordingly.

To enter the private_key, In Jenkin-Master:

cd /home/ubuntu/.ssh/
ls
cat id_rsa
copy private key

Copy & Paste the Private_key

Connection is successful

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.

Now build a job, here restrict the job to the particular agent.

Build Now

Output :

So I encourage you to try this on your own and let me know in the comment section about your learning experience

Thank you for reading! Your support means the world to me. Let's keep learning, growing, and making a positive impact in the tech world together.

Happy Learning 😊🙌

Thank You! Stay Connected ☁️👩‍💻🌈

Contact me at :

LinkedIn: Akash Singh

linkedin.com/in/akash-singh-48689a176

E-mail:

Did you find this article valuable?

Support Akash-DevOps by becoming a sponsor. Any amount is appreciated!