Create a RabbitMQ Broker (RC)
Create an Amazon MQ for RabbitMQ broker with the RabbitMQBroker API.
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.
Prerequisites
Section titled “Prerequisites”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.
1. Create the broker
Section titled “1. Create the broker”A minimal RabbitMQBroker needs only an instance type:
apiVersion: mq.entigo.com/v1alpha1kind: RabbitMQBrokermetadata: name: example-rabbitmqspec: instanceType: mq.m7g.mediumThe 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:
kubectl get rabbitmqbrokers.mq.entigo.com example-rabbitmq -wOptional settings
Section titled “Optional settings”| 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/v1alpha1kind: RabbitMQBrokermetadata: name: example-rabbitmqspec: 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 = 2047For every field, see the RabbitMQBroker API reference.
2. Mount the credentials in a Pod
Section titled “2. Mount the credentials in a Pod”The broker has two Secrets:
<metadata.name>-credentialsholds theusernameandpasswordof the admin usermqadmin.<metadata.name>-connectionholds the broker connection details (endpoints) written by the provider.
Read the admin credentials into environment variables:
apiVersion: v1kind: Podmetadata: name: rabbitmq-clientspec: 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: passwordFor more information about Secrets in Kubernetes, see Kubernetes documentation.
3. Verify
Section titled “3. Verify”The broker is ready
Section titled “The broker is ready”The broker shows SYNCED and READY as True:
$ kubectl get rabbitmqbrokers.mq.entigo.comNAME SYNCED READY COMPOSITION AGEexample-rabbitmq True True rabbitmqbrokers.mq.entigo.com 22mCredentials are stored
Section titled “Credentials are stored”$ kubectl get secretNAME TYPE DATA AGEexample-rabbitmq-credentials Opaque 2 22mexample-rabbitmq-connection Opaque 3 22m
$ kubectl get secret example-rabbitmq-credentials -o yamlapiVersion: v1kind: Secretmetadata: name: example-rabbitmq-credentials namespace: <namespace>type: Opaquedata: username: <base64-encoded-username> password: <base64-encoded-password>Limitations
Section titled “Limitations”Configuration changes
Section titled “Configuration changes”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.configurationafter 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
engineVersionbump provisions a new configuration rather than editing the existing one.
Deletion
Section titled “Deletion”- 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.
User management
Section titled “User management”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.
Troubleshooting
Section titled “Troubleshooting”| 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. |
EnvironmentConfig
Section titled “EnvironmentConfig”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. |
Infralib Configuration Example
Section titled “Infralib Configuration Example”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