如何在现有GKE群集上启用Istio SDS

时间:2019-08-13 12:15:17

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

我有一个已安装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?

3 个答案:

答案 0 :(得分:2)

每个设计的受管Istio将还原任何自定义配置,并再次禁用SDS。因此,恕我直言,这是一个无用的情况。您可以在此guide之后手动启用SDS,但请记住,该配置将仅在2-3分钟内保持活动状态。

当前,当从头开始创建集群时,GKE不支持启用SDS。在GKE托管的Istio上,Google希望拥有enable SDS on GKE clusters的功能,但该版本尚未提供ETA。

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

答案 1 :(得分:1)

根据卡洛斯的回答,我决定不使用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

答案 2 :(得分:0)

即使当前default ingress gateway创建的Istio on GKE不支持SDS,您也可以手动添加自己的额外入口网关。

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

首先下载istio的开源头盔图表(选择与您在GKE上的Istio兼容的版本,以我为例,我在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 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

Holla!您现在已经创建了具有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
相关问题