GCE: Both TCP and HTTP load balancers on one IP

7/23/2016

I'm running a kubernetes application on GKE, which serves HTTP requests on port 80 and websocket on port 8080.

Now, HTTP part needs to know client's IP address, so I have to use HTTP load balancer as ingress service. Websocket part then has to use TCP load balancer, as it's clearly stated in docs that HTTP LB doesn't support it.

I got them both working, but on different IPs, and I need to have them on one.

I would expect that there is something like iptables on GCE, so I could forward traffic from port 80 to HTTP LB, and from 8080 to TCP LB, but I can't find anything like that. Anything including forwarding allows only one them.

I guess I could have one instance with nginx/HAproxy doing only this, but that seems like an overkill

Appreciate any help!

-- lobanovadik
google-cloud-platform
google-compute-engine
kubernetes
load-balancing
websocket

1 Answer

7/24/2016

There's not a great answer to this right now. Ingress objects are really HTTP only right now, and we don't really support multiple grades of ingress in a single cluster (though we want to).

GCE's HTTP LB doesn't do websockets yet.

Services have a flaw in that they lose the client IP (we are working on that). Even once we solve this, you won't be able to use GCE's L7 balancer because of the extra port you need.

The best workaround I can think of, and has been used by a number of users until we preserve source IP, is this:

Run your own haproxy or nginx or even your own app as a Daemonset on some or all nodes (label controlled) with HostPorts.

Run a GCE Network LB (outside of Kubernetes) pointing at the nodes with HostPorts.

Once we can properly preserve external IPs, you can turn this back into a plain Service.

-- Tim Hockin
Source: StackOverflow