对等身份验证
对等身份验证
PeerAuthentication 定义了传入连接的双向 TLS (mTLS) 要求。
在 Sidecar 模式下,PeerAuthentication 决定是否允许或要求使用 mTLS 连接到 Envoy 代理 Sidecar。
在 Ambient 模式下,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
名称 | 描述 |
---|---|
UNSET | 从父级继承,如果有父级。否则被视为 |
DISABLE | 连接未被隧道化。 |
PERMISSIVE | 连接可以是明文或 mTLS 隧道。 |
STRICT | 连接为 mTLS 隧道(必须提供带有客户端证书的 TLS)。 |