Skip to content
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

[Proposal] docker service create template support for Node labels #2942

Open
derteufelqwe opened this issue Apr 12, 2020 · 4 comments
Open

Comments

@derteufelqwe
Copy link

derteufelqwe commented Apr 12, 2020

Currently supported Templates regarding the Nodes
Currently only two templates {{ .Node.ID }} and {{ .Node.Hostname }} are supported. This is nice, but labels would put these templates on another level in terms of possibilities.

How could this look
The template could be something like {{ .Node.Spec.Labels.[label name] }}.
If the label is not found the value "", "null" or "<no value>" (as it's currently done using docker node inspect) should be used.

Summary
Dockers templates for service creation should support node labels.
The result of the template {{ .Node.Spec.Labels.example_label }} should be the same as the output of docker node inspect -f="{{ .Spec.Labels.example_label }}" node_name.

@skechboy
Copy link

skechboy commented Jan 8, 2022

Great proposal, and highly anticipated :)
Also, as Docker is using Go’s text/template engine, a pipeline can be used for setting a default value if the specific label has null value, for example:

{{ .Node.Spec.Labels.label_name | "default_value" }}

@KevinBLT
Copy link

Any news on this?

Absolutely necessary! For now I have a MariaDB docker config, which has a file included that points to a config file mounted from host to get some specific variables for galera cluster. When I could use node labels it would allow me to avoid host bind mounts for config files.

@s4ke
Copy link
Contributor

s4ke commented Dec 15, 2022

This feels useful for anyone running stateful apps in swarm. I'd be happy to see if this is something I can contribute to. Any pointers where to look specifically (links to files would be enough) @dperny @thaJeztah ?

@olljanat
Copy link
Contributor

@s4ke I think that it simply folder called for template on root of this Git repo where the code related to this one exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants