Deterministic routing with key to a gRPC service in Kubernetes Deterministic routing with key to a gRPC service in Kubernetes kubernetes kubernetes

Deterministic routing with key to a gRPC service in Kubernetes


In this case you need layer 7 (L7) load balancer because they operate at the application layer and can inspect traffic in order to make routing decisions. Most importantly, they can support the HTTP/2 protocol (which gRPC uses).

Nginx and HAProxy are one of the options for L7 load balancers, but too heavyweight to microservice architecture. You can think about Envoy and Linkerd, both have support for gRPC.

Pods can be replicated to provide scaling and are wrapped in abstractions known as services which provide a stable IP address for accessing the underlying pods. Since Kubernetes 1.2 the default behaviour on hitting a service IP is that a random backend pod will be returned. However you can reconfigure your services to be headless so that the service IP will instead return the entire list of available pod IPs, allowing you to perform your own service discovery.

You can easily start with Linkerd with this official tutorial.