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

Kubernetes default backend should work #1073

Closed
jimmycuadra opened this issue Jan 26, 2017 · 3 comments
Closed

Kubernetes default backend should work #1073

jimmycuadra opened this issue Jan 26, 2017 · 3 comments

Comments

@jimmycuadra
Copy link
Contributor

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

v1.1.2

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

traefik.toml:

defaultEntryPoints = ["http", "https"]

[entryPoints]

[entryPoints.http]
address = ":80"

[entryPoints.http.redirect]
entryPoint = "https"

[entryPoints.https]
address = ":443"

[entryPoints.https.tls]

[[entryPoints.https.tls.certificates]]
CertFile = "/etc/ssl/cert.pem"
KeyFile = "/etc/ssl/key.pem"

[kubernetes]
namespaces = []

[web]
address = ":8080"
ReadOnly = true

What did you do?

I'm trying to set up a Kubernetes ingress that matches all subdomains of my cluster's TLD that don't have other ingresses with an explicit host match. For example, if I have an ingress for the host "foo.example.com", then I want to send requests for that to service "foo". But if a request comes in for "bar.example.com", or any other subdomain that doesn't have its own ingress, I want the request to go to a default backend "catchall".

This is what I tried originally:

kind: "Ingress"
apiVersion: "extensions/v1beta1"
metadata:
  name: "catchall"
spec:
  rules:
    - host: "*.example.com"
      http:
        paths:
          - backend:
              serviceName: "catchall"
              servicePort: 80

After creating this ingress, the Traefik dashboard shows one frontend for ".example.com" with route ".example.com" and rule "Host:.example.com". One backend for ".example.com" shows up with all the correct endpoints for the "catchall" Kubernetes service. However, I get a 404 when making a request that I'd expect to work:

$ curl -i https://bar.example.com/
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
X-Content-Type-Options: nosniff
Date: Thu, 26 Jan 2017 23:07:21 GMT
Content-Length: 19

404 page not found

I then tried an ingress using a default backend, which should do what I want, according to the Kubernetes documentation:

kind: "Ingress"
apiVersion: "extensions/v1beta1"
metadata:
  name: "catchall"
spec:
  backend:
    serviceName: "catchall"
    servicePort: 80

But this results in no frontends or backends showing up in the Traefik dashboard.

Finally, I tried a variation of the first ingress, but left out the host:

kind: "Ingress"
apiVersion: "extensions/v1beta1"
metadata:
  name: "catchall"
spec:
  rules:
    - http:
        paths:
          - backend:
              serviceName: "catchall"
              servicePort: 80

The Traefik dashboard shows an unnamed frontend with an empty route and an empty rule. An unnamed backend shows up with all the endpoints for the "catchall" Kubernetes service. My test request then works as I'd expect:

$ curl -i https://bar.example.com
HTTP/1.1 302 Found
# ...

Is it intentional that the first two ingresses I tried didn't work as expected? Am I misunderstanding something? Or is this a problem with Traefik and/or Kubernetes? Thanks very much!

@evanluc
Copy link

evanluc commented Feb 1, 2017

From what I understand Kubernetes stable does not yet support wildcards. The change is upcoming in v1.6 and is supported in the alpha.

You are right about the default backend in the traefik ingress. It seems to have a bug. I got the default ingress to work as intended in the following way:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: default
spec:
  tls:
    - secretName: secret-cert
  rules:
    - http:
        paths:
          - path: /
            backend:
              serviceName: svc1
              servicePort: 443

Note the path: /

@errm
Copy link
Contributor

errm commented Feb 22, 2017

Yes the default backend should work, and that looks like a bug...

Wildcards in host was fixed in #1029 and will be in v1.2

@errm errm changed the title Subdomain wildcards in Kubernetes ingresses Kubernetes default backend should work Feb 22, 2017
@errm
Copy link
Contributor

errm commented Feb 22, 2017

Closing as default backend issue dupes #1051

@errm errm closed this as completed Feb 22, 2017
@ldez ldez added the kind/bug/confirmed a confirmed bug (reproducible). label Apr 29, 2017
@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

5 participants