-
Notifications
You must be signed in to change notification settings - Fork 17
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
Use traefik labels as label prefix #105
Comments
Not possible, you could create a snippet to "translate" traefik labels to autokuma ones to decrease duplication, but you'd still need to add a label to include the snippet in the given containers. |
Too bad! Is there a chance to get such a "mode" or is this a thing you don't want to support? |
I loved the idea |
A "traefik mode" is not possible since traefik uses multiple sources of information, i.e. the config file/env variables etc, the labels just don't contain all of the information. However I've added the ability to create snippets without the "kuma." prefix, this will allow creating a snippet tailored to whatever setup you have, see !Snippets |
That looks awesome @BigBoot will test it soon! Thank you! |
Was this just added? I was trying to get it to work and it didnt appear to be doing anything, I guess its not in the 0.8 release :) |
Just updated and configured this, works awesomely! Now I just need to enable the traefik label and it automatically created the autokuma using my customer snippet. Thanks :) |
This sounds like a super interesting and handy feature but its not really clear to me from the small section in the docs how one would actually use it... At least not for me and my pea sized brain :) |
@johntdyer Unfortunately it's not possible to create a one size fits all solution here, because autokuma just doesn't have all the same information as your traefik instance, so you might need to think a bit outside the box here and/or work with conventions on your setup to get everything you need. In the end you can access any label on your container using |
@BigBoot - thanks for getting back to me.... I guess what I am looking for here is a most complete practical example of how this feature might be used. I felt that was kind of lacking with whats currently provided.... Hope that makes sense |
Here is an example of what I have done for homepage. Create a traefik snippetThe following snippet overrides the default rule for a docker provider. It lets me override host and domain if I want, but otherwise falls back to defaults. providers:
docker:
endpoint: unix:///var/run/docker.sock
defaultRule: "Host(`\
{{ if (index .Labels \"service.host\") }}\
{{ index .Labels \"service.host\" }}\
{{ else }}\
{{ .ContainerName }}\
{{ end }}\
{{ if (index .Labels \"service.domain\") }}\
.{{ index .Labels \"service.domain\" }}\
{{ else }}\
.example.com\
{{ end }}`)"
exposedByDefault: false Create autokuma snippetThen in my autokuma's snippets:
"!traefik.enable": |
{% set label = container.Labels %}
{{ label["service.host"] }}.http.name: {{ label["service.host"] }}
{{ label["service.host"] }}.http.url: https://{{ label["service.host"] }}
{%- if label["service.domain"] %}.{{ label["service.domain"] }}{% else %}.example.com{% endif %}
{%- if label["service.path"] %}/{{ label["service.path"] }}{% endif %}
{% if label["service.group"] %}
{{ label["service.group"] }}.group.name: {{ label["service.group"] }}
{{ label["service.host"] }}.http.parent_name: {{ label["service.group"] }}
{% endif %} Define my serviceNow in my compose file for a service, I can define services:
homepage:
image: ghcr.io/gethomepage/homepage:latest
restart: unless-stopped
volumes:
- config:/app/config
labels:
service.host: "home"
service.group: "apps"
traefik.enable: "true"
volumes:
config: |
@ryanwinter I don't get it working, it seems my autokuma ignores my config file. Could you send me your compose file or commands to execute the container? Want to doublecheck my docker against yours. Thank you in advance! |
Hi and thank you for this awesome project!
I have several services running with one or more available webservers. Since I have around 30 docker containers running, I don't want to edit all of them manually and I tried to link autokuma with the traefik labels, because all available service have traefik labels.
Here are some of my labels
traefik.subdomain
is a custom tag to get rid of the boilerplate I have to set on each service for Traefik.But when I set
AUTOKUMA__DOCKER__LABEL_PREFIX
totraefik
autokuma throws exceptions likeWhich I understand, because the
traefik
labels doesn't match yourkuma.xyz
syntax.Do you have any idea how I can automatically create entries in UptimeKuma with these treafik labels?
The text was updated successfully, but these errors were encountered: