如何在路由器中为Istio Ingress网关配置传入端口

时间:2020-09-22 08:27:14

标签: kubernetes routes openshift kubernetes-ingress istio

我尝试使用openshift路由配置istio入口。据我了解,请求路径如下:

request -> route -> ingress service -> gateway -> virtual service -> app service -> app

因此,我应用以下配置:

Route.yml:

kind: Route
  ...
spec:
  host: my-app.com
    to:
      kind: Service
      name: ingress-service
      weight: 100
    port:
      targetPort: http
  ...

ingress-service.yml:

kind: Service
metadata:
  name: ingress-service
...
spec:
  ports:
    - name: status-port
      protocol: TCP
      port: 15020
      targetPort: 15020
    - name: http
      protocol: TCP
      port: 9080
      targetPort: 9080
  selector:
    app: ingressgateway
    istio: ingressgateway
  type: ClusterIP 

ingress-gateway.yml:

kind: Gateway
metadata:
  name: ingress-gw
...
spec:
  servers:
    - hosts:
        - my-app.com
      port:
        name: http
        number: 9080
        protocol: HTTP
  selector:
    istio: ingressgateway

ingress-virtual-service.yml

kind: VirtualService
...
spec:
  hosts:
    - my-app.com
  gateways:
    - ingress-gw
  http:
    - route:
      - destination:
          host: my-app
          port: 9080
  exportTo:
    - .

我没有在Ingressgateway Pod的部署中设置端口9080。而且有效。但是只有当我向http://my-app.com:80

发送请求时

我哪里出错了,如何使仅路径可访问http://my-app.com:9080

1 个答案:

答案 0 :(得分:2)

外部的公开端口号取决于OpenShift上的Router(HAProxy)Pod侦听端口。如果要使用9080端口而不是80,则应更改Router(HAProxy)窗格上的端口。或者,您可以处理LB上的端口号以使用其他端口号。

访问流程如下。

LB(80, 443) 
   -> Router pod(80, 443) 
      -> Ingress-Gateway pod
         -Through Gateway and VirtualService -> Backend pod