Skip to content
Docs

This guide creates an Amazon MQ for RabbitMQ broker from Kubernetes and mounts its admin credentials in a Pod.

You describe the broker with one manifest: RabbitMQBroker. The platform creates the broker in the database subnet group, a security group with rules that let Pods reach the broker (AMQPS on port 5671) and its management console (HTTPS on port 443), and Kubernetes Secrets with the admin credentials and the connection details.

It is good practice to include the manifest in your application’s Helm chart, so the broker is deployed together with the application that uses it.

RabbitMQBroker is not enabled by default. Your Infralib configuration needs:

Module Flag Default What it does
platform-apis platform-apis.rabbitmq.install false Installs the RabbitMQBroker API and its EnvironmentConfig. Set to true.
crossplane-aws global.extraProviders [] Add mq to install the Amazon MQ provider, which manages the brokers.
crossplane-aws global.createObservers, global.createNamespacedObservers false Installs the EC2 provider for the security group and the VPC lookups the broker needs. Set both to true.

If extraProviders already lists other providers, add mq to the list instead of replacing it. Helm replaces lists instead of merging them.

For the base modules every platform API needs, see Infralib Requirements. A full example is in Infralib Configuration Example at the end of this guide.

A minimal RabbitMQBroker needs only an instance type:

apiVersion: mq.entigo.com/v1alpha1
kind: RabbitMQBroker
metadata:
name: example-rabbitmq
spec:
instanceType: mq.m7g.medium

The admin user mqadmin is created with the broker. Its credentials are stored in the Kubernetes Secret <metadata.name>-credentials.

Creating the broker can take more than 10 minutes. Watch it until READY is True:

Terminal window
kubectl get rabbitmqbrokers.mq.entigo.com example-rabbitmq -w
Field Default What it does
engineVersion 4.2 Version of the broker engine.
deploymentMode SINGLE_INSTANCE SINGLE_INSTANCE, ACTIVE_STANDBY_MULTI_AZ or CLUSTER_MULTI_AZ.
publiclyAccessible false Whether the broker is reachable from the internet.
autoMinorVersionUpgrade true Upgrades to new minor versions as Amazon MQ releases them.
maintenanceWindowStartTime unset Weekly maintenance start: dayOfWeek (for example MONDAY), timeOfDay (24-hour, for example 02:00) and timeZone (for example CET).
configuration unset Custom rabbitmq.conf (Cuttlefish) content in data, with an optional description. Creates an Amazon MQ Configuration and associates it with the broker. See Limitations.
brokerName unset Name of the broker.

For example, a multi-AZ cluster with a maintenance window and a custom configuration:

apiVersion: mq.entigo.com/v1alpha1
kind: RabbitMQBroker
metadata:
name: example-rabbitmq
spec:
instanceType: mq.m7g.large
engineVersion: '4.2'
deploymentMode: CLUSTER_MULTI_AZ
autoMinorVersionUpgrade: true
maintenanceWindowStartTime:
dayOfWeek: MONDAY
timeOfDay: '02:00'
timeZone: CET
configuration:
description: Custom broker configuration
data: |
consumer_timeout = 1800000
channel_max = 2047

For every field, see the RabbitMQBroker API reference.

The broker has two Secrets:

  • <metadata.name>-credentials holds the username and password of the admin user mqadmin.
  • <metadata.name>-connection holds the broker connection details (endpoints) written by the provider.

Read the admin credentials into environment variables:

apiVersion: v1
kind: Pod
metadata:
name: rabbitmq-client
spec:
terminationGracePeriodSeconds: 1
containers:
- name: rabbitmq-client
image: rabbitmq:management
command: ['sleep', 'infinity']
env:
- name: RABBITMQ_USER
valueFrom:
secretKeyRef:
name: example-rabbitmq-credentials
key: username
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: example-rabbitmq-credentials
key: password

For more information about Secrets in Kubernetes, see Kubernetes documentation.

The broker shows SYNCED and READY as True:

Terminal window
$ kubectl get rabbitmqbrokers.mq.entigo.com
NAME SYNCED READY COMPOSITION AGE
example-rabbitmq True True rabbitmqbrokers.mq.entigo.com 22m
$ kubectl get secret
NAME TYPE DATA AGE
example-rabbitmq-credentials Opaque 2 22m
example-rabbitmq-connection Opaque 3 22m
$ kubectl get secret example-rabbitmq-credentials -o yaml
apiVersion: v1
kind: Secret
metadata:
name: example-rabbitmq-credentials
namespace: <namespace>
type: Opaque
data:
username: <base64-encoded-username>
password: <base64-encoded-password>

The broker configuration (spec.configuration) has limitations that come from the Amazon MQ API:

  • A configuration cannot be removed once set. Amazon MQ does not support disassociating a configuration from a broker, only switching to a different one. The API enforces this, so a manifest that removes spec.configuration after it was set is rejected.
  • Configuration changes are applied on the next broker reboot, not immediately.
  • Changing the engine version creates a new configuration. An Amazon MQ Configuration is tied to a single engine version, so an engineVersion bump provisions a new configuration rather than editing the existing one.
  • Amazon MQ Configurations are not deleted. Amazon MQ does not support deleting Configuration objects through its API. Configurations created for a broker, including previous ones left behind after a configuration or engine version switch, remain in AWS after the broker is deleted.
  • Deleting the RabbitMQBroker is destructive. The broker and all of its messages, queues and vhosts are permanently removed. There is no snapshot or restore.

The Amazon MQ API only manages the single admin user (mqadmin) for the RabbitMQ engine. Additional RabbitMQ users, vhosts and permissions are not supported through the AWS API, so there is no separate user resource such as a RabbitMQUser.

To create additional users, sign in as mqadmin with the credentials from the <metadata.name>-credentials Secret and create them inside RabbitMQ, using the management console (port 443), the RabbitMQ management HTTP API or AMQP.

Symptom Cause / fix
no matches for kind "RabbitMQBroker" The API is not installed. Check the Prerequisites.
SYNCED is False The platform could not create a cloud resource. kubectl describe rabbitmqbrokers.mq.entigo.com <name> shows the error under Conditions and Events. Check that mq is in extraProviders and that createObservers and createNamespacedObservers are on.
READY stays False for several minutes after creation Normal. Amazon MQ can take more than 10 minutes to create a broker.
A manifest without spec.configuration is rejected A configuration cannot be removed once set. See Configuration changes.
A configuration change has no effect Configuration changes are applied on the next broker reboot.

There are no RabbitMQ-specific defaults for developers to worry about. The one cluster-wide setting that affects brokers is tagging.

Setting Default What it does
tags {} Cloud tags added to every broker. See Resource Tagging.
steps:
...
- name: apps
type: argocd-apps
modules:
...
- name: crossplane-aws
source: crossplane-aws
inputs:
global:
createObservers: true
createNamespacedObservers: true
extraProviders:
- mq
...
- name: platform-apis
source: platform-apis
inputs:
platform-apis:
rabbitmq:
install: true
mq:
environmentConfig:
tags:
cost-center: CC-12345