Jenkins Master Slave Configuration
Published on

Jenkins Master Slave Configuration

Authors

Prerequisites

  • Establish a setup for two servers. One is for control node and the other one is for the subordinate node.
  • Set up Java on the control node.
  • Install Jenkins onto the control node.
  • Make sure the subordinate node has the identical Java version as the control node.
  • Create a user and SSH keys on the subordinate node.
  • Copy keys on to the control node
  • Config the subordinate node with the agent code.

Configuring the Master Node for a Jenkins Master-Slave Configuration setup

  • Take Linux servers. One is for control node, and the other one is for subordinate node.
  • The first step is to establish a Jenkins server on the control node and subordinate node we need to configure later.
  • Install Jenkins on control node
  • Login to Jenkins control node
/static/images/posts/devops/jenkins-master-slave/login.png
  • Once you login to Jenkins UI dashboard with your credentials, you will see the Jenkins dashboard as shown below.
  • Click on Manage Jenkins
/static/images/posts/devops/jenkins-master-slave/manage.png
  • Then click on Nodes
/static/images/posts/devops/jenkins-master-slave/node.png
  • In the Nodes page click on + New Node to create a new node.
/static/images/posts/devops/jenkins-master-slave/newnode.png
  • Create a new slave Jenkins with some name and type select as Permanent Agent then click on Create
/static/images/posts/devops/jenkins-master-slave/slave.png
  • Enter the details for Agent node
/static/images/posts/devops/jenkins-master-slave/path.png
  • Give the details like description, name and no of executors
    • Remote root directory and labels
    • Label are helpful in running jobs on specific nodes based on the labels
    • Remote root directory and give the path
/static/images/posts/devops/jenkins-master-slave/web.png
  • Use WebSocket and to fill in the details as for the project requirement

  • Then click on Save

  • In Nodes we see our new subordinate node, which we created now.

/static/images/posts/devops/jenkins-master-slave/agent.png

Now that we have created a slave node, we need to configure the slave node to connect to the master node.

Configuring the Slave Node Jenkins

Connect to the server via SSH. I'm using the EC2 instance for the slave node.

/static/images/posts/devops/jenkins-master-slave/slave-server.png

Now lets run the following commands to update the server and install Java.

sudo yum update -y

To check if Java is installed or not, use the following command.

# Get the java installed version
java --version

If Java is not installed, you can install it using the following command. We will be using OpenJDK 17.

sudo yum install fontconfig java-17-openjdk
sudo amazon-linux-extras install java-openjdk17
/static/images/posts/devops/jenkins-master-slave/ssh.png

Open slave node in Jenkins UI which we have created earlier. We can see the Run commands for the slave node.

Run those commands in slave node terminal. Then we will see the slave node is connected to master node.

/static/images/posts/devops/jenkins-master-slave/agent-cmd.png

INFO: CONNECTED we can see in terminal

/static/images/posts/devops/jenkins-master-slave/connect.png

Now the Agent node is ready to run the jobs.

Conclusion

I trust that this post has improved your understanding of working with Jenkins Master Slave configuration. Jenkins is currently the most popular tool used in the CI/CD process across all projects.