<p>I am trying to authenticate my Kafka rest proxy with SASL but I am having trouble transferring the configs made in my local docker compose to Kubernetes.</p>

<p>I am using JAAS configuration to achieve this.
My JAAS file looks like this.</p>

<pre><code>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";
};
</code></pre>

<p>and then in my docker compose I have done:</p>

<p><code>KAFKA_OPTS: -Djava.security.auth.login.config=/etc/kafka/secrets/rest_jaas.conf</code></p>

<p>How will I transfer this same logic to Kubernetes?
I have tried passing the env variable like this:</p>

<pre><code>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";
      };
</code></pre>

<p>but it still fails. Here is what my logs say:</p>

<pre><code>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
</code></pre>

<p>Your help will be highly appreciated.</p>

kevinsamoei
<p>Save your Kafka JAAS config file as rest_jaas.conf. Then execute:</p>

<pre><code>kubectl create secret generic kafka-secret --from-file=rest_jaas.conf
</code></pre>

<p>Then in your deployment you insert:</p>

<pre><code>      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
</code></pre>
