gloo
gloo copied to clipboard
grpc reflection not working when exposing multiple grpc services
Gloo Edge Version
1.12.x (latest stable)
Kubernetes Version
1.24.x
Describe the bug
While doing basic evaluation of grpc support at Gloo, I successfully followed the tutorial on exposing a grpc service on gloo, but the tutorial doesn't answer the obvious question: how to expose two grpc services. The tutorial instructs to set up a VirtualService like so:
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
name: grpc
namespace: gloo-system
spec:
virtualHost:
routes:
- matchers:
- prefix: /
routeAction:
single:
upstream:
name: default-foo-9999
namespace: gloo-system
and that has the grpcurl
discover the (one) service:
$ grpcurl -plaintext $(glooctl proxy address --port http) list
grpc.Foo
grpc.reflection.v1alpha.ServerReflection
So I add the second service by adding a (same prefix) rute like so :
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
name: grpc
namespace: gloo-system
spec:
virtualHost:
routes:
- matchers:
- prefix: /
routeAction:
single:
upstream:
name: default-foo-9999
namespace: gloo-system
- matchers:
- prefix: /
routeAction:
single:
upstream:
name: default-bar-9999
namespace: gloo-system
but that has the grpcurl
blind to the bar
service
$ grpcurl -plaintext $(glooctl proxy address --port http) list
grpc.Foo
grpc.reflection.v1alpha.ServerReflection
So, inspired by how kong does it, I manipulated the prefixes like so
apiVersion: gateway.solo.io/v1
kind: VirtualService
metadata:
name: grpc
namespace: gloo-system
spec:
virtualHost:
routes:
- matchers:
- - prefix: /
+ - prefix: /grpc.Foo
routeAction:
single:
upstream:
name: default-foo-9999
namespace: gloo-system
- matchers:
- - prefix: /
+ - prefix: /grpc.Bar
routeAction:
single:
upstream:
name: default-bar-9999
namespace: gloo-system
That has both grpc services exposed:
$ grpcurl -d '{"param": "foo"}' -plaintext -import-path ./services/bar -proto bar.proto $(glooctl proxy address --port http) grpc.Bar/Hello
{
"param": "Hello, I am bar!\n"
}
$ grpcurl -d '{"param": "foo"}' -plaintext -import-path ./services/foo -proto foo.proto $(glooctl proxy address --port http) grpc.Foo/Hello
{
"param": "Hello, I am foo!\n"
}
but the grpc server reflection ceases to work
$ grpcurl -plaintext $(glooctl proxy address --port http) list
Failed to list services: server does not support the reflection API
Steps to reproduce the bug
Unzip the attachment and follow its the README on "Boostrap" and then "Gloo Ingress" and you should be able invoke grpc foo and bar services:
$ grpcurl -d '{"param": "foo"}' -plaintext -import-path ./services/bar -proto bar.proto $(glooctl proxy address --port http) grpc.Bar/Hello
{
"param": "Hello, I am bar!\n"
}
$ grpcurl -d '{"param": "foo"}' -plaintext -import-path ./services/foo -proto foo.proto $(glooctl proxy address --port http) grpc.Foo/Hello
{
"param": "Hello, I am foo!\n"
}
but unable to use the reflection
$ grpcurl -plaintext $(glooctl proxy address --port http) list
Failed to list services: server does not support the reflection API
Expected Behavior
grpcurl -plaintext $(glooctl proxy address --port http) list
should list both services:
grpc.Bar
grpc.Foo
grpc.reflection.v1alpha.ServerReflection
Additional Context
No response
Will take a look
Hi, Did you manage to solve it?
This issue has been marked as stale because of no activity in the last 180 days. It will be closed in the next 180 days unless it is tagged "no stalebot" or other activity occurs.