问题
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
回答1:
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
来源:https://stackoverflow.com/questions/56801967/passing-a-value-to-nomad-from-consul-kv