4.2.2. 用户身份验证
使用 KafkaUser.spec 中的 身份验证 属性配置用户身份验证。为用户启用的身份验证机制使用 type 字段指定。
支持的验证机制:
- TLS 客户端身份验证
- SCRAM-SHA-512 验证
如果没有指定身份验证机制,User Operator 不会创建用户或其凭证。
4.2.2.1. TLS 客户端身份验证
要使用 TLS 客户端身份验证,请将 type 字段设置为 tls。
启用了 TLS 客户端身份验证的 KafkaUser 示例
apiVersion: kafka.strimzi.io/v1beta1
kind: KafkaUser
metadata:
name: my-user
labels:
strimzi.io/cluster: my-cluster
spec:
authentication:
type: tls
# ...
当 User Operator 创建用户时,它会创建一个名称与 KafkaUser 资源相同的新 Secret。Secret 包含用于 TLS 客户端身份验证的私钥和公钥。公钥包含在用户证书中,由客户端证书颁发机构(CA)签名。
所有键均采用 X.509 格式。
secret 以 PEM 和 PKCS #12 格式提供私钥和证书。
有关保护 Kafka 与 Secret 的通信的更多信息,请参阅 第 11 章 管理 TLS 证书。
带有用户凭证的 Secret 示例
apiVersion: v1
kind: Secret
metadata:
name: my-user
labels:
strimzi.io/kind: KafkaUser
strimzi.io/cluster: my-cluster
type: Opaque
data:
ca.crt: # Public key of the client CA
user.crt: # User certificate that contains the public key of the user
user.key: # Private key of the user
user.p12: # PKCS #12 archive file for storing certificates and keys
user.password: # Password for protecting the PKCS #12 archive file