Kafka在kubernetes上使用sasl.jaas.config配置jaas

克里斯·爱德华兹

我正在使用这张头盔图:https : //github.com/helm/charts/tree/master/incubator/kafka

并且这些覆盖在values.yaml中

configurationOverrides:
  advertised.listeners: |-
    EXTERNAL://kafka-${KAFKA_BROKER_ID}.host-removed:$((31090 + ${KAFKA_BROKER_ID}))
  listener.security.protocol.map: |-
    PLAINTEXT:SASL_PLAINTEXT,EXTERNAL:SASL_PLAINTEXT
  sasl.enabled.mechanisms: SCRAM-SHA-256
  auto.create.topics.enable: false
  inter.broker.listener.name: PLAINTEXT
  sasl.mechanism.inter.broker.protocol: SCRAM-SHA-256
  listener.name.EXTERNAL.scram-sha-256.sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="user" password="password";

基于此文档:https : //kafka.apache.org/documentation/#security_jaas_broker

(快速摘要)

Brokers may also configure JAAS using the broker configuration property sasl.jaas.config. The property name must be prefixed with the listener prefix including the SASL mechanism, i.e. listener.name.{listenerName}.{saslMechanism}.sasl.jaas.config. Only one login module may be specified in the config value. If multiple mechanisms are configured on a listener, configs must be provided for each mechanism using the listener and mechanism prefix

listener.name.sasl_ssl.scram-sha-256.sasl.jaas.config=org.apache.kafka.common.security.scram.ScramLoginModule required \
    username="admin" \
    password="admin-secret";

问题是,当我启动Kafka时,出现以下错误:

java.lang.IllegalArgumentException: Could not find a 'KafkaServer' or 'plaintext.KafkaServer' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set

根据优先顺序,如果未设置上述配置,则应使用静态jass文件。

If JAAS configuration is defined at different levels, the order of precedence used is:
  • 代理配置属性listener.name。{listenerName}。{saslMechanism} .sasl.jaas.config
  • 静态JAAS配置的{listenerName} .KafkaServer部分
  • 静态JAAS配置的KafkaServer部分

舵图不支持配置该jaas文件的方法,因此使用此属性似乎是理想的方法,我对配置错误的内容感到困惑。

注意:如果我禁用所有SASL并仅使用纯文本,则群集工作正常,但是在实际环境中效果不佳。

米凯尔之家

我们定义了2个监听器:PLAINTEXTEXTERNAL您已将两者都映射到了SASL_PLAINTEXT

这真的是您想要做的吗?还是您不希望PLAINTEXTSASL而是纯文本格式?

  • 如果您真的希望两者都成为SASL,则它们都需要JAAS配置。在您的问题中,我仅看到EXTERNAL的JAAS配置:

    listener.name.EXTERNAL.scram-sha-256.sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="user" password="password";
    

    当您映射PLAINTEXT到SASL_PLAINTEXT时,它还需要JAAS配置。您可以使用以下方式指定它:

     listener.name.PLAINTEXT.scram-sha-256.sasl.jaas.config: org.apache.kafka.common.security.scram.ScramLoginModule required username="user" password="password";
    
  • 如果您希望您的PLAINTEXT监听器实际上是不带SASL的纯文本,那么您需要更新监听器映射:

    listener.security.protocol.map: |-
      PLAINTEXT:PLAINTEXT,EXTERNAL:SASL_PLAINTEXT
    

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章