<p>I deployed a <strong>rabbitmq</strong> instance using the <strong>rabbitmq operator</strong> in <strong>kubernetes</strong>. And I'm trying to enable the <em><strong>rabbitmq plugin:</strong></em> <strong>rabbitmq_delayed_message_exchange</strong>.</p>
<p>I tried defining my <strong>RabbitmqCluster</strong> as:</p>
<pre><code>apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: definition
spec:
  replicas: 1
  rabbitmq:
    additionalPlugins:
      - rabbitmq_management
      - rabbitmq_delayed_message_exchange
  service:
    type: LoadBalancer
</code></pre>
<p>And then I ran <code>kubectl apply -f definition.yaml</code></p>
<p>But my <strong>pod logs</strong> showed this:</p>
<pre><code>...
2020-10-05T15:42:15.081783023Z 2020-10-05 15:42:15.081 [info] &lt;0.535.0&gt; Server startup complete; 6 plugins started.
2020-10-05T15:42:15.081802701Z  * rabbitmq_prometheus
2020-10-05T15:42:15.08180602Z  * rabbitmq_peer_discovery_k8s
2020-10-05T15:42:15.081808816Z  * rabbitmq_peer_discovery_common
2020-10-05T15:42:15.081811359Z  * rabbitmq_management
2020-10-05T15:42:15.08181387Z  * rabbitmq_web_dispatch
2020-10-05T15:42:15.081825082Z  * rabbitmq_management_agent
2020-10-05T15:42:15.081951576Z  completed with 6 plugins.
...
</code></pre>
<p>There <strong>wasn't any reference</strong> to this <strong>plugin</strong> in the <strong>logs</strong>.</p>
<p>I went inside my rabbitmq pod and ran: <strong>rabbitmq-plugins list</strong></p>
<pre><code>Listing plugins with pattern &quot;.*&quot; ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: * = running on rabbit@definition-rabbitmq-server-0.definition-rabbitmq-headless.default
 |/
[  ] rabbitmq_amqp1_0                  3.8.8
[  ] rabbitmq_auth_backend_cache       3.8.8
[  ] rabbitmq_auth_backend_http        3.8.8
[  ] rabbitmq_auth_backend_ldap        3.8.8
[  ] rabbitmq_auth_backend_oauth2      3.8.8
[  ] rabbitmq_auth_mechanism_ssl       3.8.8
[  ] rabbitmq_consistent_hash_exchange 3.8.8
[  ] rabbitmq_event_exchange           3.8.8
[  ] rabbitmq_federation               3.8.8
[  ] rabbitmq_federation_management    3.8.8
[  ] rabbitmq_jms_topic_exchange       3.8.8
[E*] rabbitmq_management               3.8.8
[e*] rabbitmq_management_agent         3.8.8
[  ] rabbitmq_mqtt                     3.8.8
[  ] rabbitmq_peer_discovery_aws       3.8.8
[e*] rabbitmq_peer_discovery_common    3.8.8
[  ] rabbitmq_peer_discovery_consul    3.8.8
[  ] rabbitmq_peer_discovery_etcd      3.8.8
[E*] rabbitmq_peer_discovery_k8s       3.8.8
[E*] rabbitmq_prometheus               3.8.8
[  ] rabbitmq_random_exchange          3.8.8
[  ] rabbitmq_recent_history_exchange  3.8.8
[  ] rabbitmq_sharding                 3.8.8
[  ] rabbitmq_shovel                   3.8.8
[  ] rabbitmq_shovel_management        3.8.8
[  ] rabbitmq_stomp                    3.8.8
[  ] rabbitmq_top                      3.8.8
[  ] rabbitmq_tracing                  3.8.8
[  ] rabbitmq_trust_store              3.8.8
[e*] rabbitmq_web_dispatch             3.8.8
[  ] rabbitmq_web_mqtt                 3.8.8
[  ] rabbitmq_web_mqtt_examples        3.8.8
[  ] rabbitmq_web_stomp                3.8.8
[  ] rabbitmq_web_stomp_examples       3.8.8
</code></pre>
<p>and checked the <strong>pod plugins/ directory</strong>:</p>
<pre><code>README
accept-0.3.5.ez
amqp10_client-3.8.8.ez
amqp10_common-3.8.8.ez
amqp_client-3.8.8.ez
aten-0.5.5.ez
base64url-0.0.1.ez
cowboy-2.6.1.ez
cowlib-2.7.0.ez
credentials_obfuscation-2.2.0.ez
cuttlefish-2.4.1.ez
eetcd-0.3.3.ez
gen_batch_server-0.8.4.ez
getopt-1.0.1.ez
goldrush-0.1.9.ez
gun-1.3.3.ez
jose-1.10.1.ez
jsx-2.11.0.ez
lager-3.8.0.ez
observer_cli-1.5.4.ez
prometheus-4.6.0.ez
ra-1.1.6.ez
rabbit-3.8.8.ez
rabbit_common-3.8.8.ez
rabbitmq_amqp1_0-3.8.8.ez
rabbitmq_auth_backend_cache-3.8.8.ez
rabbitmq_auth_backend_http-3.8.8.ez
rabbitmq_auth_backend_ldap-3.8.8.ez
rabbitmq_auth_backend_oauth2-3.8.8.ez
rabbitmq_auth_mechanism_ssl-3.8.8.ez
rabbitmq_aws-3.8.8.ez
rabbitmq_consistent_hash_exchange-3.8.8.ez
rabbitmq_event_exchange-3.8.8.ez
rabbitmq_federation-3.8.8.ez
rabbitmq_federation_management-3.8.8.ez
rabbitmq_jms_topic_exchange-3.8.8.ez
rabbitmq_management-3.8.8.ez
rabbitmq_management_agent-3.8.8.ez
rabbitmq_mqtt-3.8.8.ez
rabbitmq_peer_discovery_aws-3.8.8.ez
rabbitmq_peer_discovery_common-3.8.8.ez
rabbitmq_peer_discovery_consul-3.8.8.ez
rabbitmq_peer_discovery_etcd-3.8.8.ez
rabbitmq_peer_discovery_k8s-3.8.8.ez
rabbitmq_prelaunch-3.8.8.ez
rabbitmq_prometheus-3.8.8.ez
rabbitmq_random_exchange-3.8.8.ez
rabbitmq_recent_history_exchange-3.8.8.ez
rabbitmq_sharding-3.8.8.ez
rabbitmq_shovel-3.8.8.ez
rabbitmq_shovel_management-3.8.8.ez
rabbitmq_stomp-3.8.8.ez
rabbitmq_top-3.8.8.ez
rabbitmq_tracing-3.8.8.ez
rabbitmq_trust_store-3.8.8.ez
rabbitmq_web_dispatch-3.8.8.ez
rabbitmq_web_mqtt-3.8.8.ez
rabbitmq_web_mqtt_examples-3.8.8.ez
rabbitmq_web_stomp-3.8.8.ez
rabbitmq_web_stomp_examples-3.8.8.ez
ranch-1.7.1.ez
recon-2.5.1.ez
stdout_formatter-0.2.4.ez
syslog-3.4.5.ez
sysmon_handler-1.3.0.ez
</code></pre>
<p>So it means that the <strong>plugin doesn't come integrated</strong>.</p>
<p>I also found this:</p>
<p><a href="https://stackoverflow.com/questions/51096003/how-to-install-rabbitmq-plugin-on-kubernetes">How to install rabbitmq plugin on kubernetes?</a></p>
<p>But there is <strong>no reference</strong> to the <strong>rabbitmq operator</strong> and it was asked in <strong>Jun 2018</strong>. Also in the rabbitmq operator config there isn't any reference on using lifecycle hooks to mount the ez file.</p>
<p><strong>1 idea</strong> that comes to my mind is creating my own <strong>rabbitmq image</strong> referencing the <strong>rabbitmq official image</strong> and add the plugin.</p>
<pre><code>FROM rabbitmq:3.8.8-management

