Skip to main content

Command Palette

Search for a command to run...

๐Ÿ’ŽDay 28 - Jenkins Agents

Published
โ€ข4 min read
๐Ÿ’ŽDay 28 - Jenkins Agents
P

Hey there! ๐Ÿ‘‹

I'm Pratik R. Mandge, a DevOps Engineer passionate about all things AWS DevOps Technology. Currently on a learning adventure, I'm here to share my journey and Blog's in the world of cloud and DevOps.

๐Ÿ› ๏ธ My focus? Making sense of AWS services, improving CI/CD, and diving into infrastructure as code. Whether you're fellow interns or curious enthusiasts, let's grow together in the vibrant DevOps space.

๐ŸŒ Connect with me for friendly chats, shared experiences, and learning moments. Here's to embracing the learning curve and thriving in the exciting world of AWS DevOps Technology!

Follow me on LinkedIn: https://www.linkedin.com/in/pratik-mandge363

๐Ÿ—กJenkins Master (Server)

Jenkins Master (Server) is the core component of a Jenkins installation. It manages the build jobs, schedules, and distributes build tasks to the Jenkins Agents (Nodes) for execution. The Jenkins Master also stores the configuration settings, plugins, and build histories.

๐Ÿ—กJenkins Agent

Jenkins Agent, also known as Jenkins Node, is a worker machine that executes build jobs dispatched by the Jenkins Master. Agents can be set up on different operating systems and architectures to perform diverse tasks, making Jenkins highly flexible and scalable.

Agents may be connected to the Jenkins controller using either local or cloud computers. It requires a Java installation and a network connection to the Jenkins controller.

๐Ÿ—กPre-requisites

Assuming a fresh Ubuntu 22.04 Linux installation, setting up a Jenkins agent involves installing Java (matching the version on the Jenkins master server) and Docker. It's crucial to manage rights, permissions, and ownership for Jenkins users when creating agents.

โš™๏ธTask-1: Setting Up a Jenkins Agent

๐Ÿ”ปCreate an AWS Instance

Begin by launching a new AWS EC2 instance. This instance will serve as the agent node connected to the Jenkins master. Follow these steps:

  1. Log in to your AWS Management Console.

  2. Navigate to the EC2 dashboard.

  3. Click on "Launch Instance" to create a new virtual machine.

๐Ÿ”ปConfigure EC2 Instance

During the instance configuration process:

  1. Choose an Amazon Machine Image (AMI), preferably a recent version of Ubuntu.

  2. Select an instance type based on your requirements.

  3. Configure instance details, including the number of instances, network settings, and storage.

๐Ÿ”ปAdd Security Group

Ensure that your security group allows SSH access. Add an inbound rule for SSH (port 22) to allow connections from your Jenkins master server.

๐Ÿ”ปLaunch Instance

Review your configurations and launch the instance. AWS will prompt you to select or create a key pair for connecting to the instance securely. Save the private key file (.pem) as you will need it to connect via SSH.

๐Ÿ”ปConnect EC2 Instance to Jenkins Master

Once the EC2 instance is running, use SSH to connect to it from your Jenkins master server. Use the private key you saved during the instance launch. The command will look like this:

ssh -i /path/to/private-key.pem ubuntu@ec2-instance-ip

๐Ÿ”ปInstall Java and Docker & Docker-Compose

On the EC2 instance, install Java, Docker & Docker-Compose to ensure compatibility with the Jenkins master server. Ensure that the Java version matches the one installed on the master.

๐Ÿ”ปAdd Agent Node in Jenkins UI

  1. In the Jenkins UI, navigate to "Manage Jenkins" > "Manage Nodes and Clouds."

  2. Click on "New Node" to add a new agent.

  3. Enter a name for the agent, select "Permanent Agent," and click "OK."

๐Ÿ”ปConfigure Agent Node

  1. Set the number of executors (parallel job executions) for the agent.

  2. In the "Remote root directory" field, specify the working directory on the agent.

  3. Under "Launch method," choose "Launch agent via SSH."

