How to enable traffic routing for frontend+backend servers in kubernetes cluster (traefik+k8s ingress controller)

5/1/2018

I'm looking for a recipe how to configure traefik and kubernetes ingress controller to use custom frontend and backend servers. These are not the frontends and backends used in traefik, but rather app servers we want to deploy ourselves to k8s. To clarify the idea here is how client request should looks like:

The client will place a call to http://a.b.c.com/app?params=bla First, it should be redirected to our frontend server for authentication and then to /app backend server to serve his/her request.

I was thinking about the following configuration:

Set entrypoint of traefik to be 443

[entryPoints]
 [entryPoints.http]
 address = ":80"
   [entryPoints.http.redirect]
    entryPoint = "https"
 [entryPoints.https]
 address = ":443"
  [entryPoints.https.tls]
    [[entryPoints.https.tls.certificates]]
    CertFile = "/ssl/server.crt"
    KeyFile = "/ssl/server.key"

this will redirect traffic to port 443. In ingress controller I may define path / to our frontend server running on k8s and /app to point to our backend server, e.g.

  rules:
  - host: "a.b.c.com"
    http:
      paths:
      - path: /
        backend:
          serviceName: frontend
          servicePort: 443
      - path: /app
        backend:
          serviceName: app
          servicePort: 8888

The problem is that I don't know if it is going to work since I define paths: / and /app in ingress controller and later is sub-path of the former. But want I want is really redirect traffic to frontend app server running on port 443. Then (after it will authenticate users) redirect traffic to backend server serving /app path.

Any advice?

Thanks, Valentin.

-- Valentin
kubernetes
traefik

0 Answers