Nomad-Consul integration, convenient way to get all IPs of a service and put into task env vars?

I am currently running CockroachDB and ScyllaDB outside of Nomad, and I’d like to consider moving these onto Nomad.

However, I don’t know how to Nomad-idiomatically pass all service IP’s, as opposed to a single one, the latter being well document with Nomad.


Not 100% sure I understand your problem, but I’ll try.

  • You can register external services in consul (e.g. with multiple addresses per service), and your nomad tasks can access these via consul (by service name).
  • If possible, you can add a consul agent on the “external” nodes running your services and register as internal consul services instead (better).

If you want to lookup all available IP’s of a service (or anything from consul/vault, really), you can use consul-template within nomad template-stanza or the env-stanza.

When you access a service registered in Consul, you would usually have a healthcheck on the service endpoints. Your nomad job will only get a healthy endpoint from consul.