Skip to main content

Nomad Provider

A Story of Tags, Services & Nomads Attach tags to your Nomad services and let Traefik automatically discover and route traffic. The Nomad provider integrates with HashiCorp Nomad’s native service discovery for seamless routing in your Nomad cluster.

Quick Start

1

Enable Nomad Provider

2

Add Tags to Nomad Job

job.nomad
3

Deploy Job

Traefik automatically discovers the service!

How It Works

The Nomad provider:
  1. Queries Nomad API for registered services
  2. Watches for changes (optional) in real-time
  3. Extracts routing config from service tags
  4. Discovers allocation IPs and ports
  5. Creates routes dynamically
  6. Updates on events when allocations start/stop

Provider Configuration

endpoint

Nomad server connection settings.

address

Default: http://127.0.0.1:4646

token

Optional, Default: "" Nomad ACL token:
Required ACL policy: read-job capability. See Nomad ACL documentation.

endpointWaitTime

Optional, Default: "" Watch block duration:

tls

TLS configuration:

prefix

Default: traefik Tag prefix for configuration:
Use tags like: lb.http.routers.app.rule=...

refreshInterval

Default: 15s Polling interval:
Ignored when watch: true is enabled.

watch

Default: false Enable real-time event watching:

throttleDuration

Default: 0s Throttle event handling:
Only works with watch: true.

exposedByDefault

Default: true

stale

Default: false Allow stale reads for better performance:

defaultRule

Default: Host(`{{ normalize .Name }}`)

constraints

Optional, Default: "" Filter services by tags:

namespaces (Enterprise)

Optional, Default: "" Watch specific namespaces:
Requires Nomad Enterprise with namespace support.

allowEmptyServices

Default: false Create load balancers even with no healthy allocations:

Nomad Job Examples

Basic Web Service

Service with Middleware

Multi-Service Job

Canary Deployment

Complete Traefik Deployment

Network Modes

Bridge Mode (Default)

Traefik connects to allocation’s private IP.

Host Mode

Direct node IP access.

CNI Plugins

With Consul Connect or other CNI plugins.

Tag Syntax

All Traefik labels work as Nomad tags:

Troubleshooting

Services Not Discovered

1

Check Nomad Connection

2

Verify Service Registration

3

Check ACL Token

Ensure read-job policy is attached.
4

Review Traefik Logs

Health Check Issues

Ensure service has health checks:

ACL Configuration

Create policy for Traefik:
Apply policy:

Best Practices

1

Enable Watch Mode

Use watch: true for real-time updates instead of polling.
2

Use Health Checks

Always configure Nomad service health checks.
3

Tag Consistently

Develop a tagging strategy (environment, version, team).
4

Secure ACL Tokens

Use minimum required permissions and rotate tokens regularly.
5

Set Stale Reads

Enable stale: true for better performance in large clusters.

Next Steps

Nomad Routing

Detailed tag configuration reference

Nomad Documentation

Official HashiCorp Nomad documentation