RUN apt-get update

RUN apt-get install -y curl

RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v3.8.0/rabbitmq_delayed_message_exchange-3.8.0.ez &gt; $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.8.0.ez

RUN chown rabbitmq:rabbitmq $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.8.0.ez

RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange

RUN rabbitmq-plugins enable --offline rabbitmq_consistent_hash_exchange
</code></pre>
<p>A <strong>2nd idea</strong> is to mount the file in the pod file directory by defining a configmap with the file and using volumeMounts but I couldn't find any reference to use volumeMounts with the rabbitmq operator.</p>
<p>Is there a <strong>preferred way</strong> or <strong>any other way to enable it</strong>?</p>

Arturo Aviles
<p>This <strong>plugin</strong> can be <strong>enabled</strong> by using a <strong>custom Docker Rabbitmq image</strong> with the plugin installed:</p>
<pre><code>FROM rabbitmq:3.8.8-management

RUN apt-get update

RUN apt-get install -y curl

RUN curl -L https://github.com/rabbitmq/rabbitmq-delayed-message-exchange/releases/download/v3.8.0/rabbitmq_delayed_message_exchange-3.8.0.ez &gt; $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.8.0.ez

RUN chown rabbitmq:rabbitmq $RABBITMQ_HOME/plugins/rabbitmq_delayed_message_exchange-3.8.0.ez

RUN rabbitmq-plugins enable --offline rabbitmq_delayed_message_exchange

RUN rabbitmq-plugins enable --offline rabbitmq_consistent_hash_exchange
</code></pre>
<p><strong>Notice:</strong> For immutable results or in case you can't depend on external changes, download the plugin to your machine and use COPY instead of using RUN curl... Make sure to have the rabbitmq_delayed_message_exchange .ez file in your machine.</p>
<ul>
<li>Push your image to a container registry.</li>
</ul>
<p>And then define your <strong>RabbitmqCluster</strong> as:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: rabbitmq.com/v1beta1
kind: RabbitmqCluster
metadata:
  name: definition
spec:
  image: &lt;container-registry&gt;/&lt;username&gt;/rabbitmq-delayed-message-exchange:3.8.8-management
  replicas: 1
  rabbitmq:
    additionalPlugins:
      - rabbitmq_management
      - rabbitmq_delayed_message_exchange
  service:
    type: LoadBalancer
</code></pre>
<p><strong>Notice:</strong> Change the image to the one you pushed.</p>
