2024-11-30Hünkar Döner

gRPC Routing on EKS: Management with Gateway API

gRPCEKSGateway APIRouting
g

gRPC Routing on EKS

The use of the high-performance gRPC protocol instead of JSON/REST between microservices is becoming increasingly common. However, since gRPC is based on HTTP/2, managing it with standard Load Balancer settings can sometimes be difficult.

The most modern way to manage gRPC traffic on Amazon EKS is to use the Gateway API and its GRPCRoute resource.

What is gRPC and Why is it Difficult?

gRPC uses long-lived TCP connections. Classic (L4) load balancers send this single connection to a pod and stick it there. As a result, one pod can be under 100% load while others lie idle (Load Imbalance). The solution is to use a proxy that understands gRPC at the L7 level.

GRPCRoute with Gateway API

The Gateway API standard offers the GRPCRoute resource in addition to HTTPRoute. This allows you to route based on gRPC methods and services.

Example: Routing the GetUserDetails method in MyService to the v2 service.

apiVersion: gateway.networking.k8s.io/v1alpha2
kind: GRPCRoute
metadata:
  name: user-service-route
spec:
  parentRefs:
  - name: my-gateway
  rules:
  - matches:
    - method:
        service: com.example.User
        method: GetUserDetails
    backendRefs:
    - name: user-service-v2
      port: 50051

With this configuration, the ingress controller on EKS (Envoy, etc.) balances gRPC requests on a per-request basis and performs method-based routing.