Traefik ingress is not working behind aws load balancer

5/14/2018

After I created a traefik daemonset, I created a service as loadbalancer on port 80, which is the Traefik proxy port and the node got automatically registered to it. If i hit the elb i get the proxy 404 which is OK because no service is registered yet

I then created a nodeport service for the web-ui. targeted port 8080 inside the pod and 80 on clusterip. I can curl the traefik ui from inside the cluster and it retruns traefik UI

I then created an ingress so that when i hit elb/ui it gets me to the backend web-ui service of traefik and it fails. I also have the right annotations in my ingress but the elb does not route the path to the traefik ui in the backend which is running properly

What am i doing wrong here? I can post all my yml files if required

UPD

My yaml files:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: traefik
  labels:
    app: traefik
spec:
  template:
    metadata:
      labels:
        app: traefik
    spec:
      containers:
      - image: traefik
        name: traefik
        args:
        - --api
        - --kubernetes
        - --logLevel=INFO
        - --web
        ports:
        - containerPort: 8080
          name: traefikweb
        - containerPort: 80
          name: traefikproxy


apiVersion: v1
kind: Service
metadata:
  name: traefik-proxy
spec:
  selector:
    app: traefik
  ports:
  - port: 80
    targetPort: traefikproxy
  type: LoadBalancer


apiVersion: v1
kind: Service
metadata:
  name: traefik-web-ui
spec:
  selector:
    app: traefik
  ports:
  - name: http
    targetPort: 8080
    nodePort: 30001
    port: 80
  type: NodePort


apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  namespace: default
  name: traefik-ing
  annotations:
    kubernetes.io/ingress.class: traefik
    #traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip:/ui
spec:
  rules:
  - http:
      paths:
      - path: /ui
        backend:
          serviceName: traefik-web-ui
          servicePort: 80
-- user3493900
amazon-elb
amazon-web-services
kubernetes
kubernetes-ingress
traefik

2 Answers

3/28/2019

If you are on Private_Subnets use

kind: Service
metadata:
  name: traefik-proxy
> annotations:
>     "service.beta.kubernetes.io/aws-load-balancer-internal": "0.0.0.0/0"
spec:
  selector:
    app: traefik
  ports:
  - port: 80
    targetPort: traefikproxy
  type: LoadBalancer``` 
-- Arsen
Source: StackOverflow

5/15/2018

I then created an ingress so that when i hit elb/ui it gets me to the backend web-ui service of traefik and it fails."

How did it fail? Did you get error 404, error 500, or something else?

Also, for traefik-web-ui service, you don't need to set type: NodePort, it should be type: ClusterIP.

When you configure backends for your Ingress, the only requirement is availability from inside a cluster, so ClusterIP type will be more than enough for that.

Your service should be like that:

apiVersion: v1
kind: Service
metadata:
  name: traefik-web-ui
spec:
  selector:
    app: traefik
  ports:
  - name: http
    targetPort: 8080
    port: 80

Option PathPrefixStrip can be useful because without it request will be forwarded to UI with /ui prefix, which you definitely don't want.

All other configs look good.

-- Anton Kostenko
Source: StackOverflow