【问题标题】:How to enable Istio SDS on existing GKE cluster如何在现有 GKE 集群上启用 Istio SDS
【发布时间】:2019-08-13 12:15:17
【问题描述】:

我有一个安装了 Istio 插件的现有 GKE 集群,例如:

gcloud beta container clusters create istio-demo \
    --addons=Istio --istio-config=auth=MTLS_PERMISSIVE \
    --cluster-version=[cluster-version] \
    --machine-type=n1-standard-2 \
    --num-nodes=4

我正在关注this guide 安装cert-manager,以便从 Let's Encrypt 自动提供 TLS 证书。根据指南,Istio 需要启用 SDS,这可以在安装时完成:

helm install istio.io/istio \
       --name istio \
       --namespace istio-system \
       --set gateways.istio-ingressgateway.sds.enabled=true

由于我已经通过 GKE 安装了 Istio,如何在现有集群上启用 SDS?或者,是否可以使用gcloud CLI 在集群创建时启用 SDS?

【问题讨论】:

    标签: google-cloud-platform google-kubernetes-engine istio


    【解决方案1】:

    每个设计的托管 Istio 将恢复任何自定义配置并再次禁用 SDS。所以,恕我直言,这是一个无用的场景。您可以在此guide 之后手动启用 SDS,但请记住,配置将仅保持活动 2-3 分钟。

    目前 GKE 不支持在从头开始创建集群时启用 SDS。在 GKE 管理的 Istio 上,谷歌希望能够enable SDS on GKE clusters,但他们还没有该版本的 ETA。

    但是,如果您使用非托管(开源)Istio,SDS 功能在Istio roadmap 中,我认为它应该在 1.2 版本中可用,但不能保证。

    【讨论】:

    • 谢谢卡洛斯。这是我走的确切路线。我重新创建了没有 Istio 插件的 GKE 集群,然后手动安装了启用 SDS 的 Istio。我将在代码中发布一个单独的答案。
    【解决方案2】:

    尽管目前Istio on GKE 创建的default ingress gateway 不支持 SDS,但您可以手动添加自己的额外入口网关。

    您可以在istio-system 命名空间中获取默认istio-ingressgateway deploymentservice 的清单,并对其进行修改以添加SDS 容器并更改名称,然后将其应用于您的集群。但这有点太乏味了,有一种更简单的方法可以做到这一点:

    首先下载 istio 的开源 helm chart(选择一个与您的 Istio on GKE 版本兼容的版本,在我的情况下,我在 GKE 上的 Istio 是 1.1.3,我下载了开源 istio 1.1.17 并且它可以工作):

    curl -O https://storage.googleapis.com/istio-release/releases/1.1.17/charts/istio-1.1.17.tgz
    # extract under current working directory
    tar xzvf istio-1.1.17.tgz
    

    然后只为 ingressgateway 组件渲染 helm 模板:

    helm template istio/ --name istio \
    --namespace istio-system \
    -x charts/gateways/templates/deployment.yaml \
    -x charts/gateways/templates/service.yaml \
    --set gateways.istio-egressgateway.enabled=false \
    --set gateways.istio-ingressgateway.sds.enabled=true > istio-ingressgateway.yaml
    

    然后手动修改渲染后的istio-ingressgateway.yaml文件,修改如下:

    1. 将部署和服务的metadata.name 更改为istio-ingressgateway-sds 之类的其他名称
    2. 将部署和服务的metadata.lables.istio 更改为ingressgateway-sds 之类的其他名称
    3. 为部署更改spec.template.metadata.labels,类似于ingressgateway-sds
    4. 将服务的spec.selector.istio 更改为与ingressgateway-sds 相同的值

    然后将 yaml 文件应用到您的 GKE 集群:

    kubectl apply -f istio-ingressgateway.yaml
    

    喂!您现在已经创建了带有 SDS 的自己的 istio ingressgatway,您可以通过以下方式获取它的负载均衡器 IP:

    kubectl -n istio-system get svc istio-ingressgateway-sds
    

    要让您的Gateway 使用正确的启用 sds 的入口网关,您需要设置 spec.selector.istio 以匹配您设置的那个。以下是使用 kubernetes 机密作为 TLS 证书的 Gateway 资源示例:

    apiVersion: networking.istio.io/v1alpha3
    kind: Gateway
    metadata:
      name: gateway-test
    spec:
      selector:
        istio: ingressgateway-sds
      servers:
      - hosts:
        - '*.example.com'
        port:
          name: http
          number: 80
          protocol: HTTP
        tls:
          httpsRedirect: true
      - hosts:
        - '*.example.com'
        port:
          name: https
          number: 443
          protocol: HTTPS
        tls:
          credentialName: example-com-cert
          mode: SIMPLE
          privateKey: sds
          serverCertificate: sds
    

    【讨论】:

      【解决方案3】:

      根据 Carlos 的回答,我决定不使用 Istio on GKE 插件,因为将 Istio 用作托管服务时可用的自定义非常有限。

      我创建了一个标准的 GKE 集群...

      gcloud beta container clusters create istio-demo \
          --cluster-version=[cluster-version] \
          --machine-type=n1-standard-2 \
          --num-nodes=4
      

      然后手动安装 Istio...

      1. 创建命名空间:
      kubectl create namespace istio-system
      
      1. 安装 Istio CRD:
      helm template install/kubernetes/helm/istio-init --name istio-init --namespace istio-system | kubectl apply -f -
      
      1. 使用默认配置文件和我的必要自定义安装 Istio:
      helm template install/kubernetes/helm/istio --name istio --namespace istio-system \
          --set gateways.enabled=true \
          --set gateways.istio-ingressgateway.enabled=true \
          --set gateways.istio-ingressgateway.sds.enabled=true \
          --set gateways.istio-ingressgateway.externalTrafficPolicy="Local" \
          --set global.proxy.accessLogFile="/dev/stdout" \
          --set global.proxy.accessLogEncoding="TEXT" \
          --set grafana.enabled=true \
          --set kiali.enabled=true \
          --set prometheus.enabled=true \
          --set tracing.enabled=true \
        | kubectl apply -f -
      
      1. 在默认命名空间上启用 Istio sidecar 注入
      kubectl label namespace default istio-injection=enabled
      

      【讨论】:

        猜你喜欢
        • 2020-10-23
        • 1970-01-01
        • 2020-03-24
        • 2020-07-13
        • 1970-01-01
        • 1970-01-01
        • 2022-01-04
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多