Demo of how to grab headers and trailers as part of a gRPC request using the Envoy proxy. This example is deployed as part of a kubernetes deployment and thus involves building a few yaml files.
The point of this project is to give an idea on how to develop & deploy a very simple gRPC client and server fronted by Envoy with an external processor allowing the interception of the request and response body & headers.
The reason specifically targeting trailers in this project is due to the fact that trailers are usually not thought about, nor even known about most of the time.
This project contains the following folders:
- client
- holds
main.go
grpc client and the associatedDockerfile
to host the binary on an Ubuntu image. A much smaller image can certaily be used due to Go's static linking not requiring much behind glibc. main.go
should be edited properly to ensure it is correctly targeting the service fronting Envoy/gRPC-server as needed
- holds
- server
- holds
main.go
grpc server and the associatedDockerfile
built the same way as the server
- holds
- externalprocessor
- holds
main.go
externalprocessor that receives bidirectional gRPC stream messages from Envoy. This processsor stream receives messages depending upon theenvoy.yaml
configuration. It is currently set to be sent request/response headers and trailers, therefore the stream should in total receive 4 messages. It's important to note that the following are from the perspective of the downstream and upstream service, the envoy proxy is transparent in this case.- request headers
- request trailers
- response headers
- response trailers
- holds
- pb
- holds associated protobuf Go code
- proto
- holds proto definitions
- envoy
- holds
envoy.yaml
configuration
- holds
- yaml
- holds
kubernetes
yaml files to alter/deploy
- holds
- scripts
- holds useful scripts
Steps to deploy:
- Build the client, server and external processor binaries as below via
make
targets - Upload the images to your registry, in testing it was ECR that was used
- Edit the yaml files to correctly target your uploaded images
- Deploy the yaml files to your cluster
- Open up 3 terminals, one for the each client/server/externalprocessor
- Start the server and externalprocessor binaries
- Start the client
make gen
- generate protobuf files and store in pb/
make clean
- clean pb/
folders
make build-client
- build client
make build-server
- build server
make build-external
- build external processor
If run properly, the externalprocessor should print out correctly request headers, request trailers (usually none), response headers and response trailers to stdout of that process/container.