Routing traffic to outside Kubernetes using Traefik Ingress Controller

4/28/2020

I am using Traefik as ingress controller for my Kubernetes cluster. It is working fine, and as expected for all of the use-cases except one.

I have few services/applications, all serving on the same URL/Host, but on a different path.
Till now all the applications were deployed on EC2-VMs, behind an ALB, and routing rules were written in ALB.

Now I have migrated some applications to Kubernetes, and some are still deployed behind the ALB. I want all traffic to be served through traefik only, and traefik should route to applications inside Kubernetes and outside Kubernetes based on path rules.

I want to point my URL to traefik and have a rule something like(such that I can define one upstream as URL):

spec:
  rules:
  - host: my.url.com
    http:
      paths:
      - backend:
          serviceName: abc-service
          servicePort: tcp-80
        path: /abc
      - backend:
          serviceName: xyz-service
          servicePort: tcp-80
        path: /xyz
      - backend:
          serviceName: 12345-alb-url.ap-south-1.elb.amazonaws.com ##I am not sure what the key will be
          servicePort: tcp-80
        path: /123

Is this possible with traefik? I tried searching on traefik docs, and on google but couldn't find any relevant solution.

-- kadamb
kubernetes
networking
traefik
traefik-ingress
upstream-branch

1 Answer

4/30/2020

You can create an ExternalName-type Service for services deployed out of the cluster and forward traffic to the Service in the Ingress. See Type ExternalName .

-- kitt
Source: StackOverflow