๐Ÿ”ปAdd Credentials

In the "Credentials" section, click on "Add" to provide SSH credentials for connecting to the agent. Use the private key associated with the EC2 instance.

๐Ÿ”ปSave and Connect

Save the agent configuration, and Jenkins will attempt to connect to the agent using the provided SSH credentials. Once connected, the agent status should change to "Online."

โš™๏ธTask-2: Running Jobs on the New Agent

Now that the agent is set up, you can run previous jobs on it, optimizing workload distribution. Follow these steps

๐Ÿ”ปUse Labels for Agent

  1. Edit the Jenkins job you want to run on the new agent.

  2. Under the "General" section, check the option "Restrict where this project can be run."

  3. Enter the label assigned to the new agent.

๐Ÿ”ปTrigger Builds on Agent

  1. Save the job configuration.

  2. Manually trigger a build or wait for the next scheduled build.

  3. Check the build console output to confirm that the job is being executed on the new agent.

By completing both tasks, you've successfully set up a Jenkins agent on an AWS EC2 instance, connected it to the master server, and configured jobs to run on the new agent, enhancing the scalability and efficiency of your Jenkins environment.

I think this blog will be quite valuable, offering unique viewpoints and introducing new and engaging ideas. ๐Ÿ™

๐Ÿ˜Š Happy learning!

More from this blog

๐Ÿš€ ๐——๐—ฎ๐˜† ๐Ÿญ ๐—ผ๐—ณ ๐— ๐˜† ๐Ÿณ-๐——๐—ฎ๐˜† ๐—”๐—ช๐—ฆ ๐—–๐—ต๐—ฎ๐—น๐—น๐—ฒ๐—ป๐—ด๐—ฒ ๐ŸŒŸ

Today, I kicked off my AWS Challenge with a deep dive into several fundamental concepts. Hereโ€™s what I covered: ๐Ÿท๏ธ ๐˜ผ๐™’๐™Ž ๐™‹๐™ง๐™ž๐™˜๐™ž๐™ฃ๐™œ ๐™ˆ๐™ค๐™™๐™š๐™ก๐™จ:AWS offers various pricing models to cater to different business needs: ๐Ÿญ) ๐—ข๐—ป-๐——๐—ฒ๐—บ๐—ฎ๐—ป๐—ฑ ๐—œ๐—ป...

May 22, 20242 min read
๐Ÿš€ ๐——๐—ฎ๐˜† ๐Ÿญ ๐—ผ๐—ณ ๐— ๐˜† ๐Ÿณ-๐——๐—ฎ๐˜† ๐—”๐—ช๐—ฆ ๐—–๐—ต๐—ฎ๐—น๐—น๐—ฒ๐—ป๐—ด๐—ฒ ๐ŸŒŸ

๐ŸŒŸ ๐—˜๐˜…๐—ฝ๐—น๐—ผ๐—ฟ๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—ž๐—ฒ๐˜† ๐—–๐—ผ๐—บ๐—ฝ๐—ผ๐—ป๐—ฒ๐—ป๐˜๐˜€ ๐—ผ๐—ณ ๐—ž๐˜‚๐—ฏ๐—ฒ๐—ฟ๐—ป๐—ฒ๐˜๐—ฒ๐˜€ ! ๐ŸŒŸ

Kubernetes is designed to automate the deployment, scaling, and operation of application containers. The architecture is divided into two main components: ๐™ˆ๐™–๐™จ๐™ฉ๐™š๐™ง and ๐™’๐™ค๐™ง๐™ ๐™š๐™ง. Hereโ€™s a detailed breakdown: ๐Ÿ”ถ๐™ˆ๐™–๐™จ๐™ฉ๐™š๐™ง ๐™‰๐™ค๐™™๐™š ๐˜พ๐™ค๐™ข๐™ฅ๐™ค๏ฟฝ...

