gRPC Bridge

Envoy gRPC

The gRPC bridge sandbox is an example usage of Envoy’s gRPC bridge filter. Included in the sandbox is a gRPC in-memory Key/Value store with a Python HTTP client. The Python client makes HTTP/1 requests through the Envoy sidecar process which are upgraded into HTTP/2 gRPC requests. Response trailers are then buffered and sent back to the client as a HTTP/1 header payload.

Another Envoy feature demonstrated in this example is Envoy’s ability to do authority base routing via its route configuration.

Building the Go service

To build the Go gRPC service run:

  1. $ pwd
  2. envoy/examples/grpc-bridge
  3. $ script/bootstrap.sh
  4. $ script/build.sh

Note: build.sh requires that your Envoy codebase (or a working copy thereof) is in $GOPATH/src/github.com/envoyproxy/envoy.

Docker compose

To run the docker compose file, and set up both the Python and the gRPC containers run:

$ pwd envoy/examples/grpc-bridge $ docker-compose pull $ docker-compose up –build

Sending requests to the Key/Value store

To use the Python service and send gRPC requests:

  1. $ pwd
  2. envoy/examples/grpc-bridge
  3. # set a key
  4. $ docker-compose exec python /client/client.py set foo bar
  5. setf foo to bar
  6. # get a key
  7. $ docker-compose exec python /client/client.py get foo
  8. bar
  9. # modify an existing key
  10. $ docker-compose exec python /client/client.py set foo baz
  11. setf foo to baz
  12. # get the modified key
  13. $ docker-compose exec python /client/client.py get foo
  14. baz

In the running docker-compose container, you should see the gRPC service printing a record of its activity:

  1. grpc_1 | 2017/05/30 12:05:09 set: foo = bar
  2. grpc_1 | 2017/05/30 12:05:12 get: foo
  3. grpc_1 | 2017/05/30 12:05:18 set: foo = baz