如何在现有 GKE 集群上启用 Istio SDS
How to enable Istio SDS on existing GKE cluster
我有一个安装了 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?
托管 Istio 每个设计将恢复任何自定义配置并再次禁用 SDS。所以,恕我直言,这是一个无用的场景。您可以在此 guide 之后手动启用 SDS,但请记住,配置只会保持活动状态 2-3 分钟。
目前 GKE 不支持在从头创建集群时启用 SDS。在 GKE 托管的 Istio 上,Google 希望能够 enable SDS on GKE clusters,但他们还没有该版本的 ETA。
但是,如果您使用非托管(开源)Istio,SDS 功能在 Istio roadmap 中,我认为它应该在 1.2 版本中可用,但不能保证。
根据 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...
- 创建命名空间:
kubectl create namespace istio-system
- 安装 Istio CRD:
helm template install/kubernetes/helm/istio-init --name istio-init --namespace istio-system | kubectl apply -f -
- 使用默认配置文件安装 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 -
- 在默认命名空间上启用 Istio sidecar 注入
kubectl label namespace default istio-injection=enabled
尽管目前 Istio on GKE
创建的 default ingress gateway
不支持 SDS,但您可以手动添加自己的额外入口网关。
您可以在 istio-system
命名空间中获取默认 istio-ingressgateway
deployment
和 service
的清单并修改它以添加 SDS 容器并更改名称和然后将其应用于您的集群。但这有点太繁琐了,有一个更简单的方法可以做到这一点:
首先下载 istio 的开源 helm chart(选择一个与你的 Istio on GKE 版本兼容的版本,在我的例子中,我的 Istio on GKE 是 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
文件,进行以下修改:
- 将部署和服务的
metadata.name
更改为其他内容,例如 istio-ingressgateway-sds
- 将部署和服务的
metadata.lables.istio
更改为其他内容,例如 ingressgateway-sds
- 将部署的
spec.template.metadata.labels
更改为类似于 ingressgateway-sds
- 将服务的
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 enabled ingressgateway,您需要设置 spec.selector.istio
以匹配您设置的。下面是一个 Gateway
资源使用 kubernetes 秘密作为 TLS 证书的例子:
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
我有一个安装了 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?
托管 Istio 每个设计将恢复任何自定义配置并再次禁用 SDS。所以,恕我直言,这是一个无用的场景。您可以在此 guide 之后手动启用 SDS,但请记住,配置只会保持活动状态 2-3 分钟。
目前 GKE 不支持在从头创建集群时启用 SDS。在 GKE 托管的 Istio 上,Google 希望能够 enable SDS on GKE clusters,但他们还没有该版本的 ETA。
但是,如果您使用非托管(开源)Istio,SDS 功能在 Istio roadmap 中,我认为它应该在 1.2 版本中可用,但不能保证。
根据 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...
- 创建命名空间:
kubectl create namespace istio-system
- 安装 Istio CRD:
helm template install/kubernetes/helm/istio-init --name istio-init --namespace istio-system | kubectl apply -f -
- 使用默认配置文件安装 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 -
- 在默认命名空间上启用 Istio sidecar 注入
kubectl label namespace default istio-injection=enabled
尽管目前 Istio on GKE
创建的 default ingress gateway
不支持 SDS,但您可以手动添加自己的额外入口网关。
您可以在 istio-system
命名空间中获取默认 istio-ingressgateway
deployment
和 service
的清单并修改它以添加 SDS 容器并更改名称和然后将其应用于您的集群。但这有点太繁琐了,有一个更简单的方法可以做到这一点:
首先下载 istio 的开源 helm chart(选择一个与你的 Istio on GKE 版本兼容的版本,在我的例子中,我的 Istio on GKE 是 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
文件,进行以下修改:
- 将部署和服务的
metadata.name
更改为其他内容,例如istio-ingressgateway-sds
- 将部署和服务的
metadata.lables.istio
更改为其他内容,例如ingressgateway-sds
- 将部署的
spec.template.metadata.labels
更改为类似于ingressgateway-sds
- 将服务的
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 enabled ingressgateway,您需要设置 spec.selector.istio
以匹配您设置的。下面是一个 Gateway
资源使用 kubernetes 秘密作为 TLS 证书的例子:
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