-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Make it possible to use static segment backend names with the Docker provider #4723
Comments
This makes it possible to have constant backend names, see traefik#4723.
Use the user-provided value and the service name only as fallback inside segment-based backend names to make them user-configurable. This makes it possible to have constant backend names, see traefik#4723.
@ldez Thanks for the hints. Actually I already came across most of these. That is why I am open for discussion on how to make it possible to have both dynamic (scalable) and constant (fixed) backend names. Both PRs I just posted still allow dynamic backend names if the corresponding .backend label is not set. |
Note that in branch v1.7, we only accept bug-fixes. |
That is very unfortunate for me. Anything I can do to have a solution before / without migrating to v2?
|
You can try to use a custom template: https://docs.traefik.io/configuration/backends/docker/#docker
https://github.com/containous/traefik/blob/v1.7/templates/docker.tmpl |
Sorry, but I don't understand how I can influence the internal backend name via the template. To me it looks like $backendName is already setup outside of this template. And in another place it for some reason uses getBackendName instead. Could you please give me another pointer in the right direction? Thanks in advance! |
@dduportal thanks for considering it for v2, please see #4731 and #4732 for possible implementation variants. |
@mback2k sorry but @dduportal made a mistake: in the v2 the segments don't exist at all. it's a completely different approach. |
In the template, you can use sprig function and basic Golang template operations
|
@ldez thanks a lot, again. I managed to implement #4731 via the following template snippets: Backends:
Frontends:
|
Slightly updated version due to the fact that the backend label value must already be unique and it is therefore not required to always append the segment name. Backends:
Frontends:
|
Hi! I'm Træfiker 🤖 the bot in charge of tidying up the issues. Thanks again for your interest in Traefik! I'm glad to close the issue because I think that the question has been answered (Yes, I'm quite an advanced AI 😄) Join our Slack workspace for more community #support. |
@ldez Is @traefiker right in this case? Or is this something that still needs to be considered for v2 even though segments are no longer in use? |
yes Traefiker is right: v2 has a completely different approach, the label system has been rewritten. |
Do you want to request a feature or report a bug?
Feature
What did you expect to see?
I expected the Docker container/service label "traefik.{segment-name}.backend" to behave the same way as "traefik.backend". Its raw value should have been used as the backend name instead of it being prefixed with the service name.
I understand that the default is to include the service name to avoid naming conflicts due to duplicates. But wouldn't this already be achieved by including the segment name inside the backend name?
The function used for "traefik.backend" is getDefaultBackendName which either uses just the provided value or the service name.
The function used for "traefik.{segment-name}.backend" is getSegmentBackendName which either uses the provided value prefixed with the service name or the segment name prefixed with the service name. So the segment name is already, but only used in case no value was given.
I think the behaviour of getSegmentBackendName is not consistent and causes trouble with random container names showing up, e.g. in Prometheus metrics. I would like to see it aligned with getDefaultBackendName by using the provided value or the service name, each suffixed with the segment name instead of always including the service name.
Basically this would mean to use the segment instead of the service name with the provided value, and make the service name the default value.
Examples of label to backend name conversion at the moment:
Examples of label to backend name conversion with this feature request implemented:
This would make it possible to have static backend names by setting the .backend label. What do you think?
At the moment I am unable to really monitor the metrics produced by traefik from my docker services with prometheus and grafana due to random metric names.
The text was updated successfully, but these errors were encountered: