首页 > 解决方案 > ISTIO GRPC 网关配置

问题描述

我正在尝试使用 GRPC 设置 ISTIO 网关。我使用的示例来自:https ://github.com/h3poteto/istio-grpc-example 。

此示例不包含网关。我添加了网关:

kind: Gateway
metadata:
  name: my-gateway
  namespace: istio-grpc-example
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: grpc-wildcard
      protocol: GRPC
    hosts:
    - "*"

并修改了 VirtualService:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: backend
  namespace: istio-grpc-example
spec:
  hosts:
    - "backend"
  gateways:
  - my-gateway
  http:
  - match:
    - port: 50051
    route:
    - destination:
        host: backend
        subset: v0
      weight: 90
    - destination:
        host: backend
        subset: v1
      weight: 10

还有什么我应该做的吗?我仍然无法通过网关...查询服务端点时收到错误。

谢谢!

标签: grpcistiogateway

解决方案


正如我在评论中提到的

您是否尝试过使用通配符主机?*而不是backend

您需要更改虚拟服务主机

spec:
  hosts:
    - "backend"

spec:
  hosts:
    - "*"

@Ondra 补充说他改变的另一件事是网关端口号

我将端口号从 80 更改为 31400,并将主机从“后端”更改为“*”。现在看起来一切正常。– 翁德拉


推荐阅读