*nomad* - enables reading zone data from a Nomad cluster.
## Description
This plugin serves DNS records for services registered with Nomad. Nomad 1.3+ comes with [support for discovering services](https://www.hashicorp.com/en/blog/nomad-service-discovery) with an in-built service catalogue that is available via the HTTP API. This plugin extends the HTTP API and provides a DNS interface for querying the service catalogue.
The query can be looked up with the format `[service].[namespace].service.nomad`. The plugin currently handles A, AAAA and SRV records. Refer to [#Usage Example](#usage-example) for more details.
*`filter` allows you to filter Nomad services. **FILTER** defaults to `""`. Uses [filtering](https://developer.hashicorp.com/nomad/api-docs#filtering) syntax.
*`token` The SecretID of an ACL token to use to authenticate API requests with if the Nomad cluster has ACL enabled. **TOKEN** defaults to `""`.
*`ttl` allows you to set a custom TTL for responses. **DURATION** defaults to `30 seconds`. The minimum TTL allowed is `0` seconds, and the maximum is capped at `3600` seconds. Setting TTL to 0 will prevent records from being cached. The unit for the value is seconds.
## Metrics
If monitoring is enabled (via the *prometheus* directive) the following metric is exported:
*`coredns_nomad_success_requests_total{namespace,server}` - Counter of DNS requests handled successfully.
*`coredns_nomad_failed_requests_total{namespace,server}` - Counter of DNS requests failed.
The `server` label indicated which server handled the request. `namespace` indicates the namespace of the service in the query.
## Ready
This plugin reports readiness to the ready plugin. It will be ready only when it has successfully connected to the Nomad server. It queries the [`/v1/agent/self`](https://developer.hashicorp.com/nomad/api-docs/agent#query-self) endpoint to check if it is ready.
## Examples
Enable nomad with and resolve all services with `.nomad` as the suffix. `cache` plugin is used to cache the responses for 30 seconds. This avoids a lookup to the Nomad server for every request.
`nomad` plugin uses a default Nomad configuration to create an API client. Options like the HTTP address and the token can be specified in Corefile. However, Nomad Go SDK can also additionally read these environment variables.
-`NOMAD_TOKEN`
-`NOMAD_ADDR`
-`NOMAD_REGION`
-`NOMAD_NAMESPACE`
-`NOMAD_HTTP_AUTH`
-`NOMAD_CACERT`
-`NOMAD_CAPATH`
-`NOMAD_CLIENT_CERT`
-`NOMAD_CLIENT_KEY`
-`NOMAD_TLS_SERVER_NAME`
-`NOMAD_SKIP_VERIFY`
You can read about them in detail [here](https://developer.hashicorp.com/nomad/docs/reference/runtime-environment-settings).