Istio 工作负载最小 TLS 版本配置
此任务演示如何配置 Istio 工作负载的最小 TLS 版本。Istio 工作负载的最大 TLS 版本为 1.3。
配置 Istio 工作负载的最小 TLS 版本
通过带有最小 TLS 版本配置的
istioctl
安装 Istio。用于在istioctl install
命令中配置 Istio 的IstioOperator
自定义资源包含一个用于 Istio 工作负载的最小 TLS 版本的字段。minProtocolVersion
字段指定 Istio 工作负载之间 TLS 连接的最小 TLS 版本。在以下示例中,Istio 工作负载的最小 TLS 版本配置为 1.3。$ cat <<EOF > ./istio.yaml apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: meshConfig: meshMTLS: minProtocolVersion: TLSV1_3 EOF $ istioctl install -f ./istio.yaml
检查 Istio 工作负载的 TLS 配置
配置 Istio 工作负载的最小 TLS 版本后,您可以验证最小 TLS 版本是否已配置并按预期工作。
部署两个工作负载:
httpbin
和curl
。将它们部署到单个命名空间中,例如foo
。这两个工作负载都在每个前面运行一个 Envoy 代理。$ kubectl create ns foo $ kubectl apply -f <(istioctl kube-inject -f @samples/httpbin/httpbin.yaml@) -n foo $ kubectl apply -f <(istioctl kube-inject -f @samples/curl/curl.yaml@) -n foo
使用以下命令验证
curl
是否成功与httpbin
通信$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c curl -n foo -- curl http://httpbin.foo:8000/ip -sS -o /dev/null -w "%{http_code}\n" 200
在本例中,最小 TLS 版本配置为 1.3。要检查是否允许 TLS 1.3,您可以运行以下命令
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -alpn istio -tls1_3 -connect httpbin.foo:8000 | grep "TLSv1.3"
文本输出应包含
TLSv1.3
要检查是否不允许 TLS 1.2,您可以运行以下命令
$ kubectl exec "$(kubectl get pod -l app=curl -n foo -o jsonpath={.items..metadata.name})" -c istio-proxy -n foo -- openssl s_client -alpn istio -tls1_2 -connect httpbin.foo:8000 | grep "Cipher is (NONE)"
文本输出应包含
Cipher is (NONE)
清理
从 foo
命名空间删除示例应用程序 curl
和 httpbin
$ kubectl delete -f samples/httpbin/httpbin.yaml -n foo
$ kubectl delete -f samples/curl/curl.yaml -n foo
从集群中卸载 Istio
$ istioctl uninstall --purge -y
要删除 foo
和 istio-system
命名空间
$ kubectl delete ns foo istio-system