Rabbitmq : How to create RABBITMQ_ERLANG_COOKIE

12/22/2019

I'm trying to deploy a rabbitmq pod in my kubernetes. So I use the rabbitmq hosted by Google : https://github.com/GoogleCloudPlatform/rabbitmq-docker/blob/master/3/README.md#connecting-to-a-running-rabbitmq-container-kubernetes

In the documentation, it is said : Starting a RabbitMQ instance

Replace your-erlang-cookie with a valid cookie value. For more information, see RABBITMQ_ERLANG_COOKIE in Environment Variable.

Copy the following content to pod.yaml file, and run kubectl create -f pod.yaml.

apiVersion: v1
kind: Pod
metadata:
  name: some-rabbitmq
  labels:
    name: some-rabbitmq
spec:
  containers:
    - image: launcher.gcr.io/google/rabbitmq3
      name: rabbitmq
      env:
        - name: "RABBITMQ_ERLANG_COOKIE"
          value: "unique-erlang-cookie"

How could I generate the cookie erlang ? I find nothing after days of searching on internet. I have a rabbitmq installed in my windows, I never generated a cookie erlang.

Please how could I do ? Thanks

-- Teddy Kossoko
erlang
kubernetes
rabbitmq

1 Answer

12/22/2019

It's any unique value; the only constraint is that every connected instance of RabbitMQ (that is, every Pod in your StatefulSet) has the same cookie value.

A good way to specify this is with a Secret:

env:
  - name: RABBITMQ_ERLANG_COOKIE
    valueFrom:
      secretKeyRef:
        name: rabbitmq
        key: erlangCookie

This requires you to create the Secret. Just to bring this up, you can run a one-off imperative command to create a random Secret:

kubectl create secret generic rabbitmq \
  --from-literal=erlangCookie=$(dd if=/dev/urandom bs=30 count=1 | base64)

For actual production use you'd need to store that credential somewhere safe and be able to inject (or recreate) it at deployment time. Managing that is a little beyond the scope of this question.

-- David Maze
Source: StackOverflow