代码之家  ›  专栏  ›  技术社区  ›  Andor

一个istio入口网关和多个TLS网关

  •  1
  • Andor  · 技术社区  · 7 年前

    问题简介 :

    • 如果我尝试连接多个TLS网关(使用同一证书) 对于一个入口网关,只有一个TLS可以工作(最后一次申请)
    • 将多个非TLS网关连接到同一入口网关工作正常。

    :

    ✗ curl -I https://integration.domain.com
    HTTP/2 200 
    server: envoy
    [...]
    

    ✗ curl -vI https://staging.domain.com    
    * Rebuilt URL to: https://staging.domain.com/
    *   Trying 35.205.120.133...
    * TCP_NODELAY set
    * Connected to staging.domain.com (35.x.x.x) port 443 (#0)
    * ALPN, offering h2
    * ALPN, offering http/1.1
    * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
    * successfully set certificate verify locations:
    *   CAfile: /etc/ssl/certs/ca-certificates.crt
      CApath: /etc/ssl/certs
    * TLSv1.2 (OUT), TLS header, Certificate Status (22):
    * TLSv1.2 (OUT), TLS handshake, Client hello (1):
    * Unknown SSL protocol error in connection to staging.domain.com:443 
    * Curl_http_done: called premature == 1
    * stopped the pause stream!
    * Closing connection 0
    curl: (35) Unknown SSL protocol error in connection to staging.domain.com:443 
    

    事实

    我有一个通配符TLS cert(比如说'*.domain.com'),我把它作为一个秘密:

    kubectl create -n istio-system secret tls istio-ingressgateway-certs --key tls.key --cert tls.crt
    

    我将默认的istio入口网关连接到静态IP:

    apiVersion: v1
    kind: Service
    metadata:
      name: istio-ingressgateway
      namespace: istio-system
      annotations:
      labels:
        chart: gateways-1.0.0
        release: istio
        heritage: Tiller
        app: istio-ingressgateway
        istio: ingressgateway
    spec:
      loadBalancerIP: "35.x.x.x"
      type: LoadBalancer
      selector:
        app: istio-ingressgateway
        istio: ingressgateway
    [...]
    

    然后我在不同的名称空间中有两个网关,用于TLS通配符(staging.domain.com,integration.domain.com)中包含的两个域:

    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: domain-web-gateway
      namespace: staging
    spec:
      selector:
        istio: ingressgateway # use Istio default gateway implementation
      servers:
      - port:
          number: 443
          name: https
          protocol: HTTPS
        tls:
          mode: SIMPLE
          serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
          privateKey: /etc/istio/ingressgateway-certs/tls.key
        hosts:
        - "staging.domain.com"
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - "staging.domain.com"
    

    集成:

    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: domain-web-gateway
      namespace: integration
    spec:
      selector:
        istio: ingressgateway # use Istio default gateway implementation
      servers:
      - port:
          number: 443
          name: https
          protocol: HTTPS
        tls:
          mode: SIMPLE
          serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
          privateKey: /etc/istio/ingressgateway-certs/tls.key
        hosts:
        - "integration.domain.com"
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - "integration.domain.com"
    
    1 回复  |  直到 7 年前
        1
  •  5
  •   Andor    7 年前

    问题是您在由同一工作负载(选择器)管理的两个网关中对端口443使用相同的名称(https)。他们需要有唯一的名字。此限制已记录在案 here

    您只需更改第二个网关的名称即可解决此问题,例如:

    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: domain-web-gateway
      namespace: integration
    spec:
      selector:
        istio: ingressgateway # use Istio default gateway implementation
      servers:
      - port:
          number: 443
          name: https-integration
          protocol: HTTPS
        tls:
          mode: SIMPLE
          serverCertificate: /etc/istio/ingressgateway-certs/tls.crt
          privateKey: /etc/istio/ingressgateway-certs/tls.key
        hosts:
        - "integration.domain.com"
      - port:
          number: 80
          name: http
          protocol: HTTP
        hosts:
        - "integration.domain.com"