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

Supports full regexes when using Kubernetes as a backend #2408

Closed
kedare opened this issue Nov 14, 2017 · 4 comments
Closed

Supports full regexes when using Kubernetes as a backend #2408

kedare opened this issue Nov 14, 2017 · 4 comments

Comments

@kedare
Copy link

kedare commented Nov 14, 2017

Do you want to request a feature or report a bug?

Feature

What did you do?

When trying to setup a pseudo wildcard or a regex on a Kubernetes ingress, the Kubernetes validation on the "host" field reject anything complicated (That is supported by Traefik, like regexes)

Example of ingress controller

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: templates-ssr-ingress
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.backend.circuitbreaker.expression: "NetworkErrorRatio() > 0.5"
spec:
  rules:
  - host: "npreview-{subdomain:[a-z]+}.xxxx.com"
    http:
      paths:
      - backend:
          serviceName: templates-ssr-service
          servicePort: 5050

What did you expect to see?

The correct information passed to Traefik, and the frontend set correctly

What did you see instead?

When trying to use regexes

The Ingress "templates-ssr-ingress" is invalid: spec.rules[0].host: Invalid value: "npreview-{subdomain:[a-z]+}.xxxx.com": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

When trying to use pseudo-wildcards

The Ingress "templates-ssr-ingress" is invalid: spec.rules[0].host: Invalid value: "npreview-*.xxx.com": a wildcard DNS-1123 subdomain must start with '*.', followed by a valid DNS subdomain, which must consist of lower case alphanumeric characters, '-' or '.' and end with an alphanumeric character (e.g. '*.example.com', regex used for validation is '\*\.[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')

Output of traefik version: (What version of Traefik are you using?)

v1.4.2 (as Kubernetes Ingress Controller)

What is your environment & configuration (arguments, toml, provider, platform, ...)?

Using Kubernetes as backend.
Traefik a Ingress Controller

If applicable, please paste the log output in debug mode (--debug switch)

No log to show as the config doesn't reach Traefik

@kedare
Copy link
Author

kedare commented Nov 14, 2017

Related to kubernetes/kubernetes#41881

@nmengin
Copy link
Contributor

nmengin commented Dec 21, 2017

WDYT @containous/kubernetes ?

@timoreimann
Copy link
Contributor

AFAIU, the upstream issue referenced in #2408 (comment) seems to block us from making the host field support arbitrary regular expressions. Only subdomains seem to be possible right now.

If the feature request is about full regex support (which is how I understand it, but correct me if I'm wrong @kedare), I see two options: drive a possible extension of the supported patterns upstream, or introduce a custom annotation that hosts whatever pattern we want to support. Personally I'm not too fond of the idea of coming up with yet another custom annotation -- the Ingress feature space is already fairly fractured.

We should also check how Nginx deals with the situation.

@dtomcej
Copy link
Contributor

dtomcej commented Oct 23, 2019

@kedare,

Unfortunately Kubernetes never moved forward with allowing regexes to be used in ingresses.

This forced many providers to move to CRDs to provide this functionality.

With the release of Traefik v2, the IngressRoute CRD supports full regex matching to provide this functionality.

For this reason, I will be closing this issue.

@dtomcej dtomcej closed this as completed Oct 23, 2019
@traefik traefik locked and limited conversation to collaborators Nov 23, 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

7 participants