网关端口未在服务上定义
当网关(通常为 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:
- "*"