Services DevOps DevSecOps Cloud Consulting Infrastructure Automation Managed Services AIOps MLOps DataOps Microservices 🔐 Private AINEW Solutions DevOps Transformation CI/CD Automation Platform Engineering Security Automation Zero Trust Security Compliance Automation Cloud Migration Kubernetes Migration Cloud Cost Optimisation AI-Powered Operations Data Platform Modernisation SRE & Observability Legacy Modernisation Managed IT Services 🔐 Private AI DeploymentNEW Products ✨ ZippyOPS AINEW 🛡️ ArmorPlane 🔒 DevSecOpsAsService 🖥️ LabAsService 🤝 Collab 🧪 SandboxAsService 🎬 DemoAsService Bootcamp 🔄 DevOps Bootcamp ☁️ Cloud Engineering 🔒 DevSecOps 🛡️ Cloud Security ⚙️ Infrastructure Automation 📡 SRE & Observability 🤖 AIOps & MLOps 🧠 AI Engineering 🎓 ZOLS — Free Learning Company About Us Projects Careers Get in Touch

How to Add a Slave Node to Jenkins Master

How to Add a Slave Node to Jenkins Master: A Step-by-Step Guide

When setting up Jenkins for distributed builds, adding a slave node to the Jenkins master is essential for efficient processing. In this guide, we’ll walk you through the entire process of configuring and connecting a slave node to Jenkins. This includes installing Java, setting up SSH, and completing necessary configurations.

By following these steps, you can scale your Jenkins environment and ensure smoother, more efficient build pipelines.

Jenkins slave node setup and configuration process

Preparing the Slave Node for Jenkins

Before connecting the slave node to the Jenkins master, you must prepare the node by installing Java and configuring the necessary user. Jenkins requires the same Java version to run both on the master and the node.

1. Install Java on the Slave Node

Jenkins relies on Java to run, so the first step is to install the same Java version used on the master. To install Java 1.8, use the following command:

sudo yum install java-1.8.0-openjdk

2. Create a Jenkins User on the Slave Node

For Jenkins to interact securely with the slave node, you’ll need to create a new user dedicated to Jenkins. The user will have /var/lib/jenkins as the home directory.

sudo useradd -d /var/lib/jenkins jenkins
passwd jenkins

Ensure the new user has the necessary permissions to execute Jenkins operations.

Generate and Configure SSH Keys

Jenkins uses SSH for secure communication between the master and the slave. You’ll need to generate an SSH key on the master and copy it to the slave node.

3. Generate SSH Key on the Jenkins Master

Log in to the Jenkins master node and generate an SSH key pair. Run the following command:

ssh-keygen

Follow the prompts to create the key pair. Once complete, you’ll find your private and public keys in /root/.ssh/. The output should resemble this:

Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.

4. Copy the SSH Key to the Slave Node

Now that you’ve generated the SSH key, you need to copy the public key to the slave node. On the master, use cat to display the public key:

cat /root/.ssh/id_rsa.pub

Log in to the node and append the public key to the authorized_keys file:

vi ~/.ssh/authorized_keys

Once the key is copied, try SSHing into the node from the master to ensure the connection is successful.

ssh jenkins@<slave-node-ip>

5. Test the SSH Connection

If everything is set up correctly, when you try to SSH into the slave node from the Jenkins master, you should be asked to confirm the SSH fingerprint. Type “yes” to accept the fingerprint, and the connection should be established.

Adding the Slave Node to Jenkins Master

After the slave node is configured and SSH is working, you can now add it to your Jenkins master.

6. Add the Slave Node to Jenkins

  1. Log in to the Jenkins web interface.
  2. Go to “Manage Jenkins” and click on “Manage Nodes.”
  3. Click on “New Node.”
  4. Enter a name for the node, select “Permanent Agent,” and click “OK.”

7. Configure the Node

You’ll now need to provide the following configuration details for the slave node:

  • Description: Optional, but helpful for identification.
  • Executors: Set this to 1 (or more depending on your needs).
  • Remote Root Directory: Use /var/lib/jenkins, which is the home directory for Jenkins.
  • Labels: You can use a label like Java8 to identify the node.
  • Usage: Choose “Use this node as much as possible” to allow Jenkins to schedule jobs on the node when needed.
  • Launch Method: Select “Launch via SSH.”
  • Host: Enter the IP address of the slave node.
  • Credentials: Add the Jenkins user credentials for SSH access.

8. Add SSH Key to Jenkins Configuration

To complete the setup, paste the SSH public key into the “Host Key Verification Strategy” section under “Manual Verification.” You can find the public key on the slave node by running:

vi /etc/ssh/ssh_ecdsa_key.pub

Copy the content and paste it into Jenkins.

Once these settings are complete, click “Save.”

Launch the Slave Node Agent

After saving the configuration, the node will appear in the list of nodes but will initially show as “offline.” To start the slave agent:

  1. Click on the slave node in the Jenkins interface.
  2. Click “Launch agent” to begin the connection process.

Once the message “Agent successfully connected” appears, your node is ready to process Jenkins jobs.

Conclusion: Scaling Your Jenkins with Nodes

By following this guide, you’ve successfully added a node to your Jenkins master. This setup allows Jenkins to distribute workloads efficiently across multiple nodes, improving build performance and scalability.

If you’re looking to optimize your DevOps pipeline further, ZippyOPS offers consulting, implementation, and managed services for a variety of automation processes including DevOps, DevSecOps, DataOps, Cloud, and AIOps. Learn more about how ZippyOPS can help streamline your operations on ZippyOPS Services and explore tailored solutions on ZippyOPS Solutions.

For expert support in managing Jenkins or scaling your operations, contact us at sales@zippyops.com.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top