Istio 工作負載最小 TLS 版本設定

此任務說明如何為 Istio 工作負載設定最低 TLS 版本。 Istio 工作負載的最大 TLS 版本為 1.3。

設定 Istio 工作負載的最小 TLS 版本

  • 透過 istioctl 安裝 Istio,並設定最低 TLS 版本。在 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 版本已設定並如預期運作。

  • 部署兩個工作負載:httpbincurl。將它們部署到單一命名空間中,例如 foo。兩個工作負載都各自在前面執行一個 Envoy 代理。

    ZipZip
    $ 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 命名空間中刪除範例應用程式 curlhttpbin

$ kubectl delete -f samples/httpbin/httpbin.yaml -n foo
$ kubectl delete -f samples/curl/curl.yaml -n foo

從叢集中解除安裝 Istio

$ istioctl uninstall --purge -y

若要移除 fooistio-system 命名空間

$ kubectl delete ns foo istio-system
此資訊是否實用?
您是否有任何改進建議?

感謝您的回饋!