You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the service{} stanza, the name parameter has access to few special template placeholders:
${JOB}
${TASK}
${TASKGROUP}
${BASE}
It would be nice if the tags of the service would have access to the same placeholders.
Use-cases
System such as Traefik can be configured via tags. For example here's a simple service called "whoami":
job "whoami" {
..
service {
name = "${JOB}"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.services.whoami.loadBalancer.healthCheck.path=/health",
"traefik.http.routers.whoami.entryPoints=web,websecure",
"traefik.http.routers.whoami.rule=Host(`...`)",
]
}
..
}
It's very common for people to copy a service definition like this and to forget to change the router/service name inside of the tags array. It would be nice if we could do something like:
service {
name = "${JOB}"
port = "http"
tags = [
"traefik.enable=true",
"traefik.http.services.${JOB}.loadBalancer.healthCheck.path=/health",
"traefik.http.routers.${JOB}.entryPoints=web,websecure",
"traefik.http.routers.${JOB}.rule=Host(`...`)",
]
}
The text was updated successfully, but these errors were encountered:
I want to be careful of adding more special cases for this use, as it would be easy to spread. I could imagine if we added this, additional requests to make these available in service checks and other areas of the jobspec. Therefore I wonder if we can't use the traditional interpolation variables that are available for this? The mapping is as follows:
${JOB} == ${NOMAD_JOB_NAME} or ${NOMAD_JOB_ID}
${TASKGROUP} == ${NOMAD_GROUP_NAME}
${TASK} == ${NOMAD_TASK_NAME}
${BASE} == ${NOMAD_JOB_NAME}-${NOMAD_GROUP_NAME}-${NOMAD_TASK_NAME} (I understand this is a bit annoying)
oh, I was under the impression these are only available values to the running task as an environment variable and cannot be used for interpolation in the tags values. Seems like it does!
In that case it raises the question - what's the point of having special job/taskgroup/task/base placeholders?
Going to close this issue because I think the suggested solution makes the suggestion unnecessary. Thank you for your help.
Proposal
In the
service{}
stanza, the name parameter has access to few special template placeholders:It would be nice if the tags of the service would have access to the same placeholders.
Use-cases
System such as Traefik can be configured via tags. For example here's a simple service called "whoami":
It's very common for people to copy a service definition like this and to forget to change the router/service name inside of the tags array. It would be nice if we could do something like:
The text was updated successfully, but these errors were encountered: