Search code examples
consulnomad

Passing a value to nomad from Consul kv


fetch the information from Consul and then submit this job to Nomad, injecting the Consul k/v value as an environment variable.

like for example i have a value in consul k/v which is

testData = "HELLO"

on the other hand, in my job.

i want the value from consul k/v to be injected to env stanza as a value.

env
CONSUL_test = <value of consul k/v testData>

is this possible?

so that when i inspect the docker env, i must see

CONSUL_test = HELLO

Solution

  • nomad uses consul-templating, so you can reference consul k/v values in your nomad spec by doing {{ key "myKey" }}. https://www.nomadproject.io/docs/job-specification/template.html