2015-11-18 20:14:28 +00:00
|
|
|
---
|
|
|
|
layout: "docs"
|
2016-10-09 07:01:59 +00:00
|
|
|
page_title: "Service Discovery"
|
2016-10-28 00:36:26 +00:00
|
|
|
sidebar_current: "docs-service-discovery"
|
2015-11-18 20:14:28 +00:00
|
|
|
description: |-
|
|
|
|
Learn how to add service discovery to jobs
|
2015-11-18 22:11:23 +00:00
|
|
|
---
|
2015-11-18 20:14:28 +00:00
|
|
|
|
|
|
|
# Service Discovery
|
|
|
|
|
2015-11-18 21:15:47 +00:00
|
|
|
Nomad schedules workloads of various types across a cluster of generic hosts.
|
|
|
|
Because of this, placement is not known in advance and you will need to use
|
|
|
|
service discovery to connect tasks to other services deployed across your
|
2016-10-31 04:00:35 +00:00
|
|
|
cluster. Nomad integrates with [Consul][] to provide service discovery and
|
|
|
|
monitoring.
|
2015-11-18 21:15:47 +00:00
|
|
|
|
|
|
|
Note that in order to use Consul with Nomad, you will need to configure and
|
|
|
|
install Consul on your nodes alongside Nomad, or schedule it as a system job.
|
|
|
|
Nomad does not currently run Consul for you.
|
2015-11-18 20:14:28 +00:00
|
|
|
|
|
|
|
## Configuration
|
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
To enable Consul integration, please see the
|
2016-11-01 12:53:13 +00:00
|
|
|
[Nomad agent Consul integration](/docs/agent/configuration/consul.html)
|
2016-10-31 04:00:35 +00:00
|
|
|
configuration.
|
2015-11-25 21:49:31 +00:00
|
|
|
|
2015-11-18 20:14:28 +00:00
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
## Service Definition Syntax
|
2016-03-26 20:02:30 +00:00
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
To configure a job to register with service discovery, please see the
|
|
|
|
[`service` job specification documentation][service].
|
2016-10-21 00:49:45 +00:00
|
|
|
|
2015-11-18 21:20:23 +00:00
|
|
|
## Assumptions
|
2015-11-18 20:14:28 +00:00
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
- Consul 0.6.4 or later is needed for using the Script checks.
|
2016-03-28 17:06:44 +00:00
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
- Consul 0.6.0 or later is needed for using the TCP checks.
|
2015-11-18 20:22:48 +00:00
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
- The service discovery feature in Nomad depends on operators making sure that
|
2016-01-27 05:09:03 +00:00
|
|
|
the Nomad client can reach the Consul agent.
|
2015-11-18 20:14:28 +00:00
|
|
|
|
2016-10-31 04:00:35 +00:00
|
|
|
- Tasks running inside Nomad also need to reach out to the Consul agent if
|
2015-11-18 21:20:23 +00:00
|
|
|
they want to use any of the Consul APIs. Ex: A task running inside a docker
|
|
|
|
container in the bridge mode won't be able to talk to a Consul Agent running
|
|
|
|
on the loopback interface of the host since the container in the bridge mode
|
|
|
|
has it's own network interface and doesn't see interfaces on the global
|
|
|
|
network namespace of the host. There are a couple of ways to solve this, one
|
|
|
|
way is to run the container in the host networking mode, or make the Consul
|
2016-01-27 05:09:03 +00:00
|
|
|
agent listen on an interface in the network namespace of the container.
|
2016-10-31 04:00:35 +00:00
|
|
|
|
|
|
|
[consul]: https://www.consul.io/ "Consul by HashiCorp"
|
|
|
|
[service]: /docs/job-specification/service.html "Nomad service Job Specification"
|