使用具有多个端口和协议的相同 Istio GateWay

Using the same Istio GateWay with multiple ports and protocols

我正在尝试使用两种不同的协议(GRPC 和 HTTP)配置 istio GateWay

现在,我有两个不同的网关,GRPC 和 HTTP 各一个,如下所示

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: gwgrpc
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 7878
      name: http
      protocol: GRPC
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: gwrest
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 7979
      name: http
      protocol: HTTP
    hosts:
    - "*"

是否可以使用不同协议和端口的同一个网关?

您应该可以将这两个网关结合起来。唯一的问题是您的两个端口具有相同的名称。像这样的东西应该有用。

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: gwgrpc
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 7878
      name: grpc
      protocol: GRPC
    hosts:
    - "*"
  - port:
      number: 7979
      name: http
      protocol: HTTP
    hosts:
    - "*"

您可能需要使用 this example 作为模板。同意@Frank:您需要更改名称。 这是示例配置的一小部分

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: my-gateway
spec:
  selector:
    app: my-gatweway-controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - uk.bookinfo.com
    - eu.bookinfo.com
    tls:
      httpsRedirect: true # sends 301 redirect for http requests
  - port:
      number: 443
      name: https
      protocol: HTTPS
    hosts:
    - uk.bookinfo.com
    - eu.bookinfo.com