swarmkit
swarmkit copied to clipboard
[Proposal] docker service create template support for Node labels
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
.
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" }}
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.
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 ?
@s4ke I think that it simply folder called for template
on root of this Git repo where the code related to this one exists.