文档

对等身份认证(Peer Authentication)

对等身份认证定义流量如何通过或不通过TLS隧道到达Sidecar。本文介绍对等身份认证的配置示例和字段说明。

配置示例

示例一:允许foo命名空间中所有的工作负载都使用mTLS

说明

对于网格级别的配置,命名空间namespace字段需设置为istio-system

apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: foo
spec:
  mtls:
    mode: STRICT

示例二:在foo命名空间中使用mTLS或者PlainText,但在finance应用中必须使用mTLS

apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: foo
spec:
  mtls:
    mode: PERMISSIVE
---
apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: foo
spec:
  selector:
    matchLabels:
      app: finance
  mtls:
    mode: STRICT

示例三:在foo命名空间的finance应用中必须使用mTLS,8080端口必须使用PlainText

apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: foo
spec:
  selector:
    matchLabels:
      app: finance
  mtls:
    mode: STRICT
  portLevelMtls:
    8080:
      mode: DISABLE

示例四:继承命名空间(或者网格级别)的配置,然后重写8080端口的配置

apiVersion: security.istio.io/v1beta1
kind: PeerAuthentication
metadata:
  name: default
  namespace: foo
spec:
  selector:
    matchLabels:
      app: finance
  mtls:
    mode: UNSET
  portLevelMtls:
    8080:
      mode: DISABLE

字段说明

PeerAuthentication

字段

类型

是否必须

说明

selector

WorkloadSelector

支持配置一组或者多组标签来选择配置生效的工作负载。标签的搜索范围仅限于当前资源的配置命名空间。

mtls

MutualTLS

工作负载的mTLS设置。如果未配置,将从更广范围的配置中继承。

说明

生效的优先级由高到低为:端口、工作负载、命名空间、全局。

portLevelMtls

map<uint32, MutualTLS>

端口级别的mTLS设置。仅当WorkloadSelector不为空时生效。

PeerAuthentication.MutualTLS

字段

类型

是否必须

说明

mode

Mode

为PeerAuthentication定义mTLS模式。

PeerAuthentication.MutualTLS.Mode

字段

说明

UNSET

从更广范围的配置中继承。如果更广的范围未配置,则默认为PERMISSIVE

说明

生效的优先级由高到低为:端口、工作负载、命名空间、全局。

DISABLE

Sidecar之间的连接使用PlainText模式。

PERMISSIVE

Sidecar之间的连接可以为PlainText或mTLS加密模式。

STRICT

Sidecar之间的连接使用mTLS模式,即必须提供客户端证书的TLS。

  • 本页导读 (1)
文档反馈