gRPC Bridge

    This is an example of a key-value store where an -based client CLI, written in Python, updates a remote store, written in Go, using the stubs generated for both languages.

    The client send messages through a proxy that upgrades the HTTP requests from http/1.1 to http/2.

    [client](http/1.1) -> [client-egress-proxy](http/2) -> [server-ingress-proxy](http/2) -> [server]

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

    The following documentation runs through the setup of Envoy described above.

    Ensure that you have a recent versions of docker and docker-compose installed.

    A simple way to achieve this is via the Docker Desktop.

    SSH

    HTTPS

    1. git clone https://github.com/envoyproxy/envoy.git

    A docker-compose file is provided that generates the stubs for both client and server from the specification in the protos directory.

    Inspecting the docker-compose-protos.yaml file, you will see that it contains both the python and go gRPC protoc commands necessary for generating the protocol stubs.

    Generate the stubs as follows:

    1. $ pwd
    2. envoy/examples/grpc-bridge
    3. Starting grpc-bridge_stubs_python_1 ... done
    4. Starting grpc-bridge_stubs_go_1 ... done
    5. grpc-bridge_stubs_go_1 exited with code 0
    6. grpc-bridge_stubs_python_1 exited with code 0

    You may wish to clean up left over containers with the following command:

    1. $ docker container prune

    You can view the generated kv modules for both the client and server in their respective directories:

    To build this sandbox example and start the example services, run the following commands:

    1. $ pwd
    2. envoy/examples/grpc-bridge
    3. $ docker-compose pull
    4. $ docker-compose up --build -d
    5. $ docker-compose ps
    6. Name Command State Ports
    7. grpc-bridge_grpc-client-proxy_1 /docker-entrypoint.sh /bin ... Up 10000/tcp, 0.0.0.0:9911->9911/tcp, 0.0.0.0:9991->9991/tcp
    8. grpc-bridge_grpc-client_1 /bin/sh -c tail -f /dev/null Up
    9. grpc-bridge_grpc-server_1 /bin/sh -c /bin/server Up 0.0.0.0:8081->8081/tcp

    To use the Python service and send gRPC requests:

    1. $ pwd
    2. envoy/examples/grpc-bridge

    Set a key:

    1. $ docker-compose exec python /client/client.py set foo bar
    2. setf foo to bar

    Get a key:

    Modify an existing key:

    1. $ docker-compose exec python /client/client.py set foo baz
    2. setf foo to baz

    Get the modified key:

    1. $ docker-compose exec python /client/client.py get foo
    2. baz

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

    1. $ docker-compose logs grpc-server
    2. grpc_1 | 2017/05/30 12:05:09 set: foo = bar
    3. grpc_1 | 2017/05/30 12:05:12 get: foo
    4. grpc_1 | 2017/05/30 12:05:18 set: foo = baz