GatewayPortNotDefinedOnService

消息名称GatewayPortNotDefinedOnService
消息代码IST0162
描述Gateway port not exposed by service
等级Warning

当 Gateway(通常是 istio-ingressgateway) 提供的端口与网关实例关联的 Kubernetes 服务(Service) 定义的端口不匹配时,GatewayPortNotDefinedOnService 消息将会出现。

例如,您的配置定义如下:

  1. # 端口定义错误的 Gateway
  2. apiVersion: networking.istio.io/v1alpha3
  3. kind: Gateway
  4. metadata:
  5. name: istio-ingressgateway
  6. spec:
  7. selector:
  8. istio: ingressgateway
  9. servers:
  10. - port:
  11. number: 80
  12. name: http
  13. protocol: HTTP
  14. hosts:
  15. - "*"
  16. - port:
  17. number: 8004
  18. name: http2
  19. protocol: HTTP
  20. hosts:
  21. - "*"
  22. ---
  23. # 默认的网关 Service
  24. apiVersion: v1
  25. kind: Service
  26. metadata:
  27. name: istio-ingressgateway
  28. spec:
  29. selector:
  30. istio: ingressgateway
  31. ports:
  32. - name: status-port
  33. port: 15021
  34. protocol: TCP
  35. targetPort: 15021
  36. - name: http2
  37. port: 80
  38. protocol: TCP
  39. targetPort: 8080
  40. - name: https
  41. port: 443
  42. protocol: TCP
  43. targetPort: 8443

在此示例中,因为配置使用了端口 8004,但默认的 IngressGateway (名称为 istio-ingressgateway)只定义了目标端口 15021、8080 和 8443, 所以 GatewayPortNotDefinedOnService 消息出现。

要解决此问题,请更改网关配置以使用工作负载上的有效端口,然后重试。

以下是已更正的示例:

  1. # 端口定义正确的 Gateway
  2. apiVersion: networking.istio.io/v1alpha3
  3. kind: Gateway
  4. metadata:
  5. name: istio-ingressgateway
  6. spec:
  7. selector:
  8. istio: ingressgateway
  9. servers:
  10. - port:
  11. number: 8080
  12. name: http2
  13. protocol: HTTP
  14. hosts:
  15. - "*"
  16. - port:
  17. number: 8443
  18. name: https
  19. protocol: HTTP
  20. hosts:
  21. - "*"