Skip to content
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

Exclude some frontends in consul catalog #555

Closed
minhdanh opened this issue Jul 22, 2016 · 17 comments
Closed

Exclude some frontends in consul catalog #555

minhdanh opened this issue Jul 22, 2016 · 17 comments

Comments

@minhdanh
Copy link

There are some services in consul such as nomad, nomad-client, etc. that I want to exclude from the auto discovered frontends by consul catalog backend. Currently is there a way to prohibit those frontends (and theirs corresponding backends) from being included by consul catalog?

@keis
Copy link

keis commented Jul 22, 2016

You can add a traefik.enable=false tag to a service to exclude it

@minhdanh
Copy link
Author

Unfortunately Nomad, (and maybe some other services) registers itself with Consul without an option to specify a tag/label. So I think this is not a preferable way to exclude some system services from traefik.

@emilevauge
Copy link
Member

@minhdanh
Copy link
Author

That's not what I'm talking about. I can assign the tag with a nomad job, but not with Nomad itself. As when bootstrapping a Nomad cluster, Nomad register itself with Consul, so that other Nomad agents can refer to this Nomad service by using nomad.service.consul:4747. I want to exclude the Nomad service, not Nomad jobs' services.

@emilevauge
Copy link
Member

OK I see. Hum, then I don't see any way for traefik to filter those services... Any idea?

@minhdanh
Copy link
Author

I'm thinking of something like this in consul catalog backend configuration:

exclude_services = "nomad,redis"

Which will exclude the specified services. It'll be nice if exclude_services also supports regex. But I'm not sure this is the best way possible.

@emilevauge
Copy link
Member

In fact, there is already a way to do that, but it is not documented for now #479, we are waiting this issue #451 to be fixed to add documentation on constraints ;)

@minhdanh
Copy link
Author

I see. That looks cool. So I would be able to use a constraints directive to specify which frontends should be included and excluded, right?

@emilevauge
Copy link
Member

emilevauge commented Jul 22, 2016

Yep, and it already works, but the toml config have to be refined.
You can use it with traefik --consulcatalog --consulcatalog.constraints="tag==traefik" and then add a traefik tag on all the services you want to expose in traefik.

@minhdanh
Copy link
Author

Thank you.

@emilevauge
Copy link
Member

Can we close this one?

@minhdanh
Copy link
Author

Ok. Never mind. Closing.

@nhaumont
Copy link

nhaumont commented Jul 28, 2016

Hi

I tried the solution you provided:

You can use it with traefik --consulcatalog --consulcatalog.constraints="tag==traefik" and then add a traefik tag on all the services you want to expose in traefik.

And I cannot make it work, every time I set the constraints, it excludes all the services even if I have some in consul which have the traefik label like:

  "ServiceTags":[
     "traefik"
  ],

I'm starting traefik with the docker image (docker run -t traefik -c /dev/null --web --consul --consulcatalog.constraints=tag==traefik --logLevel=DEBUG)

Thanks

@nhaumont
Copy link

nhaumont commented Jul 29, 2016

Ok, I got it working, my mistake.
In consul, it has to be something like: "ServiceTags":["traefik.tags=traefik"]

@billykwooten
Copy link

@nhaumont That works perfectly in consul. Thanks!!

@bilke
Copy link

bilke commented Jun 19, 2019

@nhaumont 's solutions works but I would like to use Consuls default tags such as http as a constraint. I think the syntax for defining the Traefik tag is a bit weird in contrast to just plain tags such as http

service {
        tags = ["traefik.tags=traefik", "http"]
        ...
}

@emilevauge Can I somehow configure consulCatalog to use simple tags? I played with the prefix-parameter but this did not help... Thanks!

@dduportal
Copy link
Contributor

Hi @bilke , as Traefik v2.0 is currently worked on (alpha state), the behavior of the KV stores (as Consul Backends) might be subject to change, so stay tuned! You can track the work on the Kanban board on this repository (tab "Projects").

@traefik traefik locked and limited conversation to collaborators Sep 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants