A template to run RabbitMQ on Kubernetes in High Availability supporting TLS and MQTT and automatic peer discovery.
Kubernetes 1.9 or later is required.
Both the management interface run on https and TLS is enabled on both MQTT and AMQP.
To accomplish this we are using Let's Encrypt via https://github.com/PalmStoneGames/kube-cert-manager which creates
a secret called cert-mq-c1
which is mounted by the statefulset.
You will want to setup kube-cert-manager as well in order to use this template.
- Create your configmap. Make sure you review the values in configmap.yaml and change as appropriate.
kubectl create -f configmap.yaml
- Assuming RBAC is enabled on your cluster which is the default, you need to configure some RBAC stuff for auto peer discovery to work
kubectl create -f rbac.yaml
- Create a service to allow the rabbitmq PODs to contact each other
kubectl create -f services.yaml
- Finally create the statefulset for RabbitMQ itself
kubectl create -f statefulset.yaml
Now wait a few seconds and you should be able to run
kubectl exec rabbitmq-0 rabbitmqctl cluster_status
And get back something like this:
Cluster status of node [email protected] ...
[{nodes,[{disc,['[email protected]',
'[email protected]']}]},
{running_nodes,['[email protected]',
'[email protected]']},
{cluster_name,<<"[email protected]">>},
{partitions,[]},
{alarms,[{'[email protected]',[]},
{'[email protected]',[]}]}]
- Scaling:
kubectl scale statefulset/rabbitmq --replicas=3