How to scale RabbitMQ across multiple Kubernetes Clusters

12/18/2019

I have an application running in a Kubernetes cluster Azure AKS which is made up of a website running in one deployment, background worker processes running as scheduled tasks in Kubernetes, RabbitMQ running as another deployment and a SQL Azure DB which is not part of the Kubernetes.

I would like to deploy achieve load balancing and failover by deploying another kubernetes cluster in another region and placing a Traffic Manager DNS Load Balancer in front of the web site.

The problem that I see is that if the two rabbit instances are in separate kubernetes clusters then items queued in one will not be available in the other.

Is there a way to cluster the rabbitmq instances running in each kubernetes cluster or something besides clustering? Or is there a common design pattern that might avoid problems from having seperate queues?

I should also note that currently there is only one node running RabbitMq in the current kuberntes cluster but as part of this upgrade it seems like a good idea to run multiple nodes in each cluster which I think the current Helm charts support.

-- Zack
azure-aks
kubernetes
rabbitmq

1 Answer

1/6/2020

You shouldn't cluster RabbitMQ nodes across regions. Your cluster will get split brain because of network delays. To synchronise RabbitMQ queues, exchanges between clusters you can use federation or shovel plugin, depending on your use case.

Federation plugin can be enabled on a cluster by running commands:

rabbitmqctl stop_app
rabbitmq-plugins enable rabbitmq_federation
rabbitmq-plugins enable rabbitmq_federation_management
rabbitmqctl start_app

Mode details on Federation.

For shovel:

rabbitmq-plugins enable rabbitmq_shovel
rabbitmq-plugins enable rabbitmq_shovel_management
rabbitmqctl stop_app
rabbitmqctl start_app

Mode details on Shovel.

Full example on how to setup Federation on RabbitMQ cluster can be found here.

-- Marius Jaraminas
Source: StackOverflow