connectrpc / envoy-demo

Demonstration of how to use the new Connect-gRPC Envoy filter, available in Envoy v1.26+.
Apache License 2.0
24 stars 7 forks source link

Add a k8s manifest/kustomize example. #2

Open johnlabarge opened 1 year ago

johnlabarge commented 1 year ago

Many of us have standardized on k8s for deploying things like this as that's how the ultimate production etc. environments are orchestrated.

Ideally demos like these would be setup for k8s rather than docker-compose which only really works locally.

timostamm commented 10 months ago

Hey John, I agree it would be nice to have k8s example.

But I think in practice, you might be running Istio, Countour or similar on top of Envoy, and the setup will look quite a bit different for each. This demo is specific to Connect/gRPC bridge, a feature we contributed to the Envoy project.

If you are new to Envoy, you might want to take a look at the documentation for Kubernetes here.

StevenACoffman commented 10 months ago

Choosing a protocol and how to route it!

In Choosing a protocol shows connect supports grpc-web as well, but I'm not getting a lot of information on how routing works for the different choices.


Connect protocol routing

Would we use traditional HTTP Routing? something else? Any example with any gateway or ingress or proxy would be clarifying.

The Connect protocol is a simple, POST-only protocol that works over HTTP/1.1 or HTTP/2. It takes the best portions of gRPC and gRPC-Web, including streaming, and packages them into a protocol that works equally well in browsers, monoliths, and microservices. The Connect protocol is what we think the gRPC Protocol should be. By default, JSON- and binary-encoded Protobuf is supported. Calling a Connect API is as easy as using curl:


# Try it out! This is a live demo!
curl \
    --header "Content-Type: application/json" \
    --data '{"sentence": "I feel happy."}' \
    https://demo.connectrpc.com/connectrpc.eliza.v1.ElizaService/Say

This makes me believe that routing for HTTP/1.1 or HTTP/2 for the Connect protocol would be based on the URL /connectrpc.eliza.v1.ElizaService.


gRPC Routing

In Kubernetes, the common Gateway API spec has experimental support GRPCRoute. AFAICT Envoy Gateway has the most mature support for Gateway API GRPCRoute of the implementations. At least GKE specifically recommends using Envoy as your gRPC gateway.

The source code for that tutorial is here


gRPC-web Routing options

There are two different options, and I'm not sure what the pros and cons of each are.

grpc-web option 1: grpc-web

In grpc-web, traditional HTTP URL routing works. For instance:

curl 'http://localhost:8080/grpc.gateway.testing.EchoService/Echo' 
-H 'Pragma: no-cache' 
-H 'X-User-Agent: grpc-web-javascript/0.1' 
-H 'Origin: http://localhost:8081' 
-H 'Content-Type: application/grpc-web+proto' 
-H 'Accept: */*' 
-H 'X-Grpc-Web: 1' 
-H 'Connection: keep-alive' --data-binary $'\x00\x00\x00\x00\x05\n\x03abc' --compressed

The URL /grpc.gateway.testing.EchoService would be routed to the service.

grpc-web option 2: gRPC bridging

Envoy also supports gRPC bridging where gRPC-web is translated to gRPC.