<p>I am using the RabbitMQ <a href="https://www.rabbitmq.com/kubernetes/operator/using-operator.html" rel="nofollow noreferrer">Kubernetes operator</a> for a dev-instance and it works great. What isn't great is that the credentials generated by the operator are different for everyone on the team (I'm guessing it generates random creds upon init).</p>
<p>Is there a way to provide a secret and have the operator use those credentials in place of the generated ones?</p>
<p>Yaml:</p>
<pre><code>apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: rabbitmq-cluster-deployment
  namespace: message-brokers
spec:
  replicas: 1
  service:
    type: LoadBalancer
</code></pre>
<p>Ideally, I can just configure some yaml to point to a secret and go from there. But, struggling to find the documentation around this piece.</p>
<p>Example Username/Password generated:</p>
<ul>
<li>user: default_user_wNSgVBIyMIElsGRrpwb</li>
<li>pass: cGvQ6T-5gRt0Rc4C3AdXdXDB43NRS6FJ</li>
</ul>

<p>I figured it out. Looks like you can just add a secret configured like the below example and it'll work. I figured this out by reverse engineering what the operator generated. So, please chime in if this is bad.</p>
<p>The big thing to remember is the <code>default_user.confg</code> setting. Other than that, it's just a secret.</p>
<pre><code>kind: Secret
apiVersion: v1
metadata:
  name: rabbitmq-cluster-deployment-default-user
  namespace: message-brokers
stringData:
  default_user.conf: |
    default_user = user123
    default_pass = password123
  password: password123
  username: user123
type: Opaque
</code></pre>
<p><code>rabbitmq-cluster-deployment-default-user</code> comes from the Deployment  <code>mdatadata.name</code> + <code>-default-user</code> (see yaml in question)</p>
<p><strong>UPDATE</strong></p>
<p>From the docs: <a href="https://github.com/rabbitmq/cluster-operator/tree/main/docs/examples/external-admin-secret-credentials" rel="nofollow noreferrer">https://github.com/rabbitmq/cluster-operator/tree/main/docs/examples/external-admin-secret-credentials</a></p>
<blockquote>
<p>When this externalSecret field is specified the default secret will
not be generated by the cluster operator but the statefulset will wait
until my-secret will be generated.</p>
</blockquote>
<pre><code>apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: external-secret-user
spec:
  service:
    type: LoadBalancer
  replicas: 1
  secretBackend:
    externalSecret: 
      name: &quot;my-secret&quot;
</code></pre>
<p>Example Secret:</p>
<pre><code>apiVersion: v1
data:
  default_user.conf: ZGVmYXVsdF91c2VyID0gZGVmYXVsdF91c2VyX2htR1pGaGRld3E2NVA0ZElkeDcKZGVmYXVsdF9wYXNzID0gcWM5OG40aUdEN01ZWE1CVkZjSU8ybXRCNXZvRHVWX24K
  host: dmF1bHQtZGVmYXVsdC11c2VyLmRlZmF1bHQuc3Zj
  password: cWM5OG40aUdEN01ZWE1CVkZjSU8ybXRCNXZvRHVWX24=
  port: NTY3Mg==
  provider: cmFiYml0bXE=
  type: cmFiYml0bXE=
  username: ZGVmYXVsdF91c2VyX2htR1pGaGRld3E2NVA0ZElkeDc=
kind: Secret
metadata:
  name: my-secret 
  namespace: rabbitmq-system
type: Opaque
</code></pre>
