我正在尝试使用 SASL 验证我的 Kafka rest 代理,但我无法将本地 docker 编写中的配置转移到 Kubernetes。
我正在使用 JAAS 配置来实现这一点。我的 JAAS 文件看起来像这样。
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="rest"
password="rest-secret";
};
Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="rest"
password="restsecret";
};
然后在我的 docker 组合中,我已经完成了:
KAFKA_OPTS: -Djava.security.auth.login.config=/etc/kafka/secrets/rest_jaas.conf
我将如何将相同的逻辑转移到 Kubernetes?我尝试像这样传递 env 变量:
env:
- name: KAFKA_OPTS
value: |
KafkaClient {
org.apache.kafka.common.security.plain.PlainLoginModule required
username="rest"
password="rest-secret";
};
Client {
org.apache.zookeeper.server.auth.DigestLoginModule required
username="rest"
password="rest-secret";
};
但它仍然失败了。以下是我的日志所说的:
Error: Could not find or load main class KafkaClient
/bin/sh: 3: org.apache.kafka.common.security.plain.PlainLoginModule: not found
/bin/sh: 6: Syntax error: "}" unexpected
您的帮助将不胜感激。
将 Kafka JAAS 配置文件保存为 rest_jaas.conf。然后执行:
kubectl create secret generic kafka-secret --from-file=rest_jaas.conf
然后在部署中插入:
env:
- name: KAFKA_OPTS
value: -Djava.security.auth.login.config=/etc/kafka/secrets/rest_jaas.conf
volumeMounts:
- name: kafka-secret
mountPath: /etc/kafka/secrets
subPath: rest_jaas.conf
volumes:
- name: kafka-secret
secret:
secretName: kafka-secret