<p>I'm using this chart: <a href="https://github.com/helm/charts/tree/master/stable/rabbitmq" rel="noreferrer">https://github.com/helm/charts/tree/master/stable/rabbitmq</a> to deploy a cluster of 3 RabbitMQ nodes on Kubernetes. My intention is to have all the queues mirrored within 2 nodes in the cluster.</p>

<p>Here's the command I use to run Helm: <code>helm install --name rabbitmq-local -f rabbitmq-values.yaml stable/rabbitmq</code></p>

<p>And here's the content of <code>rabbitmq-values.yaml</code>:</p>

<pre><code>persistence:
  enabled: true

resources:
  requests:
    memory: 256Mi
    cpu: 100m

replicas: 3

rabbitmq:
  extraConfiguration: |-
    {
      "policies": [
        {
          "name": "queue-mirroring-exactly-two",
          "pattern": "^ha\.",
          "vhost": "/",
          "definition": {
            "ha-mode": "exactly",
            "ha-params": 2
          }
        }
      ]
    }
</code></pre>

<p>However, the nodes fail to start due to some parsing errors, and they stay in crash loop. Here's the output of <code>kubectl logs rabbitmq-local-0</code>:</p>

<pre><code>BOOT FAILED
===========

Config file generation failed:
=CRASH REPORT==== 23-Jul-2019::15:32:52.880991 ===
  crasher:
    initial call: lager_handler_watcher:init/1
    pid: &lt;0.95.0&gt;
    registered_name: []
    exception exit: noproc
      in function  gen:do_for_proc/2 (gen.erl, line 228)
      in call from gen_event:rpc/2 (gen_event.erl, line 239)
      in call from lager_handler_watcher:install_handler2/3 (src/lager_handler_watcher.erl, line 117)
      in call from lager_handler_watcher:init/1 (src/lager_handler_watcher.erl, line 51)
      in call from gen_server:init_it/2 (gen_server.erl, line 374)
      in call from gen_server:init_it/6 (gen_server.erl, line 342)
    ancestors: [lager_handler_watcher_sup,lager_sup,&lt;0.87.0&gt;]
    message_queue_len: 0
    messages: []
    links: [&lt;0.90.0&gt;]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 610
    stack_size: 27
    reductions: 228
  neighbours:

15:32:53.679 [error] Syntax error in /opt/bitnami/rabbitmq/etc/rabbitmq/rabbitmq.conf after line 14 column 1, parsing incomplete
=SUPERVISOR REPORT==== 23-Jul-2019::15:32:53.681369 ===
    supervisor: {local,gr_counter_sup}
    errorContext: child_terminated
    reason: killed
    offender: [{pid,&lt;0.97.0&gt;},
               {id,gr_lager_default_tracer_counters},
               {mfargs,{gr_counter,start_link,
                                   [gr_lager_default_tracer_counters]}},
               {restart_type,transient},
               {shutdown,brutal_kill},
               {child_type,worker}]
=SUPERVISOR REPORT==== 23-Jul-2019::15:32:53.681514 ===
    supervisor: {local,gr_param_sup}
    errorContext: child_terminated
    reason: killed
    offender: [{pid,&lt;0.96.0&gt;},
               {id,gr_lager_default_tracer_params},
               {mfargs,{gr_param,start_link,[gr_lager_default_tracer_params]}},
               {restart_type,transient},
               {shutdown,brutal_kill},
               {child_type,worker}]
</code></pre>

<p>If I remove the <code>rabbitmq.extraConfiguration</code> part, the nodes start properly, so it must be something wrong with the way I'm typing in the policy. Any idea what I'm doing wrong?</p>

<p>Thank you.</p>

<p>According to <a href="https://github.com/helm/charts/tree/master/stable/rabbitmq#load-definitions" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/rabbitmq#load-definitions</a>, it is possible to link a <code>JSON</code> configuration as <code>extraConfiguration</code>. So we ended up with this setup that works:</p>

<p><strong>rabbitmq-values.yaml:</strong></p>

<pre><code>rabbitmq:
  loadDefinition:
    enabled: true
    secretName: rabbitmq-load-definition
  extraConfiguration:
    management.load_definitions = /app/load_definition.json
</code></pre>

<p><strong>rabbitmq-secret.yaml:</strong></p>

<pre><code>apiVersion: v1
kind: Secret
metadata:
  name: rabbitmq-load-definition
type: Opaque
stringData:
  load_definition.json: |-
    {
      "vhosts": [
        {
          "name": "/"
        }
      ],
      "policies": [
        {
          "name": "queue-mirroring-exactly-two",
          "pattern": "^ha\.",
          "vhost": "/",
          "definition": {
            "ha-mode": "exactly",
            "ha-params": 2
          }
        }
      ]
    }
</code></pre>

<p>The secret must be loaded into Kubernetes before the Helm chart is played, which goes something like this: <code>kubectl apply -f ./rabbitmq-secret.yaml</code>.</p>
