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

Support query matcher for kubernetes ingress #3840

Closed
gugu91 opened this issue Aug 30, 2018 · 4 comments
Closed

Support query matcher for kubernetes ingress #3840

gugu91 opened this issue Aug 30, 2018 · 4 comments

Comments

@gugu91
Copy link

gugu91 commented Aug 30, 2018

We would like to use traefik to route based on query string parameters (even a single one) over a k8s cluster. We would like to use a k8s ingress to configure this, as the services we would route to would be changing quite often (this would all be part of an A/B testing strategy)

From this line here: https://github.com/containous/traefik/blob/master/provider/kubernetes/kubernetes.go#L541 it looks like this is not supported.

Query matcher is part of the project itself, so was wondering if it would be a huge amount of work to support it. Also interested if you guys would see a PR supporting this in line with your objectives

@dtomcej
Copy link
Contributor

dtomcej commented Aug 30, 2018

Hello @gugu91,

Thanks for your interest in Traefik!

Unfortunately routing on non-path options is not something that is supported by the Kubernetes Ingress Spec (https://kubernetes.io/docs/concepts/services-networking/ingress/).

You are correct, in that Traefik can route via query strings, headers, and many other request components, but attempting to implement those routing rules into an ingress environment is not easy or ideal, as the interactions would be totally "custom" and not standardized to any spec.

The other major request is routing based on request headers, which is also absent from the ingress spec.

Unfortunately the only suggestion I can offer is to run a double proxy setup, with 3 instances of traefik, 2 as ingress controllers (with different labelselectors), and then run an instance of traefik with a static config routing based on query string to your appropriate ingress controllers. This may be able to accomplish what you want.

The other option would be to use the traefik.ingress.kubernetes.io/service-weights annotation in the 1.7 RC, to be able to route traffic between 2 services.

Hopefully these options will work for you.

Thanks again!

@dtomcej dtomcej closed this as completed Aug 30, 2018
@gugu91
Copy link
Author

gugu91 commented Aug 30, 2018

Hi @dtomcej,
Thanks for your quick response. In your opinion, would I be able to achieve the same goal with and endpoint redirect and one instance of Traefik?

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    regex = "^(.*)?(.*mvt=)(.*)&(.*)"
    replacement = "$1/mvt/$3?$2$3$4"

and setting up my ingress to do a path match on mvt/something?

@dtomcej
Copy link
Contributor

dtomcej commented Aug 30, 2018

Yes, that could work, and you could use PathPrefixStrip on your ingresses to strip that path out of your backend request, so its invisible to your app.

Make sure you check out (https://docs.traefik.io/configuration/entrypoints/#rewriting-url) for some pointers on syntax, in case you get unexpected results.

@gugu91
Copy link
Author

gugu91 commented Aug 31, 2018

Would this result in a 302 though?

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

4 participants