Ingress gRPC Example

The example ingress configuration in grpc-ingress.yaml shows how to route gRPC traffic to backend services.

Deploy the Demo App

For this demo we will use GCP’s microservices demo app.

  1. $ kubectl apply -f https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/kubernetes-manifests.yaml

Since gRPC is binary-encoded, you also need the proto definitions for the gRPC services in order to make gRPC requests. Download this for the demo app:

  1. $ curl -o demo.proto https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/pb/demo.proto

Deploy GRPC Ingress

You’ll find the example Ingress definition in example/kubernetes/servicemesh/grpc-ingress.yaml.

  1. $ kubectl apply -f https://raw.githubusercontent.com/cilium/cilium/v1.12/examples/kubernetes/servicemesh/grpc-ingress.yaml

This defines paths for requests to be routed to the productcatalogservice and currencyservice microservices.

Just as in the previous HTTP Ingress Example, this creates a LoadBalancer service, and it may take a little while for your cloud provider to provision an external IP address.

  1. $ kubectl get ingress
  2. NAME CLASS HOSTS ADDRESS PORTS AGE
  3. grpc-ingress cilium * <IP address> 80 3d

Make gRPC Requests to Backend Services

To issue client gRPC requests you can use grpcurl.

  1. $ GRPC_INGRESS=$(kubectl get ingress grpc-ingress -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  2. # To access the currency service:
  3. $ grpcurl -plaintext -proto ./demo.proto $GRPC_INGRESS:80 hipstershop.CurrencyService/GetSupportedCurrencies
  4. #To access the product catalog service:
  5. $ grpcurl -plaintext -proto ./demo.proto $GRPC_INGRESS:80 hipstershop.ProductCatalogService/ListProducts