尽管目前Istio on GKE 创建的default ingress gateway 不支持 SDS,但您可以手动添加自己的额外入口网关。
您可以在istio-system 命名空间中获取默认istio-ingressgateway deployment 和service 的清单,并对其进行修改以添加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文件,修改如下:
- 将部署和服务的
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 的入口网关,您需要设置 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