In Kubernetes-based environments, you may need to configure RabbitMQ with specific settings, or any other custom configurations that align with your operational or security requirements.
RabbitMQ Version: 4.1.0
In Kubernetes, RabbitMQ is typically deployed using the RabbitMQ Cluster Operator, which helps manage RabbitMQ clusters efficiently. The configuration for RabbitMQ needs to be applied through Kubernetes resources (like the RabbitmqCluster CRD), but users may find it unclear how to modify configuration files such as rabbitmq.conf or how to add custom configuration.
To apply a custom configuration in RabbitMQ deployed on Kubernetes, use the RabbitmqCluster resource and the additionalConfig option. This option allows you to add settings directly into the rabbitmq.conf file.
a) Sample YAML - In the additionalConfig section, you can add any RabbitMQ configuration settings
apiVersion: v1
kind: ConfigMap
metadata:
name: rabbitmq-config
data:
rabbitmq.conf: |
<customer-configuration-to-be-placed-here>
b) You can deploy RabbitMQ by referencing the ConfigMap created above
apiVersion: apps/v1
kind: Deployment
metadata:
name: rabbitmq
spec:
replicas: 1
selector:
matchLabels:
app: rabbitmq
template:
metadata:
labels:
app: rabbitmq
spec:
containers:
- name: rabbitmq
image: rabbitmq:4.1.0
ports:
- containerPort: 5672
- containerPort: 15672
volumeMounts:
- name: rabbitmq-config-volume
mountPath: /etc/rabbitmq
volumes:
- name: rabbitmq-config-volume
configMap:
name: rabbitmq-config
c) Apply the changes
kubectl apply -f rabbitmq-deployment.yaml
d) Verify the same by inspecting the latest logs:
kubectl logs <rabbitmq-pod-name>