<p>I have managed to run one grpc service in a root path. But I tried to add more grpc service by adding custom path route in virtual service which doesn't work. Any help would be highly appreciated.</p>

<p>This is the gateway:</p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - "*"
</code></pre>

<p>I have this virtual service routing to only one grpc service and <strong>is working fine</strong></p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-virtual-svc
spec:
  hosts:
    - "*"
  gateways:
    - my-gateway
  http:
  - name: "my-grpc-1"
    match:
    - uri:
        prefix: "/"
    route:
    - destination:
        port:
          number: 9090
        host: my-grpc-1-svc
</code></pre>

<p>But I wanted to try something like below but <strong>it is not working</strong></p>

<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-virtual-svc
spec:
  hosts:
    - "*"
  gateways:
    - my-gateway
  http:
  - name: "my-grpc-1"
    match:
    - uri:
        prefix: "/my-grpc-1"
    route:
    - destination:
        port:
          number: 9090
        host: my-grpc-1-svc
  - name: "my-grpc-2"
    match:
    - uri:
        prefix: "/my-grpc-2"
    route:
    - destination:
        port:
          number: 9090
        host: my-grpc-2-svc
</code></pre>

Prata
<p>Here are some tips when working with grpc and istio (tested with istio 1.9.2).</p>
<p>1.Set protocol in service:</p>
<pre><code>kind: Service
metadata:
  name: my-grpc-service
spec:
  ports:
  - number: 9009
    appProtocol: grpc
</code></pre>
<p>2.set protocol in gateway:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  servers:
    - port:
        number: 80
        name: grpc
        protocol: GRPC
      hosts:
        - &quot;*&quot;
</code></pre>
<p>3.grpc generated uri path prefix will be the same as <code>package</code> value in .proto file:</p>
<pre><code>syntax = &quot;proto3&quot;;    
package somepath;
</code></pre>
<p>use it as <code>match.uri.prefix</code>:</p>
<pre><code>apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-virtual-svc
spec:
  http:
  - name: &quot;my-grpc-1&quot;
    match:
    - uri:
        prefix: &quot;/somepath&quot;
</code></pre>