May 19, 20242 min read
๐ŸŒŸ ๐—˜๐˜…๐—ฝ๐—น๐—ผ๐—ฟ๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—ž๐—ฒ๐˜† ๐—–๐—ผ๐—บ๐—ฝ๐—ผ๐—ป๐—ฒ๐—ป๐˜๐˜€ ๐—ผ๐—ณ ๐—ž๐˜‚๐—ฏ๐—ฒ๐—ฟ๐—ป๐—ฒ๐˜๐—ฒ๐˜€ ! ๐ŸŒŸ

โ›…๏ธImportant AWS Services: Part - 3

๐Ÿš€๐™€๐™ญ๐™˜๐™ž๐™ฉ๐™š๐™™ ๐™ฉ๐™ค ๐™จ๐™๐™–๐™ง๐™š ๐™ข๐™ฎ ๐™š๐™ญ๐™ฅ๐™š๐™ง๐™ฉ๐™ž๐™จ๐™š ๐™ž๐™ฃ ๐˜ผ๐™’๐™Ž ๐™ฌ๐™ž๐™ฉ๐™ ๐™– ๐™›๐™ค๐™˜๐™ช๐™จ ๐™ค๐™ฃ ๐™˜๐™ค๐™ฃ๐™ฉ๐™–๐™ž๐™ฃ๐™š๐™ง๐™ž๐™ฏ๐™–๐™ฉ๐™ž๐™ค๐™ฃ ๐™–๐™ฃ๐™™ ๐™™๐™š๐™ฅ๐™ก๐™ค๐™ฎ โ–ถ๏ธ๐—”๐—บ๐—ฎ๐˜‡๐—ผ๐—ป ๐—˜๐—น๐—ฎ๐˜€๐˜๐—ถ๐—ฐ ๐—ž๐˜‚๐—ฏ๐—ฒ๐—ฟ๐—ป๐—ฒ๐˜๐—ฒ๐˜€ ๐—ฆ๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฐ๐—ฒ (๐—˜๐—ž๐—ฆ): โ–ช๏ธFully managed Kuberne...

May 12, 20242 min read
โ›…๏ธImportant AWS Services: Part - 3

โ›…๏ธImportant AWS Services: Part - 2

โšœ๏ธ๐™„๐™ข๐™ฅ๐™ค๐™ง๐™ฉ๐™–๐™ฃ๐™ฉ ๐™ฌ๐™ž๐™™๐™š ๐™ง๐™–๐™ฃ๐™œ๐™š ๐™ค๐™› ๐˜ผ๐™’๐™Ž ๐™จ๐™š๐™ง๐™ซ๐™ž๐™˜๐™š๐™จ ๐™ฉ๐™๐™–๐™ฉ ๐™˜๐™–๐™ฃ ๐™š๐™ฃ๐™–๐™—๐™ก๐™š ๐™ฉ๐™ค ๐™–๐™ง๐™˜๐™๐™ž๐™ฉ๐™š๐™˜๐™ฉ ๐™จ๐™˜๐™–๐™ก๐™–๐™—๐™ก๐™š, ๐™จ๐™š๐™˜๐™ช๐™ง๐™š, ๐™–๐™ฃ๐™™ ๐™š๐™›๐™›๐™ž๐™˜๐™ž๐™š๐™ฃ๐™ฉ ๐™˜๐™ก๐™ค๐™ช๐™™ ๐™จ๐™ค๐™ก๐™ช๐™ฉ๐™ž๐™ค๐™ฃ๐™จ. ๐™ƒ๐™š๐™ง๐™š ๐™–๐™ง๐™š ๐™จ๐™ค๐™ข๐™š ๐™ ๐™š๐™ฎ ๐™จ๐™š๐™ง...

May 10, 20243 min read
โ›…๏ธImportant AWS Services: Part - 2

PratikM's Blog

49 posts