> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Create and Configure Node

> This tutorial demonstrates how to create and configure a Jenkins node to enhance build execution scalability and performance.

This tutorial shows how to offload build execution from your Jenkins controller to a dedicated agent (node), improving scalability and performance. We’ll provision an Ubuntu VM (`ubuntu-docker-jdk17-node20`) and connect it as a Jenkins agent using JNLP.

## Prerequisites

* A running Jenkins controller ([installation guide](https://www.jenkins.io/doc/))
* A VM with a matching JDK installed
* Network connectivity between controller and agent

## 1. Add a New Node in Jenkins

1. On the Jenkins controller, go to **Manage Jenkins** → **Manage Nodes and Clouds**.
2. Click **New Node**, enter a name (e.g., `Ubuntu-Agent`), select **Permanent Agent**, and **OK**.

<Frame>
  ![The image shows a Jenkins dashboard displaying node information, including architecture, clock difference, and disk space details. The interface is dark-themed with options to manage nodes and configure monitors.](https://kodekloud.com/kk-media/image/upload/v1752870292/notes-assets/images/Certified-Jenkins-Engineer-Demo-Create-and-Configure-Node/jenkins-dashboard-node-info-dark.jpg)
</Frame>

3. Fill in the node configuration:

| Field                 | Purpose                                                    | Example                                                     |
| --------------------- | ---------------------------------------------------------- | ----------------------------------------------------------- |
| Description           | Brief summary of this agent’s role                         | `Ubuntu build executor`                                     |
| # of Executors        | Max concurrent builds this agent can run                   | `2`                                                         |
| Remote Root Directory | Directory on the agent for workspaces, logs, and artifacts | `/home/jenkins-agent`                                       |
| Labels                | Tags for targeting in jobs or pipelines                    | `docker jdk17 ubuntu`                                       |
| Usage                 | Restrict builds to labels matching this node               | `Only build jobs with label expressions matching this node` |
| Launch method         | How the agent connects (e.g., JNLP)                        | `Launch agent by connecting from the controller`            |
| Availability          | Agent online policy                                        | `Keep this agent online as much as possible`                |

<Frame>
  ![The image shows a Jenkins configuration page for creating a new node, with fields for description, number of executors, remote root directory, and labels.](https://kodekloud.com/kk-media/image/upload/v1752870294/notes-assets/images/Certified-Jenkins-Engineer-Demo-Create-and-Configure-Node/jenkins-new-node-configuration.jpg)
</Frame>

<Callout icon="lightbulb" color="#1CB2FE">
  Under **Node Properties**, you can add environment variables or enable disk space monitoring to maintain agent health.
</Callout>

<Frame>
  ![The image shows a Jenkins dashboard interface with node properties settings, including disk space monitoring thresholds and environment variables. There are options to add variables and save changes.](https://kodekloud.com/kk-media/image/upload/v1752870295/notes-assets/images/Certified-Jenkins-Engineer-Demo-Create-and-Configure-Node/jenkins-dashboard-node-properties-settings.jpg)
</Frame>

4. Click **Save**. The agent remains **offline** until it connects to the controller.

## 2. Enable TCP Inbound Agent Port

1. Navigate to **Manage Jenkins** → **Configure Global Security**.
2. Under **Agents** → **TCP port for inbound agents**, select **Fixed** or **Random**.
3. Click **Save**.

## 3. Connect the Agent from the Command Line

On the agent VM (`ubuntu-docker-jdk17-node20`):

```shell theme={null}
# Go to a working directory
cd /home

# Download the Jenkins agent JAR
curl -sO http://<JENKINS_HOST>:8080/jnlpJars/agent.jar

# (Optional) Store the agent secret securely
echo <SECRET_TOKEN> > secret-file
chmod 600 secret-file

# Launch the agent with JNLP
java -jar agent.jar \
  -url http://<JENKINS_HOST>:8080/ \
  -secret @secret-file \
  -name "ubuntu-agent" \
  -workDir "/home/jenkins-agent"
```

<Callout icon="triangle-alert" color="#FF6B6B">
  Keep the `secret-file` secure. Exposing the JNLP secret allows unauthorized agents to connect.
</Callout>

A successful connection shows:

```text theme={null}
INFO: Connected
Inbound agent connected from 165.233.191.207:55522
This is a Unix agent
Agent successfully connected and online
```

## 4. Verify the Agent in Jenkins

Return to **Manage Nodes and Clouds** and confirm `Ubuntu-Agent` is **online**:

<Frame>
  ![The image shows a Jenkins interface displaying system information for an "ubuntu-agent," with options to view system properties, environment variables, and other details. The sidebar includes various menu options like status, configure, and log.](https://kodekloud.com/kk-media/image/upload/v1752870296/notes-assets/images/Certified-Jenkins-Engineer-Demo-Create-and-Configure-Node/jenkins-ubuntu-agent-interface.jpg)
</Frame>

Use [JavaMelody Monitoring](https://javamelody.github.io/) for system reports:

<Frame>
  ![The image shows a Jenkins dashboard with JavaMelody Monitoring options for system reports and actions on an "ubuntu-agent" node. It includes options like viewing threads, OS processes, memory histograms, and executing system actions.](https://kodekloud.com/kk-media/image/upload/v1752870297/notes-assets/images/Certified-Jenkins-Engineer-Demo-Create-and-Configure-Node/jenkins-dashboard-javamelody-monitoring.jpg)
</Frame>

## 5. Inspect the Agent Workspace

On the agent VM:

```shell theme={null}
root@ubuntu-docker-jdk17-node20:/home# ls
agent.jar  jenkins-agent

root@ubuntu-docker-jdk17-node20:/home# cd jenkins-agent
root@ubuntu-docker-jdk17-node20:/home/jenkins-agent# ls
remoting
```

As builds run, Jenkins creates `workspaces`, `logs`, and `artifacts` directories under `/home/jenkins-agent`.

Next, we’ll run a sample job on this agent to demonstrate distributed execution.

## Links and References

* [Jenkins Documentation](https://www.jenkins.io/doc/)
* [Jenkins JNLP Agents](https://www.jenkins.io/doc/book/using/remote-agents/)
* [JavaMelody](https://javamelody.github.io/)
* [Jenkins CLI & Remoting](https://www.jenkins.io/doc/book/managing/cli/)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/certified-jenkins-engineer/module/2175ebff-1a0f-4c0f-90ea-04e5fa96956f/lesson/34e5d199-7df1-4413-a04c-e9407edaee06" />
</CardGroup>
