github.com/zhizhiboom/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/website/source/guides/operations/consul-integration/index.html.md (about)

     1  ---
     2  layout: "guides"
     3  page_title: "Consul Integration"
     4  sidebar_current: "guides-operations-consul-integration"
     5  description: |-
     6    Learn how to integrate Nomad with Consul and add service discovery to jobs
     7  ---
     8  
     9  # Consul Integration
    10  
    11  [Consul][] is a tool for discovering and configuring services in your 
    12  infrastructure. Consul's key features include service discover, health checking, 
    13  a KV store, and robust support for multi-datacenter deployments. Nomad's integration 
    14  with Consul enables automatic clustering, built-in service registration, and 
    15  dynamic rendering of configuration files and environment variables. The sections 
    16  below describe the integration in more detail.
    17  
    18  ## Configuration
    19  
    20  In order to use Consul with Nomad, you will need to configure and
    21  install Consul on your nodes alongside Nomad, or schedule it as a system job.
    22  Nomad does not currently run Consul for you.
    23  
    24  To enable Consul integration, please see the
    25  [Nomad agent Consul integration](/docs/configuration/consul.html)
    26  configuration.
    27  
    28  ## Automatic Clustering with Consul
    29  
    30  Nomad servers and clients will be automatically informed of each other's 
    31  existence when a running Consul cluster already exists and the Consul agent is 
    32  installed and configured on each host. Please see the [Automatic Clustering with 
    33  Consul](/guides/operations/cluster/automatic.html) guide for more information.
    34  
    35  ## Service Discovery
    36  
    37  Nomad schedules workloads of various types across a cluster of generic hosts.
    38  Because of this, placement is not known in advance and you will need to use
    39  service discovery to connect tasks to other services deployed across your
    40  cluster. Nomad integrates with Consul to provide service discovery and
    41  monitoring.
    42  
    43  To configure a job to register with service discovery, please see the
    44  [`service` job specification documentation][service].
    45  
    46  ## Dynamic Configuration
    47  
    48  Nomad's job specification includes a [`template` stanza](/docs/job-specification/template.html) 
    49  that utilizes a Consul ecosystem tool called [Consul Template](https://github.com/hashicorp/consul-template). This mechanism creates a convenient way to ship configuration files 
    50  that are populated from environment variables, Consul data, Vault secrets, or just 
    51  general configurations within a Nomad task.
    52  
    53  For more information on Nomad's template stanza and how it leverages Consul Template, 
    54  please see the [`template` job specification documentation](/docs/job-specification/template.html).
    55  
    56  ## Assumptions
    57  
    58  - Consul 0.7.2 or later is needed for `tls_skip_verify` in HTTP checks.
    59  
    60  - Consul 0.6.4 or later is needed for using the Script checks.
    61  
    62  - Consul 0.6.0 or later is needed for using the TCP checks.
    63  
    64  - The service discovery feature in Nomad depends on operators making sure that
    65    the Nomad client can reach the Consul agent.
    66  
    67  - Tasks running inside Nomad also need to reach out to the Consul agent if
    68    they want to use any of the Consul APIs. Ex: A task running inside a docker
    69    container in the bridge mode won't be able to talk to a Consul Agent running
    70    on the loopback interface of the host since the container in the bridge mode
    71    has its own network interface and doesn't see interfaces on the global
    72    network namespace of the host. There are a couple of ways to solve this, one
    73    way is to run the container in the host networking mode, or make the Consul
    74    agent listen on an interface in the network namespace of the container.
    75  
    76  [consul]: https://www.consul.io/ "Consul by HashiCorp"
    77  [service]: /docs/job-specification/service.html "Nomad service Job Specification"