Day 28 of 90 Days of DevOps Challenge: Configuring Jenkins Agents

Welcome to Day 28 of the 90 Days of DevOps challenge! 🎉

Today, we’re focusing on setting up Jenkins agents to scale your Jenkins environment. By using agents, you can distribute the workload and manage your builds more efficiently.


Understanding Jenkins Master and Agents

  • Jenkins Master: The master node manages Jenkins configurations, schedules jobs, and monitors builds. It’s the control server that orchestrates workflows.

  • Jenkins Agent: An agent is a machine or container that connects to the Jenkins master and executes jobs. Each agent has a unique label and can be used to run specific jobs based on the assigned label.

Scaling Jenkins with agents allows you to handle more complex and resource-intensive builds by distributing the workload across multiple machines.


Task-01: Set Up a Jenkins Agent

  1. Prepare Your Agent Environment

    • VM Setup: Start by creating a new Azure VM with Ubuntu 22.04. Ensure that Java (the same version as the Jenkins master) and Docker are installed on the instance.

    • Permissions: Make sure to set up the correct permissions and ownership for Jenkins users on the agent machine. This step is crucial for security and proper functioning.

  2. Configure the Jenkins Agent

    • Add a New Node:

      • In Jenkins, go to “Manage Jenkins” and select “Manage Nodes and Clouds.”

      • Click on “New Node” and enter a name for the agent.

      • Select “Permanent Agent” and click “OK.”

    • Configure Node Details:

      • Remote Root Directory: Specify a directory on the agent where Jenkins will store files.

      • Labels: Assign a label to the agent that you’ll use to specify which jobs should run on this node.

      • Launch Method: Select “Launch agents via SSH.”

      • Host: Enter the public IP address of your VM.

      • Credentials: Add the SSH private key used to connect to the instance.

    • Verify Node Status:

      • After saving the configuration, check the “Nodes” section to ensure that the new agent is connected and online.

For a detailed guide, you can follow this article.

Task-02: Run Jobs on the New Agent

  1. Update Job Configuration

    • For the jobs you created on Day 26 and Day 27, update the configuration to use the new agent:

      • Open the job configuration in Jenkins.

      • In the “General” section, find the “Restrict where this project can be run” option.

      • Enter the label assigned to your new agent.

  2. Trigger Builds

    • Save the job configuration and trigger a build.

    • Jenkins should now execute the job on the new agent based on the label configuration.

  3. Verify Execution

    • Check the build logs to ensure that the job is running on the new agent.

    • Monitor the agent and master to confirm that the build process is functioning as expected.


Conclusion

Today’s tasks focused on setting up and configuring Jenkins agents to scale your CI/CD infrastructure. By distributing job execution across multiple agents, you enhance your Jenkins environment’s efficiency and capability.

Feel free to share your progress and insights with the community using #90DaysOfDevOps. Keep up the great work and happy learning! 🚀