Hi,
As you already know Jenkins architecture is based on master slave architecture.This is useful and best practice to add slave/nodes to Jenkins master for many purposes such as security (avoid malicious code on the master for example and also to spread the charge and preserve Jenkins master performances and health.)

some definitions

  • The Jenkins Master is the Jenkins service itself.It is a webserver that also acts as a “brain” for deciding how, when and where to run tasks.
  • A node is a server where Jenkins runs jobs on executors.
  • The agent is the tool that manages the executors on a remote node, on behalf of Jenkins.
    Note that the Jenkins master also runs on a node.

define your node

  • go to Manage Jenkins → Managed Nodes and cloud

  • add your node by selecting new node

  • insert your node name, select permanent agent then select OK
  • add number of executors and your remote root directory,you can add a label*

  • to add a Linux machine you can select your authentication method , here we will add ssh connection with user and password

  • what is an executor?

check Jenkins site for more components definitions:
https://www.jenkins.io/
An executor is a slot for execution of work defined by a Pipeline or Project on a Node. A Node may have zero or more Executors configured which corresponds to how many concurrent Projects or Pipelines are able to execute on that Node.
We can compare it as a single process ID that will execute the builds ( best practice is to define one executor by core on the slave machine,note: on the master best practice is to set the number of executor to 0 to avoid any build to be triggered on it)

  • click on your new node, we will configure it

create the directory on your node

[root@serveurctmv900 workspace]# pwd
/home/jenkins/workspace
[root@serveurctmv900 workspace]#

we can select many ways to add an agent

  • install the java agent on your node by clicking on the link
  • install the Jenkins remoting agent when the java popup appears*

*Important: seems to be not working on current Jenkins versions ( mine was working as you can see ),some people kindly gave me a feedback on it so I guess the best to define your node is to make an installation with credentials as we will see further on that post , you can check also users feedback regarding that topic following the above link
https://wiki.jenkins.io/display/JENKINS//Step+by+step+guide+to+set+up+master+and+agent+machines+on+Windows

  • Here we are ,agent is now connected on Jenkins master

  • Below a screen of node defined and running on a Linux machine

  • we can see now agent up and running in the Jenkins master node manager

Define your node to be connected with ssh and add credentials

When you add a new node you can select the connexion method, here we will select with credential and connect by SSH
Select launch agent by Ssh and add your credentials created in your Jenkins vault:


launch your agent and check if connexion is now possible:

— here we see that node is UP in node manager:

— and also the log indicate that agent is now connected

Connexion by ssh key

In that case you can create a key pair and add it in your credential vault to allow ssh connexion

add the public key manually in node’s configuration

launch the slave it should connected now in SSH as displayed on the log

Define your node in a Build or Pipeline to be used

  • You can now chose to perform your builds on this node or on all nodes of your label(*group of node ofr example here we used label named linux ),you have to select it in build options.

Conclusion

Now you know how to define nodes on your Jenkins master ,there are many options to configure them so you can test it,feel free to check dbi bloggers for new topic!