Search code examples
kubernetesgrpchaproxy-ingress

How to configure haproxy-ingress for serving GRPC


Has anyone successful in configuring Haproxy ingress controller for serving a GRPC server in the backend

GRPC Client ----> Ingress----> GRPC Server (k8s Service) --> GRPC Server( Pod)

I tried configuring as per the documentation here (https://www.haproxy.com/blog/haproxy-1-9-2-adds-grpc-support/ and https://haproxy-ingress.github.io/docs/configuration/keys/#backend-protocol)

It is not working as expected. Wanted to check if I have missed some configuration here


Solution

  • gRPC works on top of h2 and, for compatibility reasons, client and server need to agree about the http protocol version they want to speak. In haproxy this is done using alpn keyword in the bind line, which only works on TLS connections. By default HAProxy Ingress configures alpn with h2,http1.1, allowing h2 and gRPC out of the box in the client side - but only on https connections.

    If you're using plain http, client and server doesn't have a way to agree about a protocol, and the default version used is http1. You can overwrite this behavior configuring bind-http with :80 proto h2 but this should break http1 clients.