π₯οΈ Permanent Compute Nodes: Building Persistent, Dedicated Worker Fleets
While containerized ephemeral pods on Kubernetes represent the modern cloud-native paradigm for microservices, enterprise delivery platforms still rely extensively on Permanent Static Build Agents. Workloads that require specialized native hardware (such as Apple Silicon macOS nodes for iOS/Xcode compilation, dedicated GPU rigs for AI/ML inference pipelines, physical embedded test benches, or legacy Windows .NET Framework systems) must be provisioned as long-lived, high-capacity worker nodes. Integrating a static node into a Jenkins cluster follows two primary architectural launch topologies: Outbound SSH Agents (where the controller initiates an encrypted SSH session to launch remoting) and Inbound JNLP/WebSocket Agents (where the agent initiates a reverse tunnel back to the controller). This guide details the complete provisioning lifecycle across Linux and Windows environments.
STATIC AGENT CONNECTION MODES & DIRECTIONALITY:
1. OUTBOUND LAUNCH TOPOLOGY (SSH BUILD AGENTS):
Controller initiates connection β Agent listens on Port 22
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β JENKINS CONTROLLER β β STATIC LINUX / MAC β
β β β AGENT WORKER NODE β
β β’ SSH Build Agents Plugin β SSH (Port 22 / TCP) β β’ OpenSSH Server (sshd) β
β β’ Private SSH Key Store β βββββββββββββββββββββΊ β β’ Dedicated jenkins user β
β β’ Uploads remoting.jar β β β’ OpenJDK 17/21 Runtime β
β β’ Spawns slave JVM processβ β β’ /var/jenkins workspace β
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β’ Requirement: Controller must have direct IP routing and firewall access to Port 22 on Agent.
β’ Operating Systems: Linux (Ubuntu, Debian, RHEL, Rocky), macOS, BSD.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. INBOUND LAUNCH TOPOLOGY (JNLP / WEBSOCKET REVERSE TUNNEL):
Agent initiates connection β Controller listens on Port 8080/443 (or TCP 50000)
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β STATIC WORKER NODE β β JENKINS CONTROLLER β
β (Linux / Windows / Mac) β β β
β β HTTPS / WebSocket β β’ Web UI & API (Port 443) β
β β’ agent.jar / remoting β βββββββββββββββββββββΊ β β’ Inbound Agent Listener β
β β’ Node Secret (HMAC-SHA) β (Port 443 or 50000) β β’ Verifies Cryptographic β
β β’ Runs as System Service β β Node Secret String β
βββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββ
β’ Requirement: Worker node requires only outbound HTTPS (Port 443) egress to Controller.
β’ Ideal For: Agents located behind corporate NAT, strict egress firewalls, or Windows Server.
TOPOLOGY DECISION MATRIX:
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β CHARACTERISTIC β OUTBOUND SSH LAUNCHER β INBOUND WEBSOCKET LAUNCHER β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ€
β Connection Initiator β Controller connects to Agent β Agent connects to Controller β
β Agent Firewall Ports β Port 22/TCP MUST be open β Zero inbound ports open (NAT)β
β Controller Port Need β None (standard local socket) β Port 8080/443 (HTTP/WS) β
β OS Native Target β Linux / macOS / Unix β Windows / Cross-Platform β
β Lifecycle Control β Controller auto-reboots node β Node service manages restart β
β Setup Complexity β Low (Controller pushes jar) β Medium (Manual bootstrap/svc)β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ
#!/usr/bin/env bash
# ==============================================================================
# Host Baseline Setup for Dedicated Linux Jenkins Worker Node
# Run with root/sudo privileges on target agent host (Ubuntu/Debian/RHEL)
# ==============================================================================
set -euo pipefail
echo "[*] Step 1: Installing OpenJDK 17 LTS, OpenSSH server, and build utilities..."
if command -v apt-get > /dev/null; then
sudo apt-get update -y
sudo apt-get install -y openjdk-17-jdk openssh-server curl git tar unzip build-essential
elif command -v dnf > /dev/null; then
sudo dnf install -y java-17-openjdk java-17-openjdk-devel openssh-server curl git tar gcc gcc-c++
fi
echo "[*] Step 2: Creating unprivileged dedicated 'jenkins' system user..."
# Enforce predictable UID/GID 1000 for cross-container alignment
if ! id -u jenkins > /dev/null 2>&1; then
sudo useradd -m -d /home/jenkins -s /bin/bash -u 1000 jenkins
echo "[+] Created user 'jenkins' (UID 1000)."
else
echo "[!] User 'jenkins' already exists."
fi
echo "[*] Step 3: Provisioning dedicated remote workspace directory..."
sudo mkdir -p /var/jenkins
sudo chown -R jenkins:jenkins /var/jenkins
sudo chmod -R 775 /var/jenkins
echo "[*] Step 4: Configuring SSH directory and authorized_keys..."
sudo -u jenkins mkdir -p /home/jenkins/.ssh
sudo -u jenkins chmod 700 /home/jenkins/.ssh
sudo -u jenkins touch /home/jenkins/.ssh/authorized_keys
sudo -u jenkins chmod 600 /home/jenkins/.ssh/authorized_keys
echo "[*] Step 5: Verifying Java version compliance..."
sudo -u jenkins java -version
echo "[β] Host provisioning complete. Ready for SSH public key injection."
# ==============================================================================
# Executed on Jenkins Controller (or Administrator Terminal)
# ==============================================================================
# 1. Generate dedicated Ed25519 key pair without passphrase
ssh-keygen -t ed25519 -C "jenkins-controller-to-static-agent" -f ~/.ssh/id_ed25519_jenkins_agent -N ""
# 2. Append the public key to the target agent node's authorized_keys
AGENT_IP="192.168.1.150"
ssh-copy-id -i ~/.ssh/id_ed25519_jenkins_agent.pub jenkins@${AGENT_IP}
# 3. Test manual SSH connection as the jenkins user
ssh -i ~/.ssh/id_ed25519_jenkins_agent jenkins@${AGENT_IP} "java -version"
CONFIGURING THE SSH AGENT IN THE JENKINS DASHBOARD:
1. Register Private Key Credential:
β’ Navigate to: Manage Jenkins β Credentials β System β Global credentials β Add Credentials.
β’ Kind: SSH Username with private key
β’ ID: static-agent-ssh-key
β’ Username: jenkins
β’ Private Key: Select "Enter directly" β Paste contents of ~/.ssh/id_ed25519_jenkins_agent
β’ Click "Create".
2. Create New Node:
β’ Navigate to: Manage Jenkins β Nodes β "New Node".
β’ Node name: linux-static-builder-01
β’ Type: Permanent Agent β Click "Create".
3. Configure Node Settings:
β’ Number of executors: 4 (Determines concurrent build slots; matches physical CPU cores)
β’ Remote root directory: /var/jenkins
β’ Labels: linux-x86 high-spec docker-host
β’ Usage: Only build jobs with label expressions matching this node
β’ Launch method: "Launch agents via SSH"
- Host: 192.168.1.150
- Credentials: Select "jenkins (static-agent-ssh-key)"
- Host Key Verification Strategy: Known hosts file Verification Strategy
(or "Manually trusted key Verification Strategy")
- Port: 22
β’ Availability: Keep this agent online as much as possible
β’ Click "Save".
#!/usr/bin/env bash
# ==============================================================================
# Inbound WebSocket Agent Automation Script (Linux Systemd Integration)
# ==============================================================================
set -euo pipefail
JENKINS_URL="https://jenkins.company.com/"
NODE_NAME="linux-inbound-agent-01"
# Retrieve the 64-character secret from: Node Dashboard β Status
NODE_SECRET="a8f3b21c4e90d782194b1234567890abcdef1234567890abcdef1234567890ab"
AGENT_DIR="/var/jenkins"
sudo mkdir -p "${AGENT_DIR}"
cd "${AGENT_DIR}"
echo "[*] Step 1: Downloading canonical agent.jar from Controller..."
sudo curl -fsSL -o "${AGENT_DIR}/agent.jar" "${JENKINS_URL}jnlpJars/agent.jar"
sudo chown -R jenkins:jenkins "${AGENT_DIR}"
echo "[*] Step 2: Creating Systemd Service Unit for Auto-Recovery on Boot..."
sudo tee /etc/systemd/system/jenkins-agent.service > /dev/null << EOF
[Unit]
Description=Jenkins Inbound Worker Agent Daemon
After=network.target network-online.target
Wants=network-online.target
[Service]
Type=simple
User=jenkins
Group=jenkins
WorkingDirectory=${AGENT_DIR}
ExecStart=/usr/bin/java -jar ${AGENT_DIR}/agent.jar \\
-url ${JENKINS_URL} \\
-secret ${NODE_SECRET} \\
-name ${NODE_NAME} \\
-workDir ${AGENT_DIR} \\
-webSocket
Restart=always
RestartSec=10
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
EOF
echo "[*] Step 3: Enabling and launching systemd service..."
sudo systemctl daemon-reload
sudo systemctl enable --now jenkins-agent.service
echo "[*] Step 4: Inspecting active connection status..."
sudo systemctl status jenkins-agent.service --no-pager
# ==============================================================================
# Run inside Administrator PowerShell on Windows Server 2019 / 2022
# ==============================================================================
$ErrorActionPreference = "Stop"
$JenkinsUrl = "https://jenkins.company.com/"
$NodeName = "windows-build-agent-01"
$NodeSecret = "b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0"
$WorkDir = "C:\Jenkins"
# Create target directories
New-Item -ItemType Directory -Force -Path $WorkDir
Set-Location $WorkDir
Write-Host "[*] Step 1: Downloading agent.jar from Controller..."
Invoke-WebRequest -Uri "$($JenkinsUrl)jnlpJars/agent.jar" -OutFile "$WorkDir\agent.jar"
Write-Host "[*] Step 2: Downloading WinSW (Windows Service Wrapper) executable..."
$WinSWUrl = "https://github.com/winsw/winsw/releases/download/v2.12.0/WinSW-x64.exe"
Invoke-WebRequest -Uri $WinSWUrl -OutFile "$WorkDir\jenkins-agent.exe"
Write-Host "[*] Step 3: Generating WinSW XML configuration definition..."
$XmlContent = @"
<service>
<id>jenkins-agent</id>
<name>Jenkins Inbound Agent</name>
<description>Maintains persistent WebSocket connection to Jenkins Controller</description>
<executable>java.exe</executable>
<arguments>-Xrs -jar "$WorkDir\agent.jar" -url $JenkinsUrl -secret $NodeSecret -name $NodeName -workDir "$WorkDir" -webSocket</arguments>
<logmode>rotate</logmode>
<onfailure action="restart" delay="10 sec"/>
</service>
"@
Set-Content -Path "$WorkDir\jenkins-agent.xml" -Value $XmlContent
Write-Host "[*] Step 4: Registering and starting Windows Service..."
& "$WorkDir\jenkins-agent.exe" install
Start-Service -Name "jenkins-agent"
Write-Host "[β] Service installed and running successfully."
Get-Service -Name "jenkins-agent"
// 1. DECLARATIVE PIPELINE: Complex Boolean Label Expression
pipeline {
agent {
node {
// Evaluates labels across static inventory:
// Must have 'linux-x86' AND 'high-spec', but must NOT have 'legacy'
label 'linux-x86 && high-spec && !legacy'
}
}
stages {
stage('Compile Heavy C++ Application') {
steps {
echo "[*] Assigned to Static Worker: ${env.NODE_NAME}"
sh 'make -j$(nproc)'
}
}
}
}
// βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// 2. SCRIPTED PIPELINE: Allocating Static Node Block
node('windows-build-agent-01') {
stage('Compile .NET Framework') {
echo "Running on dedicated Windows node: ${env.NODE_NAME}"
bat 'msbuild.exe Solution.sln /p:Configuration=Release'
}
}
DIAGNOSTIC SCENARIOS & REMEDIATIONS:
1. AGENT MARKED OFFLINE: "Disk space is too low"
β’ Symptom: Jenkins automatically marks the node offline with a red warning badge.
β’ Cause: Jenkins disk space monitor (Node Monitoring) detects available space dropped
below the configured threshold (default: 1 GB).
β’ Remediation:
- Clear stale workspaces on agent: sudo rm -rf /var/jenkins/workspace/*
- Purge untracked Docker objects: docker system prune -af --volumes
- Adjust threshold if needed under: Manage Jenkins β Nodes β Configure Monitors.
2. ERROR: "Connection refused" or "Authentication failed (Auth cancel)" via SSH:
β’ Log: [SSH] Opening SSH connection... Authentication failed.
β’ Cause: The public key in /home/jenkins/.ssh/authorized_keys does not match the private
key registered in Jenkins Credentials, or permissions are too open.
β’ Fix: Ensure strict Linux filesystem permissions:
chmod 700 /home/jenkins/.ssh && chmod 600 /home/jenkins/.ssh/authorized_keys
3. INBOUND AGENT DROPPING CONNECTION (CONNECTION CLOSED / RESET):
β’ Symptom: Inbound agent disconnects every few minutes with java.io.EOFException.
β’ Cause: A reverse proxy or load balancer (Nginx/HAProxy) in front of Jenkins has a low
read timeout, terminating idle WebSocket connections.
β’ Fix: In Nginx configuration for Jenkins, set:
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
4. CAPTURING REMOTE THREAD DUMPS:
If an agent appears online but hangs on executing shell commands:
Navigate to: Manage Jenkins β Nodes β Click Node β "Thread Dump" in sidebar.
Inspect running threads to identify stuck sub-processes (e.g. hung compiler or deadlock).
STATIC AGENT SPECIFICATION MATRIX:
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β ATTRIBUTE / COMPONENT β OUTBOUND SSH AGENT β INBOUND JNLP / WEBSOCKET AGENT β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββ€
β Jar File Distributed β remoting.jar (Auto-pushed) β agent.jar (Manually downloaded) β
β Required Port β 22/TCP on Worker Node β 443/TCP or 50000/TCP on Controller β
β Authentication Type β Asymmetric Key (Ed25519/RSA) β Cryptographic Node Secret (Hex string)β
β Controller Plugin β SSH Build Agents Plugin β Built-in WSS / Inbound Remoting β
β Remote Directory β /var/jenkins (Recommended) β Configurable (/var/jenkins or C:\) β
β Background Supervisor β OpenSSH Server (sshd) β Linux systemd / Windows Service WinSW β
β Network Compatibility β Direct routing (Same VPC) β Works through NAT, Proxies & Firewallsβ
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββ€
β TOP 5 STATIC AGENT GOVERNANCE AXIOMS FOR DEVOPS SREs: β
β 1. Dedicated Unprivileged User: Always run agents as a non-root 'jenkins' user account. β
β 2. Equal Java Runtimes: Ensure agent Java LTS major version matches Controller exactly. β
β 3. Enable Exclusive Mode: Set high-spec/specialized nodes to 'Only build jobs matching label'. β
β 4. Modern WebSockets: Prefer -webSocket over raw TCP 50000 to simplify firewall traversal. β
β 5. Automated Service Recovery: Always supervise inbound agents with systemd or WinSW daemons. β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