簡體   English   中英

OpenShift和Istio Gateway流量配置,以便使用外部域進行訪問

[英]OpenShift and Istio Gateway traffic configuration in order to access using an external a domain

在OpenShift上部署Istio 1.1.2之后,便有了一條istio-ingressgateway路由及其相關的服務和Pod。

我已成功使用該入口網關訪問應用程序,並使用*作為主機配置了網關和VirtualService。

但是,我想配置一個域(例如insuranceinc.es)來訪問該應用程序。 根據文檔,我具有以下Istio配置:

網關:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: insuranceinc-gateway
  namespace: istio-insuranceinc
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "insuranceinc.es"

VirtualService

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: insuranceinc
  namespace: istio-insuranceinc
spec:
  hosts:
    - insuranceinc.es
  gateways:
    - insuranceinc-gateway
  http:
    - route:
        - destination:
            host: insuranceinc-web
            port:
              number: 8080

如果我進行curl調用...

curl http://istio-ingressgateway-istio-system.apps.mycluster.com/login

...我可以在入口網關窗格中看到404錯誤:

[2019-04-12T15:27:51.765Z] "GET /login HTTP/1.1" 404 NR "-" 0 0 1 - "xxx" "curl/7.54.0" "xxx" "istio-ingressgateway-istio-system.apps.mycluster.com" "-" - - xxx -

這是有道理的,因為它不是來自insuranceinc.es主機的。 因此,我將curl更改為發送Host: insuranceinc.es標頭:

curl -H "Host: insuranceinc.es" http://istio-ingressgateway-istio-system.apps.mycluster.com/login

現在,我收到503錯誤,並且istio-ingressgateway窗格中沒有日志。

應用程序不可用

該應用程序當前不在此端點上處理請求。 它可能尚未啟動或仍在啟動。

這意味着該istio-ingressgateway路由-> service-> poc尚未處理該請求。

由於它是Openshift Route因此它必須需要一個Host標頭,其中包含路線host istio-ingressgateway-istio-system.apps.mycluster.com 實際上,如果我發送curl -H "Host: istio-ingressgateway-istio-system.apps.mycluster.com" http://istio-ingressgateway-istio-system.apps.mycluster.com/login它將由istio處理入口網關返回404。

因此,如何發送我的Host insuranceinc.es標頭並到達istio入口網關(實際上是OpenShift路由)?

您需要在istio-system名稱空間中創建一個openshift路由,以與您創建的主機名相關。

例如:

oc -n istio-system get routes
NAME              HOST/PORT                                            PATH      SERVICES               PORT      TERMINATION   WILDCARD
gateway1-lvlfn    insuranceinc.es                                                istio-ingressgateway   <all>                   None

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM