-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add support for templating node labels and annotations #701
Conversation
Thanks! The one thing that I don't like about this is the skipped validation for the templated value and the only way to satisfy my dislike is to call the |
While this is skipped, the tool will fail with a validation error after the config has been generated. For example, given the following config: nodeLabels:
installerUrl: '{{ .MachineConfig.MachineInstall.InstallImage }}' The tool will fail, prior to generating configs, with: 2024/11/12 22:05:13 failed to generate talos config: 1 error occurred:
* invalid machine node labels: 1 error occurred:
* label value length exceeds limit of 63: "factory.talos.dev/installer-secureboot/67a999813ff49ba00dc632aa48170dc866bda646b7ee4f944e2fb7dc50b522bd:v1.7.1" This is less descriptive than the pre-generation validation, but it is still some form of validation. |
Ah yeah that's validation from the Talos side of |
Thanks @solidDoWant! I think everything is good now. I'll merge this once you're done with the tests and docs (I can do the docs if you don't feel like doing this). Also can you squash the commit as |
Added tests in fc1a8b8. How/where would you like documentation added? I'm not quite sure which pages should have this information added, how it should be formatted, etc.
I'll be sure to squash and rename after final review. |
You can put it inside https://github.com/budimanjojo/talhelper/blob/master/docs/docs/guides.md. Title can be something like |
Added docs. Let me know what you think, and if everything is good to go, then I'll squash and fixup the commit message. I added a link to my system-upgrade-controller deployment in the docs, as a full example of how to handle automated Talos upgrades. A full example (including scripts, health checks, scheduling, etc.) would require a bunch of page space so I thought it might be better to just show a small portion of the concept, with a link to the full thing. Not sure what your policy on this is - let me know if you want me to remove it. |
Looks good! I'm running the workflows now, let me know if you're done with the commit squashing. Thank you! |
@budimanjojo squashed and renamed. Thanks for your help on this! |
Signed-off-by: solidDoWant <[email protected]>
v3.0.10 released with this feature! |
This adds support for templating node labels and annotations. This is useful for passing Talos information that is node-specific to Kubernetes workloads. Each field will be provided the built, but not yet validated or templated machine config struct as the root context (
.
).Here's a simple demo (included in the example file):
I've configured the template engine to use Sprig functions, which is what other popular Golang templating tools use (like Helm, gotemplate, gomplate). I think this will cover the majority of user's needs.
If desired, it should be pretty trivial to add templating support to other fields as well. Personally I'd find a lot of value in having support for templating in
extraKernelArgs
, but I thought it'd be best to start small with labels and annotations, and get some feedback on the concept first.Prior to merge, I need to add:
Example