Kubernetes OpenShift和Istio网关流量配置,以便使用外部域进行访问

Kubernetes OpenShift和Istio网关流量配置,以便使用外部域进行访问,kubernetes,openshift,openshift-origin,istio,Kubernetes,Openshift,Openshift Origin,Istio,在OpenShift上部署Istio 1.1.2后,有一条Istio入口高速公路路线及其相关服务和pod 我已成功使用该入口网关访问应用程序,并使用*作为主机配置网关和虚拟服务 但是,我希望配置一个域,例如insuranceinc.es,以访问该应用程序。根据文档,我有以下Istio配置: 网关: apiVersion: networking.istio.io/v1alpha3 kind: Gateway metadata: name: insuranceinc-gateway name

在OpenShift上部署Istio 1.1.2后,有一条Istio入口高速公路路线及其相关服务和pod

我已成功使用该入口网关访问应用程序,并使用*作为主机配置网关和虚拟服务

但是,我希望配置一个域,例如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"
虚拟服务

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调用

curlhttp://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 -

这是有道理的,因为它不是来自保险公司的主机。因此,我将curl更改为发送一个
Host:insuranceinc.es
头:

curl-H“主机:保险公司”http://istio-ingressgateway-istio-system.apps.mycluster.com/login

现在我得到一个503错误,并且在istio入口通道吊舱中没有日志

申请表不可用 应用程序当前未在此终结点上为请求提供服务。它可能尚未启动或仍在启动

这意味着该请求尚未由istio ingressgateway route->service->poc处理

由于它是一个
Openshift路由
,因此必须需要一个包含路由主机的主机头
istio-ingresgateway-istio-system.apps.mycluster.com
。事实上,如果我发送
curl-H“Host:istio-ingresgateway istio-system.apps.mycluster.com”http://istio-ingressgateway-istio-system.apps.mycluster.com/login
它由返回404的istio入口网关处理


那么,如何发送我的Host insuranceinc.es标头并同时到达istio入口网关(实际上是一个OpenShift路由)?

您需要在istio系统名称空间中创建一个OpenShift路由,以与您创建的主机名相关联

例如:

oc -n istio-system get routes
NAME              HOST/PORT                                            PATH      SERVICES               PORT      TERMINATION   WILDCARD
gateway1-lvlfn    insuranceinc.es                                                istio-ingressgateway   <all>                   None
oc-n istio系统获取路由
名称主机/端口路径服务端口终止通配符
网关1 lvlfn保险公司es istio入口网关无

Thank you@Chris,这是文档中缺少的内容,但却是必需的。