-
-
Notifications
You must be signed in to change notification settings - Fork 98
feat(autodiscovery): Add Nomad integration #4957
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Nomad integration to Updatecli’s autodiscovery feature, enabling automated updates for Nomad job files and supporting variable interpolation for docker image definitions.
- Introduces Nomad plugin implementation with supporting utility and matching rule functions.
- Adds tests and manifest templates specifically for Nomad.
- Integrates the Nomad crawler into the autodiscovery pipeline.
Reviewed Changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
pkg/plugins/autodiscovery/nomad/utils_test.go | Adds tests for Nomad file search, spec parsing, and variable extraction functions. |
pkg/plugins/autodiscovery/nomad/utils.go | Implements file search and Nomad spec parsing (note: update comment regarding Chart.yaml). |
pkg/plugins/autodiscovery/nomad/matchingRule.go | Implements rule matching logic but contains an accumulation bug in ruleResults. |
pkg/plugins/autodiscovery/nomad/matchingRule_test.go | Adds tests validating matching rule behavior for Nomad resources. |
pkg/plugins/autodiscovery/nomad/manifestTemplate.go | Provides manifest templates for generating updated Nomad configuration. |
pkg/plugins/autodiscovery/nomad/main_test.go | Tests the discovery of manifests from Nomad configuration files. |
pkg/plugins/autodiscovery/nomad/main.go | Implements the Nomad plugin’s initialization logic. |
pkg/plugins/autodiscovery/nomad/dockerDriver.go | Generates manifests for Nomad jobs via docker image parsing and templating. |
pkg/core/pipeline/autodiscovery/main.go | Registers the Nomad crawler into the autodiscovery pipeline. |
Files not reviewed (2)
- pkg/plugins/autodiscovery/nomad/testdata/simple/nomad.hcl: Language not supported
- pkg/plugins/autodiscovery/nomad/testdata/variable/grafana.nomad: Language not supported
Comments suppressed due to low confidence (1)
pkg/plugins/autodiscovery/nomad/utils.go:17
- [nitpick] The comment incorrectly references "Chart.yaml"; update it to indicate that the function searches for Nomad files based on the provided file patterns.
// searchNomadFiles will look, recursively, for every files named Chart.yaml from a root directory.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, maybe it needs to be a touch clearer that it's only for the docker driver in hcl files, as you can have different drivers and also json spec
Indeed good point |
Just want to mention, docker is not the only driver for container related workloads, there is also a podman driver. |
@allroundtechie usually this is left to the caller of updatecli, typically in ci what i do is have a login step (for docker registries, npm, cargo, ...) then call updatecli |
@loispostula Good point, thanks. I basically forgot how I was doing it with the docker-compose autodiscovery which I use at another project and a private registry and you are right, I also did this like you mentioned (within a CI pipeline step). This really says a lot about this tool, setup and forget, just works :-) |
The way I see authentication today:
|
Just my two cents:
So from a security point of view the last option @olblak mentioned is at least in context of CI pipelines actually a no go. But of course this could makes sense for other people who do not use CI pipelines. |
@allroundtechie back when I was using nomad, but I do use it for my k3s clusters, I actually set up |
Thanks for the feedback, I agree with you. Updatecli is mostly used from a CI environment and rely on environment variables.
So I guess the PR is ready in the current state and we could always improve it after |
Fix #2331
Add Nomad autodiscovery plugin to automate docker image update.
Please note that it only supports the Docker driver and HCL files.
We could improve it in the future to also handle JSON files
It handles the following scenario:
image = "hashicorp/http-echo:latest"
image = "grafana/grafana:${var.image_tag}"
In the second case, Updatecli will update the variable definition and not the task definition
Test
To test this pull request, you can run the following commands:
I also did some testing on https://github.com/fhemberger/nomad-demo
Additional Information
Checklist
Tradeoff
Potential improvement