hashicorp / consul-template

Template rendering, notifier, and supervisor for @HashiCorp Consul and Vault data.
https://www.hashicorp.com/
Mozilla Public License 2.0
4.75k stars 784 forks source link

Add a way to template nomad nodes (similar to consul nodes). #1860

Open blmhemu opened 8 months ago

blmhemu commented 8 months ago

Feature Request

Add a way to enumerate over nomad nodes (and fetch the node data like ip, etc) similar to how we do for consul - https://github.com/hashicorp/consul-template/blob/main/docs/templating-language.md#nodes

This will enhance nomad service discovery story.

Use case

If we know which nodes nomad runs on can open up possibilities to connect to outside applications with known ports.

thevilledev commented 5 months ago

You can access any data from the Consul service catalog in consul-template through the service function. Nomad server endpoints are registered under nomad service and clients can be found under nomad-client. This means you can do things like this with consul-template:

{{ range service "nomad-client" }} {{ .Address }}:{{ .Port }} {{ end }}

Would this work for your use case?

blmhemu commented 5 months ago

The above solution needs consul and consul-nomad integration - But what I proposed should work for standalone nomad.

thevilledev commented 5 months ago

Thanks, makes sense. Created a branch on my fork to work on it.