-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature request: template with on-the-fly consul-kv / vault-kv backend support #24121
Comments
Hi @dmclf! The workflow you're describing is a little unclear to me. I understand that you want the Can you provide a full proposed |
hi @tgross and then in the jobspec now roughly you have something like (dry-jobs-levant
then that may work fine for small files, although when having bigger jobs that span several groups with a good amount of tasks per group that all have a common used secret, the jobspec itself can grow rapidly. and yes artifacts can work, but may have several security issues too. so I was wondering if Nomad more 'natively' , example..
lets say it turns it to
where on final nomad jobspec, you would only see this special reference and practically, nomad would use that consul-kv in a same way as the 'artifact' (ie, download/render) where in the end the following would be achieved
but if this would only make things simpler for the end-user, but requires a big amount of changes on Nomad side that do not keep things simple, then I guess this may likely not happen. (I guess it logically should be more part of the 'templating / abstraction' phase, before any 'nomad job' cmd's?) ok, maybe will just close it as I guess this likely won't be accepted, seeing Nomad also wants to keep things simple (on Nomad side) just my setup now is generic usable levant based templating with json-files through gitlab-ci steps that everyone seems to easily understand |
Ok to close, but just for anyone who comes along later looking for something like this... Just to clarify, you're looking for a workflow where:
As I've noted, the new feature here would be just steps 2-4. This logic would be mostly contained in the consul-template project. The cluster admin would likely have some challenging work to do to set up the appropriate ACL policies for minting Consul/Vault tokens from Workload Identity as well. But while the implementation of this would be relatively complex, I think it has more fundamental design problems:
|
Addendum: if it weren't for the "write back to KV" aspect of this, I could imagine a feature where we have something like this: template {
consul_kv_source = "foo/bar"
destination = "/secret/mysecret.txt"
} that gets automatically transformed behind the scenes into: template {
data = "{{ key: \"foo/bar\"}}"
destination = "/secret/mysecret.txt"
} But that only works for Consul's API. For Vault KV and Nomad Variables you need to dereference the items in the value by name as well. |
In the situation I envisioned I'd indeed see the KV as the 'template' source, per your Addendum, and not rendered/write back 👌 I suppose, maybe i'll just have to reconsider the artifact section , accept that its security is not great.. |
Ok, but if you're not writing back, then you can just do: template {
data = "{{ key: \"foo/bar\"}}"
destination = "/secret/mysecret.txt"
} And then you're done, for Consul. For Vault the equivalent would be: template {
data = "{{with secret \"foo/bar\"}}{{index .Data \"myfield\"}}{{end}}"
destination = "/secret/mysecret.txt"
} For Nomad the equivalent would be: template {
data = "{{ with nomadVar \"foo/bar\" }}{{ .myfield }}{{ end }}"
destination = "/secret/mysecret.txt"
}
} This wouldn't let you render a template nested in that template, but that's an open issue for CT here: hashicorp/consul-template#1981 |
Hi @tgross
but for optimizations I was wondering about other approaches to not make the actual file part of the jobspec (and which wouldnt be 'artifact' based) anyway, thank you for your input, I will take a few moments to consider possible next steps to improve on our end, and I may keep an eye on that CT issue you mentioned and see if that possibly can come in handy in the future. |
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. |
Proposal
template block now supports two source definitions
request:
Use-cases
example..
this would make templating more 'native' to the nomad cli and keep the jobspec cleaner
Attempted Solutions
data = <<EOF
large-blob
EOF
can get out of hand as docs state for larger files
and the data -> source <-> artifact path also is not the most convenient to setup.
example, if Nomad can upload these files on-the-fly, then from a gitlab CI one would then easily be able to regenerate the files.
however, if one depends on artifacts and http, yes, it can work from gitlab-ci but one would need long-living tokens, so no deploy-specific tokens, to make that work longer term.
example: you deploy your job on the first day of the week, but next week the job restarts and tokens expired, job fails to fetch artifacts and falls over.
and with artifact, these tokens (or ssh-keys) then will be part of the nomad-jobspec , which does not seem very secure?
security concerns:
(reference)[https://developer.hashicorp.com/nomad/docs/job-specification/artifact#download-file]
so writing to a (secure path) of consul-kv (or even vault-kv), natively managed by nomad,
might be a lot more hashicorp-native, cleaner and safer way?
The text was updated successfully, but these errors were encountered: