Kubernetes HAProxy Ingress doesn't work without explicitly setting host header

12/19/2019

I followed the tutorial from https://www.haproxy.com/documentation/hapee/1-9r1/traffic-management/kubernetes-ingress-controller/ to setup the haproxy controller (community edition) and the "Echo Server" App that should be accessed.

When I run curl -L -H 'Host: echo.example.com' localhost:30884 I get the desired response

Request served by app-58f7d69f54-p2kq8

HTTP/1.1 GET /

Host: echo.example.com
User-Agent: curl/7.61.1
Accept: */*
X-Forwarded-For: 10.42.0.0

However if I just use curl -L echo.example.com:30884 I get the response default backend - 404 So apperently the request reaches the ingress controller, but the ingress controller doesn't know which host should be used.

Running kubectl get ing gives me

eignungstest              eignungstest.example.com          10.43.173.120   80      17h
kube-web-view             dashboard.example.com                             80      16h
web-ingress               echo.example.com                                  80      16h

it seems there is no address assigned, but running the same commands above with the host eignungstest.example.com I get the same results, so that should be of no relevance.

Is there a setting I'm missing that prevents the host header from being passed when I dont explicitly specify it?

-- danielr1996
haproxy
kubectl
kubernetes

1 Answer

12/19/2019

Ingress controller and ingress looks fine.

As you can see in your kubectl response the ingress is pointing to port 80 of that service which would pick up echo.example.com.

So it only knows about port 80 of echo.example.com, but when you try curl -L echo.example.com:30884, it is checking for that particular port and routing all the traffic to default backend.

Make sure you could directly curl -L echo.example.com, if it doesn't work check the service if the service has something similar.

spec:
  ports:
    - port: 80
      targetPort: 3001

You might have done the service part right as well. Hope this helps.

-- BinaryMonster
Source: StackOverflow