Nomad
Service Discovery in Nomad
Service Discovery refers to a suite of networking features that expose services running on a host machine and make them to consumable by one another.
Nomad includes a lightweight service discovery feature suitable for edge computing and deployments with basic requirements. For production workloads, we recommend integrating HashiCorp Consul as your service discovery solution.
Consul service discovery
Consul uses a service catalog that makes it suitable for dynamic workload operations at scale.
If you define a service for Consul and configure a health check in the
service block of a Nomad jobspec, Consul
automatically registers the service in the catalog when you run the job.
Consul service discovery is ideal for production environments at scale in cloud, multi-cloud, and hybrid cloud deployments with complex networking requirements. Key use cases include:
- Microservices architectures: Consul enables automatic discovery, health-based routing, and failure detection without hardcoding endpoints.
- High availability in production: For workloads that rely on DNS queries, mTLS encryption, or integration with tools like Traefik, Consul ensures that only healthy instances are discoverable.
- Dynamic app configuration and monitoring: Applications can use Consul KV for automated configuration changes during runtime, with detailed telemetry output and monitoring integrations.
- Hybrid or multi-cluster setups: When services span Nomad clusters or integrate with non-Nomad components, Consul provides secure connectivity and centralized discovery.
- Legacy app modernization: Migrating monoliths to services, using Consul DNS to replace static IPs/hostnames for easier scaling and monitoring.
For a working example of Consul service discovery on Nomad, complete the Migrate a monolithic application tutorial collection.
Nomad native service discovery
To use Nomad’s native service discovery, you must use
Go template syntax to configure the
template block of a Nomad jobspec, which
leverages Nomad’s underlying Go architecture to dynamically set address values.
Nomad service discovery is ideal for scenarios where you prioritize low overhead over advanced networking. Key use cases include:
- Small single-cluster deployments: For applications with basic service communication needs, such as a web app connecting to a database with templated IPs or ports, without the complexity of DNS or external registries.
- Local development and testing environments: Developers can prototype services quickly using Nomad's CLI for queries without installing Consul.
- Minimalist production setups: Nomad provides embedded registration and load balancing for basic east-west traffic, which may be sufficient in resource-constrained edge computing environments, or when adopting Nomad incrementally as an organization.
- Dependency chaining in jobs: Building interconnected services using templates to dynamically inject service details is suitable for applications that do not have microservice architectures.
For a working example of Nomad service discovery in action, complete the AI workloads on Nomad tutorial collection.
Service discovery comparison
The following table describes aspects of each product’s service discovery features,
| Aspect | Nomad | Consul |
|---|---|---|
| Address discovery | Static API/CLI queries Go template syntax | Dynamic DNS resolution |
| Health checks | Nomad allocation health No health filtering | Built-in HTTP/TCP/GRPC checks Filters to healthy instances. |
| Scalability | Best for small, basic workloads. | Best for large-scale distributed systems with churn. |
| Additional requirements | None | Consul agents running on Nomad nodes. |
To learn more about Consul’s service discovery features, refer to What is service discovery? in the Consul documentation.
Next steps
Learn how to configure service discovery on Nomad describes the process to configure Nomad and Consul service discovery in a job specification.
Complete the following tutorials to learn about Nomad service discovery in more detail:
For more information about Consul and its service discovery operations, refer to Discover services in the Consul documentation.