Running Network Agent as a Nomad Job
Nomatron is in early access. Some advanced workflows may not be covered in the public docs.
Running the Network Agent as a Nomad job is a natural fit when the private cluster already uses Nomad to manage infrastructure-side services.
For many teams, this becomes the cleanest long-lived deployment model because Nomad already gives you:
- restart and reschedule behavior;
- template rendering for
agent.hcl; - secret injection patterns;
- placement controls; and
- a consistent way to run supporting agents inside the same private environment as the Nomad cluster itself.
Unlike the Nomatron server, the Network Agent is usually an outbound-only component. That changes the recommended Nomad shape quite a bit:
- the agent normally does not need a public load balancer;
- it often does not need Nomad service registration at all;
- the important concern is private-network placement and egress reachability; and
- most cluster-specific configuration still belongs in the rendered
agent.hclfile.
Best-Practice Shape
For most deployments, the recommended pattern is:
- run the Network Agent in the same private network as the Nomad cluster it will reach;
- use a dedicated Nomad namespace for infrastructure-side agent jobs if your cluster uses namespaces;
- render
agent.hclwith a Nomadtemplatestanza; - inject the Network Agent token and Nomad ACL token through Nomad variables, Vault, or another secret mechanism;
- start with one agent per private cluster unless you have a clear reason to combine multiple clusters into one agent process; and
- keep the agent close to the cluster API it needs to reach rather than treating it like a public-facing service.
One Agent Per Cluster Versus One Agent Per Private Network
The simplest operating model is:
- one Network Agent process;
- one private Nomad cluster; and
- one
clusterblock in the config file.
That model is easiest to reason about because:
- placement is obvious;
- credentials are isolated cleanly;
- troubleshooting is simpler; and
- each agent maps to one cluster trust boundary.
A single agent can serve multiple clusters if:
- all of those clusters are reachable from the same private network;
- the same operational team owns them;
- you are comfortable storing multiple cluster credentials in one rendered config file; and
- you want to reduce the number of long-lived agent processes.
When in doubt, start with one agent per cluster and only combine later if the operational shape is clearly worth it.
Before You Start
Have these pieces ready before you submit the job:
- a Nomad cluster in the same private network as the target Nomad API;
- the published
ghcr.io/nomatronio/nomatron-releases/nomatron-connectivity-agent:v0.1.7image (always pin a version tag; do not uselatest); - a valid Network Agent ID and token;
- the target cluster ID from Nomatron;
- the private Nomad API address;
- a Nomad ACL token if the target cluster requires one; and
- a decision about where the job should land inside the private network.
The Network Agent does not help if it cannot reach the private Nomad API from where it is scheduled.
Older Nomad Versus Newer Nomad
This page uses two compatibility tracks.
Older Nomad
On older Nomad versions, you may not have:
- built-in Nomad Variables; or
- the newer built-in service registration features.
That is still fine for the Network Agent, because service registration is usually not the main concern here.
On older Nomad:
- keep the job simple;
- inject secrets through job variables, Vault, environment variables, or your existing secret path; and
- render a static
agent.hclfile with explicit control-plane and Nomad API addresses.
Newer Nomad
On newer Nomad versions, take advantage of:
- Nomad Variables for the Network Agent token and Nomad ACL token;
- richer
templateworkflows; and - cleaner namespace-level policy boundaries.
Those features improve secret handling and make the job easier to promote between environments, even though the agent itself usually does not need Nomad service registration.
Why Templates Are The Right Default
Nomad template stanzas are the best fit for the Network Agent because they let you render the exact agent.hcl shape the runtime expects.
That is better than trying to force the whole configuration through environment variables once the deployment becomes real.
Templates are especially useful here because the agent config usually contains:
- the Network Agent ID and token;
- one or more Nomad cluster definitions;
- Nomad TLS settings;
- Nomad ACL token settings; and
- control-plane TLS settings.
Those settings read much more clearly as an HCL config file than as a long list of environment variables.
Dedicated Namespace Recommendation
If your Nomad cluster uses namespaces, a dedicated namespace such as nomatron-agents or platform-agents is a strong default.
That gives you:
- a cleaner ACL boundary for who can change the agent jobs;
- less noisy job listings;
- clearer ownership; and
- easier separation from tenant application workloads.
Example:
namespace = "nomatron-agents"Single-Cluster Baseline Job
This is the best place to start for most teams.
It assumes:
- one private Nomad cluster;
- one Network Agent process;
- one rendered
agent.hcl; and - a Docker task using the published image.
job "nomatron-connectivity-agent" {
datacenters = ["dc1"]
type = "service"
namespace = "nomatron-agents"
update {
max_parallel = 1
min_healthy_time = "10s"
healthy_deadline = "5m"
progress_deadline = "10m"
auto_revert = true
}
group "agent" {
count = 1
restart {
attempts = 10
interval = "30m"
delay = "15s"
mode = "delay"
}
task "nomatron-connectivity-agent" {
driver = "docker"
config {
image = "ghcr.io/nomatronio/nomatron-releases/nomatron-connectivity-agent:v0.1.7"
args = ["--config", "${NOMAD_SECRETS_DIR}/agent.hcl"]
}
# Agent token, read from a Nomad Variable into a file in the secrets dir.
template {
destination = "secrets/agent-token"
perms = "0400"
data = <<EOF
{{- with nomadVar "nomad/jobs/nomatron-connectivity-agent/agent/nomatron-connectivity-agent" }}{{ .agent_token }}{{ end -}}
EOF
}
template {
destination = "secrets/agent.hcl"
perms = "0400"
data = <<EOF
server_addrs = ["${var.server_addr}"]
http_base_urls = ["${var.http_base_url}"]
agent_id = "${var.agent_id}"
agent_token_file = "{{ env "NOMAD_SECRETS_DIR" }}/agent-token"
heartbeat_interval = "15s"
log_level = "info"
log_format = "text"
capabilities = [
"nomad_proxy",
"job_events"
]
cluster {
cluster_id = "${var.cluster_id}"
address = "${var.nomad_address}"
acl_token = "{{ with nomadVar "nomad/jobs/nomatron-connectivity-agent/agent/nomatron-connectivity-agent" }}{{ .nomad_acl_token }}{{ end }}"
tls_enabled = false
skip_verify = false
}
control_plane_tls_enabled = false
EOF
}
resources {
cpu = 500
memory = 256
}
}
}
}
variable "server_addr" {
type = string
description = "Nomatron gRPC endpoint, e.g. nomatron.internal.example.com:4650."
}
variable "http_base_url" {
type = string
description = "Nomatron HTTP API base URL, e.g. https://nomatron.example.com:4649."
}
variable "agent_id" {
type = string
description = "Network Agent UUID from Nomatron."
}
variable "cluster_id" {
type = string
description = "Nomad cluster UUID known to Nomatron."
}
variable "nomad_address" {
type = string
description = "Private Nomad API address reachable from the task."
}The job reads its secrets from the Nomad Variable nomad/jobs/nomatron-connectivity-agent/agent/nomatron-connectivity-agent, which the task can read automatically. Store two items in it, agent_token (the minted Network Agent token) and nomad_acl_token (the Nomad ACL token for the target cluster, if required), for example with nomad var put -namespace nomatron-agents @agent-secrets.json from a spec file kept out of source control. Neither value appears in the job file, and both rendered files live in the task’s secrets directory.
This baseline intentionally keeps the job simple:
- one task;
- one rendered config file plus a token file, both in the secrets directory;
- no inbound ports;
- one cluster definition; and
- no dependency on service registration.
Multi-Cluster Example
If one agent needs to serve multiple private clusters from the same network boundary, render multiple cluster blocks into the same file.
Example:
template {
destination = "secrets/agent.hcl"
perms = "0400"
data = <<EOF
server_addrs = ["${var.server_addr}"]
http_base_urls = ["${var.http_base_url}"]
agent_id = "${var.agent_id}"
agent_token_file = "{{ env "NOMAD_SECRETS_DIR" }}/agent-token"
heartbeat_interval = "15s"
capabilities = [
"nomad_proxy",
"job_events"
]
cluster {
cluster_id = "${var.cluster_one_id}"
address = "${var.cluster_one_address}"
acl_token = "{{ with nomadVar "nomad/jobs/nomatron-connectivity-agent/agent/nomatron-connectivity-agent" }}{{ .cluster_one_acl_token }}{{ end }}"
tls_enabled = false
skip_verify = false
}
cluster {
cluster_id = "${var.cluster_two_id}"
address = "${var.cluster_two_address}"
acl_token = "{{ with nomadVar "nomad/jobs/nomatron-connectivity-agent/agent/nomatron-connectivity-agent" }}{{ .cluster_two_acl_token }}{{ end }}"
tls_enabled = false
skip_verify = false
}
EOF
}Only do this when those clusters genuinely share an operational boundary. If the clusters live in different network zones or are owned by different teams, separate agents are usually cleaner.
Placement Guidance
The Network Agent should be scheduled where it can reach the private Nomad API reliably.
In practice, that usually means one of these patterns:
- run it on a general infrastructure client inside the same private subnet;
- constrain it to a dedicated class of infrastructure clients; or
- constrain it to a region, datacenter, or node pool that has the required routes.
A common pattern is:
constraint {
attribute = "${node.class}"
value = "infra"
}Use placement rules to make sure the job does not drift onto clients that cannot reach the target Nomad API.
Networking Considerations
The Network Agent usually does not need:
- a load balancer;
- a public ingress path; or
- a Nomad service registration entry for inbound traffic.
What matters is outbound reachability from the task to:
- the Nomatron gRPC endpoint on
4650; - the Nomatron HTTP API on
4649; and - the private Nomad API address for each configured cluster.
Because the agent is outbound-only, the Nomad job spec is often simpler than a public-facing service job.
Secret Handling
The sensitive values in this deployment are usually:
- the Network Agent token;
- the Nomad ACL token; and
- any mounted TLS material.
On newer Nomad clusters, Nomad Variables are a strong fit for these.
On older clusters, use the secret source you already trust, such as:
- Vault integration;
- pipeline-injected variables;
- environment variables; or
- another external secret delivery mechanism.
Avoid baking tokens directly into the job file committed to source control.
Do You Need A Service Stanza?
Usually, no.
The Network Agent is not normally an inbound service that other applications call directly. It is a long-lived outbound worker process.
That means:
- service registration is optional; and
- health is often better judged by Nomad task state, logs, and the connected state visible in Nomatron.
If you have a local operational reason to register the task in Nomad, you can, but it is not the main pattern this component depends on.
Resources
A conservative starting point is:
resources {
cpu = 500
memory = 256
}Increase that if:
- the agent is serving multiple clusters;
- event throughput is high; or
- you expect sustained proxy activity through the agent.
Start small, watch usage, and increase based on real load.
What Healthy Operation Looks Like
After the job starts, you should see:
- the allocation stays running;
- the rendered
agent.hclvalidates cleanly; - the logs show a successful connection to Nomatron; and
- the agent appears as connected inside Nomatron.
From Nomad’s point of view, the main signal is that the task stays healthy and avoids restart loops.
From Nomatron’s point of view, the main signal is that the agent is connected and cluster-backed operations succeed.
Common Failure Modes
| Problem | What it usually means |
|---|---|
| Allocation restarts immediately | The rendered config file is invalid or missing required fields. |
| Task stays running but never connects | The task cannot reach Nomatron on 4650 or 4649. |
| Task connects but cluster validation fails | cluster_id, address, ACL token, or Nomad TLS settings are wrong. |
| The job lands on the wrong client | Placement constraints are too loose for the private-network topology. |
| The config is hard to reason about | Too much of the runtime was pushed into environment variables instead of a rendered config file. |
Recommended Pattern
For most operators, the cleanest Nomad-based shape is:
- use one agent per private cluster to start with;
- schedule it in a dedicated infrastructure namespace;
- render
agent.hclwith atemplatestanza; - inject the Network Agent token and Nomad ACL token from a secret source;
- avoid service registration unless you have a clear operational reason for it; and
- keep placement strict enough that the task always lands where the private Nomad API is reachable.
If you want a reusable Nomad Pack for this pattern, the next page explains the current Nomad Pack options.