GatewayPortNotDefinedOnService

當閘道器(通常是 istio-ingressgateway)提供的埠,不是由閘道器選取的 Kubernetes 服務工作負載所提供時,就會發生此訊息。

例如,您的 Istio 設定包含以下值

# Gateway with bogus ports

apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: istio-ingressgateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
  - port:
      number: 8004
      name: http2
      protocol: HTTP
    hosts:
    - "*"
---

# Default Gateway Service

apiVersion: v1
kind: Service
metadata:
  name: istio-ingressgateway
spec:
  selector:
    istio: ingressgateway
  ports:
  - name: status-port
    port: 15021
    protocol: TCP
    targetPort: 15021
  - name: http2
    port: 80
    protocol: TCP
    targetPort: 8080
  - name: https
    port: 443
    protocol: TCP
    targetPort: 8443

在此範例中,會發生 GatewayPortNotDefinedOnService 訊息,因為此設定使用埠 8004,但預設的 IngressGateway (名為 istio-ingressgateway) 僅在目標埠 15021、8080 和 8443 上開啟。

若要解決此問題,請變更您的閘道器設定以使用工作負載上的有效埠,然後重試。

以下是修正後的範例

# Gateway with correct ports

apiVersion: networking.istio.io/v1
kind: Gateway
metadata:
  name: istio-ingressgateway
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 8080
      name: http2
      protocol: HTTP
    hosts:
    - "*"
  - port:
      number: 8443
      name: https
      protocol: HTTP
    hosts:
    - "*"