This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.6.2.2.2. 为 Kafka 代理配置 SASL 身份验证
Apache Kafka 使用 简单身份验证和安全层 (SASL)进行身份验证。如果在集群中使用 SASL 身份验证,用户则必须向 Knative 提供凭证才能与 Kafka 集群通信,否则无法生成或消耗事件。
先决条件
- 在 OpenShift Container Platform 上具有集群管理员权限。
-
OpenShift Serverless Operator、Knative Eventing 和
KnativeKafkaCR 已安装在 OpenShift Container Platform 集群中。 - 您已创建了一个项目,或者具有适当的角色和权限访问项目,以便在 OpenShift Container Platform 中创建应用程序和其他工作负载。
- 您有一个 Kafka 集群的用户名和密码。
-
您已选择使用 SASL 的机制,例如
PLAIN、SCRAM-SHA-256或SCRAM-SHA-512。 -
如果启用了 TLS,您还需要 Kafka 集群的
ca.crt证书文件。 -
安装 OpenShift CLI(
oc)。
流程
在
knative-eventing命名空间中创建证书文件作为 secret:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
使用键名
ca.crt,password, 和sasl.mechanism.不要更改它们。 如果要将 SASL 与公共 CA 证书搭配使用,您必须在创建 secret 时使用
tls.enabled=true标志,而不是使用ca.crt参数。例如:oc create secret -n <namespace> generic <kafka_auth_secret> \ --from-literal=tls.enabled=true \ --from-literal=password="SecretPassword" \ --from-literal=saslType="SCRAM-SHA-512" \ --from-literal=user="my-sasl-user"
$ oc create secret -n <namespace> generic <kafka_auth_secret> \ --from-literal=tls.enabled=true \ --from-literal=password="SecretPassword" \ --from-literal=saslType="SCRAM-SHA-512" \ --from-literal=user="my-sasl-user"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
使用键名
编辑
KnativeKafkaCR,并在brokerspec 中添加对 secret 的引用:Copy to Clipboard Copied! Toggle word wrap Toggle overflow