Adding Linux node to Jenkins

Before adding a slave node to the Jenkins master we need to prepare the node. We need to install Java on the slave node. Jenkins will install a client program on the slave node. To run the client program we need to install the same Java version we used to install on the Jenkins master

Install the Java packages
# sudo yum install java-1.8.0-openjdk

Create a user on the agent to be used by Jenkins
The new user will be called Jenkins with /var/lib/jenkins as the home directory

# sudo useradd -d /var/lib/jenkins jenkins
useradd: user 'jenkins' already exist
# passwd jenkins

Generating an ssh key
Log in to the Jenkins master node and create an ssh key-pair
# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:4/GaQMNCRrtKhBPfC179bx5s1DD1kCRVwRnQiWuKtL8 root@zippyops
The key's randomart image is:
+---[RSA 2048]----+
|.   .     .o*B+= |
| + o o     ooo=  |
|o + * .   o  ..  |
| + = + ..  +o    |
|  o + +.So.o.    |
| . . o ooB.      |
|  .   . ..B      |
|       . *..     |
|        o E.     |
+----[SHA256]-----+

Copy the content and log in to the slave node. Add the copied content to authorized_keys
# vi .ssh/authorized_keys

From the master ssh to the slave node. It will ask to accept the ssh fingerprint, type yes and enter. If you haven’t done anything wrong you should be able to ssh into the slave node

Adding the slave node to the master
Log in to the Jenkins console via the browser and click on "Manage Jenkins" and scroll down to the bottom. From the list click on "Manage Nodes". In the new window click on "New Node".


Manage Nodes
Give a name to the node, select "Permanent Agent" and click on OK

Now the user needs to provide the necessary configurations, Directory (path in slave node where to deploy files from master), Labels, Credentials, etc

Provide the necessary

*Descriptions 

*Executors (Default as 1)

*Remote root Directory (directory dedicated to Jenkins Master) = /var/lib/jenkins

*Labels(used to group multiple agents into one logical group) = Java8

*Usage: Use node as much as possible

*Launch method (launch Via SSH)

*Host(specify the IP address of the Node)

*Credentials Click ADD -> Jenkins Now Provide the User name and password of the Slave node

*Click the Drop Down box and click on your Username (example: zippyops/*****)

*Host key Verification Strategy: Give it as (Manual provided Verification Strategy). A blank space appears asking for an SSH key.  For that(follow next step)* 

*Goto Slave node

# vi /etc/ssh/ssh_ecdsa_key.pub 

*Paste the key in the SSH key section

*Once completed Click on the Save icon to Save the Configurations

After that, the page will display the list of nodes with the Master node. But shows that the node created is offline. Now Click on the Ubuntu slave node

Click on the Launch agent to initialize the Ubuntu Slave Node

Once the message results Agent successfully connected and online then your node is ready to process

After it, the user can view the node connected in the list of Nodes with Master

Once the node is connected you can send files to perform functions in the node through master




Relevant Blogs:

Blue ocean dashboard in Jenkins  

Basics of Jenkins 

Rolling update in kubernetes 

Zabbix Custom scripts



Recent Comments

No comments

Leave a Comment