How to build a basic 2 nodes Jenkins architecture on AWS
…or how to start dealing with distributed builds mode…
A single instance of Jenkins may not be sufficient when dealing with several projects where different builds are performed by different teams during the day.
Luckily it is possible to remedy this drawback by adding one or more
slave nodes within our architecture.
A slave node is an instance configured to automate execution on behalf of the master node and will handle heavy work by letting the master node perform basic operations (including the GUI part).
In this tutorial I will explain to you in a very simple and fast way how to configure a basic two nodes architecture on AWS cloud.
For this PoC i launched two Centos 7- t2small instances with 8gb EBS volume on AWS (remember that you’ll need a public ip or an elastic ip in order to download the software we need).
So, if the subnet where you’re launching your instances is set up by default to not release an ip public, just keep in mind that you’ll have to change the subnet settings or — better — associate an elastic ip to the instances.
IMPORTANT: you need to configure a security group to allow ssh connection (tcp, port 22) in order to allow the communication between the two nodes.
Once you have 2 instances up and running we can proceed configuring the master node:
STEP 1 — MASTER NODE
- Connect via ssh to the master instance
- Perform the following steps in order to install the components we need (Java and Jenkins):
- Install Java 8 (current version of Jenkins doesn’t support Java 10 and 11. So if you have multiple installations of Java on your server(s) make sure Java 8 is the default one:
sudo yum install java-1.8.0-openjdk-devel
- Enable Jenkins repo by importing the GPG key:
curl --silent --location http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo | sudo tee /etc/yum.repos.d/jenkins.repo
- Add the repo to your ec2 instance:
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
- Now we can install Jenkins on our master node:
sudo yum install jenkins -y
- Then we can start the service:
sudo systemctl start jenkins
- … check if the service is running properly:
systemctl status jenkins
- Last but not least… enable Jenkins to start on every system boot:
sudo systemctl enable jenkins