Server REST JSON Transcoding server Client Expensive maintenance cost 1. Parse JSON request 2. Transform JSON to gRPC Request 3. Send request to gRPC Server 4. Transcode gRPC response to JSON format 5. Send a response to the client It seems familiar!
and complexity Difficult to understand and manage Service Mesh Detach network logic from business logic Monolythic Microservice Microservice Proxy Microservice Proxy
example-transcoder namespace: example-namespace spec: workloadLabels: ... filters: - listenerMatch: listenerType: SIDECAR_INBOUND filterName: envoy.grpc_json_transcoder filterType: HTTP filterConfig: proto_descriptor: “path/to/bin” match_incoming_request_route: True auto_mapping: False services: - buzzvil.calendar.v1.CalendarApi Proto Descriptor Envoy has to know the proto descriptor of your gRPC service in order to the transcoding. $ protoc -I$(GOOGLEAPIS_DIR) -I. \ --include_imports \ --include_source_info \ --descriptor_set_out =proto.pb \ test/proto/bookstore.proto proto_descriptor: “path/to/bin”
Cr15ChVnb29nbGUvYXBpL2h0dHAucHJvdG8SCm... Proto Descriptor Bin $ cat proto.pb | openssl base64 -A Encode proto descriptor using base64 encoding, and set the value in yaml file
is mounted to istio-proxy container is not easy ◦ Automatic sidecar injection from istio-sidecar-injector is not dynamic enough(mounted volume contains all pb descriptors) ◦ Hard to control deployment timing • proto_descriptor_bin ◦ Lack of readability ◦ No volume dependency ◦ New transcoding configuration is applied as soon as EnvoyFilter is updated
blog.proto │ └── package.json └── user ├── user.proto └── package.json Mono Repository Approach • Create CI pipeline that generates & publishes language-specific artifacts • Common CI checks(lint, breaking changes warning) run for changed proto files • Reduced boilerplate! • Use lerna(node package) to bump versions of each API Generating protobuf descriptor artifact: protoc --include_imports --include_source_info --descriptor_set_out=blog.pb
path • kubectl port-forward didn’t work for testing out REST APIs • Arbitrary(non-JSON) message can be also supported by using google.api.HttpBody • grpc-status, grpc-message headers in response are useful when debugging Pitfalls & Tips
after then it becomes easy to develop any gRPC service that supports JSON transcoding • You can develop gRPC services while allowing other teams time to transition • API-First approach becomes standard throughout the organization • Over time, initial setup cost pays off