<p>I've been struggling with this for quite a while now. My effort so far is shown below. The env variable, <code>CASSANDRA_AUTHENTICATOR</code>, in my opinion, is supposed to enable password authentication. However, I'm still able to logon without a password after redeploying with this config. Any ideas on how to enable password authentication in a Kubernetes deployment file?</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: cassandra
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: cassandra
    spec:
      containers:
          - name: cassandra
            image: cassandra
            env:
              - name: CASSANDRA_CLUSTER_NAME
                value: Cassandra
              - name: CASSANDRA_AUTHENTICATOR
                value: PasswordAuthenticator
            ports:
              - containerPort: 7000
                name: intra-node
              - containerPort: 7001
                name: tls-intra-node
              - containerPort: 7199
                name: jmx
              - containerPort: 9042
                name: cql

            volumeMounts:
              - mountPath: /var/lib/cassandra/data
                name: data
      volumes:
        - name: data
          emptyDir: {}
</code></pre>

<p>The environment is Google Cloud Platform.</p>

<p>So I made few changes to the artifact you have mentioned:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: cassandra
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: cassandra
    spec:
      containers:
          - name: cassandra
            image: bitnami/cassandra:latest
            env:
              - name: CASSANDRA_CLUSTER_NAME
                value: Cassandra
              - name: CASSANDRA_PASSWORD
                value: pass123
            ports:
              - containerPort: 7000
                name: intra-node
              - containerPort: 7001
                name: tls-intra-node
              - containerPort: 7199
                name: jmx
              - containerPort: 9042
                name: cql

            volumeMounts:
              - mountPath: /var/lib/cassandra/data
                name: data
      volumes:
        - name: data
          emptyDir: {}
</code></pre>

<p>The changes I made were:</p>

<p><code>image</code> name has been changed to <code>bitnami/cassandra:latest</code> and then replaced the <code>env</code> <code>CASSANDRA_AUTHENTICATOR</code> with <code>CASSANDRA_PASSWORD</code>.</p>

<p>After you deploy the above artifact then I could authenticate as shown below</p>

<ul>
<li><p>Trying to exec into pod</p>

<pre><code>fedora@dhcp35-42:~/tmp/cassandra$ oc exec -it cassandra-2750650372-g8l9s bash
root@cassandra-2750650372-g8l9s:/# 
</code></pre></li>
<li><p>Once inside the pod trying to authenticate with the server</p>

<pre><code>root@cassandra-2750650372-g8l9s:/# cqlsh 127.0.0.1 9042 -p pass123 -u cassandra
Connected to Cassandra at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.11.0 | CQL spec 3.4.4 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh&gt; 
</code></pre></li>
</ul>

<p>This image documentation can be found at <a href="https://hub.docker.com/r/bitnami/cassandra/" rel="nofollow noreferrer">https://hub.docker.com/r/bitnami/cassandra/</a></p>

<p>If you are not comfortable using the third party image and wanna use the image that upstream community manages then look for following solution, which is more DIY but also is more flexible.</p>

<hr>

<p>To setup the password you were trying to use the <code>env</code> <code>CASSANDRA_AUTHENTICATOR</code> but this is not merged proposal yet for the image <code>cassandra</code>. You can see the open PRs <a href="https://github.com/docker-library/cassandra/pull/41#issuecomment-174004501" rel="nofollow noreferrer">here</a>.</p>

<p>Right now the upstream suggest doing the mount of file <a href="https://raw.githubusercontent.com/apache/cassandra/trunk/conf/cassandra.yaml" rel="nofollow noreferrer"><code>cassandra.yaml</code></a> at <code>/etc/cassandra/cassandra.yaml</code>, so that people can set whatever settings they want.</p>

<p>So follow the steps to do it:</p>

<ul>
<li>Download the <a href="https://raw.githubusercontent.com/apache/cassandra/trunk/conf/cassandra.yaml" rel="nofollow noreferrer">cassandra.yaml</a></li>
</ul>

<p>I have made following changes to the file:</p>

<pre><code>$ diff cassandra.yaml mycassandra.yaml 
103c103
&lt; authenticator: AllowAllAuthenticator
---
&gt; authenticator: PasswordAuthenticator
</code></pre>

<ul>
<li>Create configmap with that file</li>
</ul>

<p>We have to create <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configmap/" rel="nofollow noreferrer">Kubernetes Configmap</a> which then we will mount inside the container, we cannot do host mount similar to docker.</p>

<pre><code>    $ cp mycassandra.yaml cassandra.yaml
    $ k create configmap cassandraconfig --from-file ./cassandra.yaml
</code></pre>

<p>The name of configmap is <code>cassandraconfig</code>.</p>

<ul>
<li><p>Now edit the <code>deployment</code> to use this config and mount it in right place</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: cassandra
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: cassandra
    spec:
      containers:
          - name: cassandra
            image: cassandra
            env:
              - name: CASSANDRA_CLUSTER_NAME
                value: Cassandra
            ports:
              - containerPort: 7000
                name: intra-node
              - containerPort: 7001
                name: tls-intra-node
              - containerPort: 7199
                name: jmx
              - containerPort: 9042
                name: cql

            volumeMounts:
              - mountPath: /var/lib/cassandra/data
                name: data
              - mountPath: /etc/cassandra/
                name: cassandraconfig
      volumes:
        - name: data
          emptyDir: {}
        - name: cassandraconfig
          configMap:
            name: cassandraconfig
</code></pre></li>
</ul>

<p>Once you create this deployment.</p>

<ul>
<li><p>Now exec in the pod </p>

<pre><code>$ k exec -it cassandra-1663662957-6tcj6 bash
root@cassandra-1663662957-6tcj6:/# 
</code></pre></li>
<li><p>Try using the client</p>

<pre><code>root@cassandra-1663662957-6tcj6:/# cqlsh 127.0.0.1 9042
Connection error: ('Unable to connect to any servers', {'127.0.0.1': AuthenticationFailed('Remote end requires authentication.',)})
</code></pre></li>
</ul>

<p>For more information on creating <code>configMap</code> and using it by mounting inside container you can read <a href="https://docs.openshift.org/latest/dev_guide/configmaps.html" rel="nofollow noreferrer">this doc</a>, which helped me for this answer.</p>
