Setup of jenkins master agent and slave agent on AWS ec2 instance¶
Introduction¶
In the realm of continuous integration and deployment, Jenkins stands as a powerful automation tool that streamlines the software development process. By leveraging Jenkins Master and Slave agents, you can distribute workloads across multiple nodes, optimizing performance and scalability. This step-by-step guide is designed to walk you through the process of setting up Jenkins Master and Slave agents on AWS EC2 instances.
Problem Statement¶
Many software development teams face challenges in optimizing their continuous integration and deployment workflows. This guide aims to address the complexities involved in setting up Jenkins Master and Slave agents on AWS EC2 instances, providing solutions for efficient and scalable automation in cloud-based environments.
Prerequisites¶
- Launch 2 AWS ec2 instances for jenkins master and slave agent.
- Create a security group that allows inbound traffic from ssh, http, https, and custom tcp from port 8080 and apply this to both ec2 instances.
Jenkins Master-Agent Creation¶
Step 1: Installation of Jenkins¶
- Ensure that your software packages are up to date on your instance by using the following command to perform a quick software update:
- Add the Jenkins repo using the following command:
- Import a key file from Jenkins-CI to enable installation from the package:
- Install Java (Amazon Linux 2023):
- Install Jenkins:
- Enable the Jenkins service to start at boot:
- Start Jenkins as a service:
- You can check the status of the Jenkins service using the command:
Step 2: Configuring Jenkins to create a master agent on ec2¶
- Connect to http://
:8080 from your browser. You will be able to access Jenkins through its management interface: - As prompted, enter the password found in /var/lib/jenkins/secrets/initialAdminPassword.
- Once the installation is complete, the Create First Admin User will open. Enter your information, and then select Save and Continue.
- On the left-hand side, select Manage Jenkins, and then select Manage Plugins.
- Select the Available tab, and then enter Amazon EC2 plugin at the top right.
- Select the checkbox next to Amazon EC2 plugin, and then select Install without restart.
Step 3: Verify your master agent as build-in-node and it is in synched¶
Jenkins Slave-Agent Creation¶
Step 1: Refer this step in order to install jenkins¶
Step 2: Create a Node.¶
- Go under manage Jenkins section from dashboard -> Select Nodes -> Create a new node and give it a name and choose as Permanent Type.
Step 3: Configuring Node¶
- Give host as Public ip of your slave ec2 instance and in credentials click on Add.
- Enter private key of slave-agent ec2.
- In host key verification strategy select non verifying.
- Save.
Step 4: You will see that your agent will be in sync .¶
Conclusion:¶
In wrapping up, you've successfully established a robust Jenkins infrastructure on AWS EC2, empowering your team with efficient and scalable CI/CD capabilities. With Master and Slave agents configured, you're poised to accelerate development cycles and enhance overall software delivery. Cheers to a streamlined and automated workflow!