PeerAuthentication
PeerAuthentication
PeerAuthentication 定義了傳入連線的相互 TLS (mTLS) 要求。
在邊車模式中,PeerAuthentication 決定是否允許或需要使用 mTLS 連線至 Envoy 代理邊車。
在環境模式中,ztunnel 節點代理會透明地為 Pod 啟用安全性。(代理之間的流量使用 HBONE 協定,其中包括使用 mTLS 加密。) 因此,不支援 DISABLE
模式。STRICT
模式有助於確保無法建立繞過網格的連線。
範例
在命名空間 foo
下要求所有工作負載使用 mTLS 流量的原則
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: foo
spec:
mtls:
mode: STRICT
對於網格層級,請根據您的 Istio 安裝將原則放置在根命名空間中。
允許命名空間 foo
下的所有工作負載同時使用 mTLS 和純文字流量,但要求工作負載 finance
使用 mTLS 的原則。
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: foo
spec:
mtls:
mode: PERMISSIVE
---
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: finance
namespace: foo
spec:
selector:
matchLabels:
app: finance
mtls:
mode: STRICT
對所有 finance
工作負載啟用嚴格 mTLS,但保留連接埠 8080
為純文字的原則。請注意,portLevelMtls
欄位中的連接埠值是指工作負載的連接埠,而非 Kubernetes 服務的連接埠。
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: foo
spec:
selector:
matchLabels:
app: finance
mtls:
mode: STRICT
portLevelMtls:
8080:
mode: DISABLE
從命名空間 (或網格) 設定繼承 mTLS 模式,並停用工作負載連接埠 8080
的 mTLS 的原則。
apiVersion: security.istio.io/v1
kind: PeerAuthentication
metadata:
name: default
namespace: foo
spec:
selector:
matchLabels:
app: finance
mtls:
mode: UNSET
portLevelMtls:
8080:
mode: DISABLE
PeerAuthentication.MutualTLS
相互 TLS 設定。
PeerAuthentication.MutualTLS.Mode
名稱 | 描述 |
---|---|
未設定 | 若有父級設定,則繼承父級設定。否則視為 |
停用 | 連線不使用通道傳輸。 |
寬鬆 | 連線可以是純文字或 mTLS 通道。 |
嚴格 | 連線是 mTLS 通道(必須提供帶有用戶端憑證的 TLS)。 |