-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Feature/add filter by labels #134
Conversation
Uses autodiscovery to start groups of instances by their labels
9a9b783
to
964a738
Compare
🎉 This PR is included in version 1.4.0-beta.1 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Does this mean that all you would need to do is add the label to the container and Sablier would then stop and start it automatically as and when required? I'm confused because I thought you needed the container info to be in the dynamic config file because Traefik will not recognise the container when it's shutdown! |
So this mechanism is not related to Traefik exactly. Instead of specifying each individual name for your provider (which can differ per provider) you can specify a group name which gets fetched periodically in the background by the provider. |
So how does it work? Do I add the label and the middleware like this: |
As stated in my example, you have a new key on your configuration. It's not a breaking change so you can still use the
Please correct me if I'm wrong, but from my understanding the labels are attached to the container you actually want to shut down on demand right? - sablier.enable=true
- - traefik.http.middlewares.dynamic.plugin.sablier.names=sablier_dockerContainer
+ - traefik.http.middlewares.dynamic.plugin.sablier.group=default
- traefik.http.middlewares.dynamic.plugin.sablier.sablierUrl=http://sablier:10000/
- traefik.http.middlewares.dynamic.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.dynamic.plugin.sablier.dynamic.theme=hacker-terminal Note the If you want a custom group, you'd do the following: - sablier.enable=true
+ - sablier.group=mygroup
- - traefik.http.middlewares.dynamic.plugin.sablier.group=default
+ - traefik.http.middlewares.dynamic.plugin.sablier.group=mygroup
- traefik.http.middlewares.dynamic.plugin.sablier.sablierUrl=http://sablier:10000/
- traefik.http.middlewares.dynamic.plugin.sablier.sessionDuration=1m
- traefik.http.middlewares.dynamic.plugin.sablier.dynamic.theme=hacker-terminal Does it make sense? |
Thank you. I added that to one of my containers but nothing happens. Am I missing something? p.s. I'm running plugin v1.3 and the latest beta release of the container. |
Hi @tam481, You should always use the same version for the plugin and the docker image. There was an issue publishing the beta version on docker, I have to figure that out. If you use the beta version of the docker image you will have group scanning capabilities. However, if you do not use the beta version from the middleware, it won't be able to send the correct request stating the group. As the plugin is only registered for tags, please consider using The docker image version I'll fix the release process on tags for docker image, it should be less confusing in the future. |
I didn't realise that the plugin follows the main application. Thank you for that. Does this look correct for the plugin: experimental: |
Yes, I think it looks good. Provide the overall configuration so I can be sure that you configured everything right (traefik + sablier + service to set on demand) |
Here's my container config:
|
Had to edit it a few times to get it to display correctly. Sorry about that. |
From your input I can see that you are using docker provider, not swarm or kubernetes. Traefik has some limitation on this part. See https://github.com/acouvreur/sablier/tree/main/plugins/traefik#traefik-with-docker-classic Basically, all containers that are stopped are removed from the pool, thus all metadata attatched to them as labels. They build workaround for swarm and kubernetes but not for docker classic. You'll have to use a dynamic config file for traefik metadata. |
🎉 This PR is included in version 1.4.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
You can tag a container with the following:
And then use the Traefik middleware with the following
The API call allows now either "names" or "group" as a query parameter.
How to try it yourself when developing:
docker run -d --name=whoami --label "sablier.enable=true" whoami
You should now see whoami started.
The same steps can be reproduced for swarm.