According to the E
SPv2 repository - ESPv2 should support gRPC:
Google Cloud Platform ESPv2 is a service proxy which enables API management capabilities for JSON/REST or gRPC API services using Google Service Infrastructure. The current implementation uses Envoy as a service proxy.
I wanted to move the discussion here in hopes of gaining an understanding of whether or not ESPv2 actually does support gRPC at this time (on or off of Cloud Run), and if not, when it is planned to be implemented.
In my testing, I've been able to get ESPv2 to accept gRPC requests, but it doesn't seem to be routing them to the backend correctly. My backend is protected via IAP + TLS and ESPv1 seems to support this without issue.
--log_request_headers=true
--enable_debug
--tracing_sample_rate=1
--tracing_incoming_context=x-cloud-trace-context
--tracing_outgoing_context=traceparent
--backend_protocol=grpc
The log output shows that ESPv2 can accept gRPC requests, authenticate them appropriately, and try to contact the backend. From the log output below, it looks like it's falling to add Bearer authentication for IAP to the backend request and maybe having trouble connecting over TLS, but otherwise looks to support gRPC and does include the `x-endpoint-api-userinfo` header.
Here is the output of some of the applicable debug logs (highlighted to show indications of the requests progress):
23:21:32.803 27 envoy] [27][http][external/envoy/source/common/http/conn_manager_impl.cc:708] [C24][S12315280653272850522] request headers complete (end_stream=false):\n\':authority\', \'<my-service>-uc.a.run.app\'\n\':path\', \'/service.v1alpha.Interop/MutateFiles\'\n\':method\', \'POST\'\n\':scheme\', \'http\'\n\'content-type\', \'application/grpc\'\n\'user-agent\', \'grpc-go/1.26.0\'\n\'authorization\', \'Bearer <TOKEN-REMOVED>\'\n\'x-cloud-trace-context\', \'d610a57b2025d586dc2a0e0b45cda9c1/10536684767275038589;o=1\'\n\'x-forwarded-for\', \'<my-ip-removed>\'\n\'x-forwarded-proto\', \'https\'\n\'forwarded\', \'for=\"<my-ip-removed>\";proto=https\'\n\'content-length\', \'119\'\n\'te\', \'trailers\'
23:21:32.803 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/filter.cc:124] Called Filter : setDecoderFilterCallbacks
23:21:32.803 27 envoy] [27][filter][src/envoy/http/path_matcher/filter.cc:54] matched operation: service.v1alpha.Interop.MutateFiles
23:21:32.803 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/filter.cc:46] Called Filter : decodeHeaders
23:21:32.803 27 envoy] [27][jwt][bazel-out/k8-opt/bin/external/envoy/source/extensions/filters/http/jwt_authn/_virtual_includes/filter_config_interface/extensions/filters/http/jwt_authn/filter_config.h:117] use filter state value service.v1alpha.Interop.MutateFiles to find verifier.
23:21:32.803 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/authenticator.cc:107] JWT authentication starts (allow_failed=false)
23:21:32.803 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/authenticator.cc:127] Verifying JWT token of issuer api-signer@<project-id>.iam.gserviceaccount.com
23:21:32.804 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/authenticator.cc:245] JWT token verification completed with: OK
23:21:32.804 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/filter.cc:84] Called Filter : check complete OK
23:21:32.804 27 envoy] [27][filter][src/envoy/http/service_control/filter.cc:46] Called ServiceControl Filter : decodeHeaders
23:21:32.804 27 envoy] [27][filter][src/envoy/http/backend_auth/filter.cc:56] Found operation: service.v1alpha.Interop.MutateFiles
23:21:32.804 27 envoy] [27][filter][src/envoy/http/backend_routing/filter.cc:42] Found operation: service.v1alpha.Interop.MutateFiles
23:21:32.804 27 envoy] [27][filter][src/envoy/http/backend_routing/filter.cc:46] No backend routing rule found for operation service.v1alpha.Interop.MutateFiles
23:21:32.804 27 envoy] [27][router][external/envoy/source/common/router/router.cc:438] [C24][S12315280653272850522] cluster \'<my-service>-uc.a.run.app_local\' match for URL \'/service.v1alpha.Interop/MutateFiles\'
23:21:32.804 27 envoy] [27][router][external/envoy/source/common/router/router.cc:553] [C24][S12315280653272850522] router decoding headers:\n\':authority\', \'<my-service>-uc.a.run.app\'\n\':path\', \'/service.v1alpha.Interop/MutateFiles\'\n\':method\', \'POST\'\n\':scheme\', \'http\'\n\'content-type\', \'application/grpc\'\n\'user-agent\', \'grpc-go/1.26.0\'\n\'x-cloud-trace-context\', \'d610a57b2025d586dc2a0e0b45cda9c1/10536684767275038589;o=1\'\n\'x-forwarded-for\', \'<my-ip-removed>\'\n\'x-forwarded-proto\', \'https\'\n\'forwarded\', \'for=\"<my-ip-removed>\";proto=https\'\n\'content-length\', \'119\'\n\'te\', \'trailers\'\n\'x-request-id\', \'cf477066-b418-914d-8a3e-c0a624219021\'\n\'x-endpoint-api-userinfo\', \'<REMOVED>>\'\n\'x-envoy-expected-rq-timeout-ms\', \'15000\'\n\'traceparent\', \'00-d610a57b2025d586dc2a0e0b45cda9c1-98bdad355f38e5b7-01\'
23:21:32.804 27 envoy] [27][client][external/envoy/source/common/http/codec_client.cc:31] [C29] connecting
23:21:32.804 27 envoy] [27][connection][external/envoy/source/common/network/connection_impl.cc:707] [C29] connecting to 127.0.0.1:8082
23:21:32.804 27 envoy] [27][connection][external/envoy/source/common/network/connection_impl.cc:716] [C29] connection in progress
23:21:32.804 27 envoy] [27][http2][external/envoy/source/common/http/http2/codec_impl.cc:912] [C29] setting stream-level initial window size to 268435456
23:21:32.804 27 envoy] [27][http2][external/envoy/source/common/http/http2/codec_impl.cc:934] [C29] updating connection-level initial window size to 268435456
23:21:32.804 27 envoy] [27][pool][external/envoy/source/common/http/conn_pool_base.cc:20] queueing request due to no available connections
23:21:32.804 27 envoy] [27][http][external/envoy/source/common/http/conn_manager_impl.cc:1250] [C24][S12315280653272850522] request end stream
23:21:32.804 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/filter.cc:108] Called Filter : decodeData
23:21:32.804 27 envoy] [27][filter][src/envoy/http/service_control/filter.cc:100] Called ServiceControl Filter : decodeData
23:21:32.804 27 envoy] [27][connection][external/envoy/source/common/network/connection_impl.cc:564] [C29] delayed connection error: 111
23:21:32.804 27 envoy] [27][connection][external/envoy/source/common/network/connection_impl.cc:189] [C29] closing socket: 0
23:21:32.804 27 envoy] [27][client][external/envoy/source/common/http/codec_client.cc:88] [C29] disconnect. resetting 0 pending requests
23:21:32.804 27 envoy] [27][pool][external/envoy/source/common/http/http2/conn_pool.cc:152] [C29] client disconnected
23:21:32.804 27 envoy] [27][router][external/envoy/source/common/router/router.cc:914] [C24][S12315280653272850522] upstream reset: reset reason connection failure
23:21:32.804 27 envoy] [27][http][external/envoy/source/common/http/conn_manager_impl.cc:1347] [C24][S12315280653272850522] Sending local reply with details upstream_reset_before_response_started{connection failure}
23:21:32.804 27 envoy] [27][filter][src/envoy/http/service_control/filter.cc:122] Called ServiceControl Filter : encodeHeaders before
23:21:32.804 27 envoy] [27][http][external/envoy/source/common/http/conn_manager_impl.cc:1545] [C24][S12315280653272850522] encoding headers via codec (end_stream=true):\n\':status\', \'200\'\n\'content-type\', \'application/grpc\'\n\'grpc-status\', \'14\'\n\'grpc-message\', \'upstream connect error or disconnect/reset before headers. reset reason: connection failure\'\n\'date\', \'Thu, 09 Jan 2020 23:21:32 GMT\'\n\'server\', \'envoy\'
23:21:32.804 27 envoy] [27][http2][external/envoy/source/common/http/http2/codec_impl.cc:742] [C24] stream closed: 0
23:21:32.804 27 envoy] [27][jwt][external/envoy/source/extensions/filters/http/jwt_authn/filter.cc:39] Called Filter : onDestroy
23:21:32.804 27 envoy] [27][filter][src/envoy/http/service_control/filter.cc:38] Called ServiceControl Filter : onDestroy
23:21:32.804 27 envoy] [27][pool][external/envoy/source/common/http/http2/conn_pool.cc:174] [C29] destroying primary client
23:21:32.804 27 envoy] [27][filter][src/envoy/http/service_control/filter.cc:145] Called ServiceControl Filter : log
If anyone has an idea on how to make further progress on this or any details on gRPC support for ESPv2, please let me know!
Thank you,
Prateek