网关中未找到 VirtualService 主机

当虚拟服务中定义的host在相应的网关中找不到时,会发生此消息。

示例

您将收到此消息

Warning [IST0132] (VirtualService testing-service.default testing.yaml:8) one or more host [wrong.com] defined in VirtualService default/testing-service not found in Gateway istio-system/testing-gateway.

当您的集群具有以下虚拟服务时

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: testing-service
  namespace: default
spec:
  gateways:
  - istio-system/testing-gateway
  hosts:
  - wrong.com
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        host: ratings

以及以下网关时

apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: testing-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - testing.com
    port:
      name: http
      number: 80
      protocol: HTTP

在此示例中,虚拟服务testing-service的主机为wrong.com,它未包含在网关testing-gateway中。

如何解决

确保虚拟服务中的所有hosts都包含在绑定到虚拟服务的网关的hosts中。