gloo icon indicating copy to clipboard operation
gloo copied to clipboard

grpc reflection not working when exposing multiple grpc services

Open remster opened this issue 2 years ago • 1 comments

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

remster avatar Sep 11 '22 11:09 remster

Will take a look

chrisgaun avatar Sep 16 '22 16:09 chrisgaun

Hi, Did you manage to solve it?

ahoze-r7 avatar Jan 12 '23 12:01 ahoze-r7

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.

github-actions[bot] avatar Jun 05 '24 10:06 github-actions[bot]