A ready to deploy rabbitmq cluster to work on top of Kubernetes.
It uses rabbitmq clusterer plugin to achieve clustering.
- Kubernetes version 1.5.X (We're using StatefulSet)
- kubectl configured to work with your Kubernetes API
- Tested on Kubernetes 1.5.2 on top of AWS (See future work)
- Optional - Access to your own docker repository to store your own images. That's relevant if you don't want to use the default images offered here.
- A 3 nodes rabbitmq cluster as StatefulSet
- A rmq-cluster headless service to control the StatefulSet domain
- a rabbitmq service to access the cluster
- An optional, rabbitmq-management service to access the admin control panel
Name | Default Value | Purpose | Can be changed? |
---|---|---|---|
DOCKER_REPOSITORY | nanit | Change it if you want to build and use custom docker repository | Yes |
SUDO | sudo | Should docker commands be prefixed with sudo. Change to "" to omit sudo. | Yes |
RABBITMQ_REPLICAS | 3 | Number of nodes in the cluster | No |
RABBITMQ_DEFAULT_USER | None | The default username to access the management console | Yes |
RABBITMQ_DEFAULT_PASS | None | The default password to access the management console | Yes |
RABBITMQ_ERLANG_COOKIE | None | Erlang secret needed for nodes communication | Yes |
RABBITMQ_EXPOSE_MANAGEMENT | FALSE | Should RMQ management console be exposed outside | Yes |
- Clone this repository
- Run:
export DOCKER_REPOSITORY=nanit && \
export RABBITMQ_REPLICAS=3 && \
export RABBITMQ_DEFAULT_USER=username && \
export RABBITMQ_DEFAULT_PASS=password && \
export RABBITMQ_ERLANG_COOKIE=secret && \
export RABBITMQ_EXPOSE_MANAGEMENT=TRUE && \
export SUDO="" && \
make deploy
At the end of the installation you should have a service named rabbitmq
which you can use to connect to the cluster
If you'd like to have more than 3 nodes in the cluster you have to:
- Change the clusterer.config to include all the cluster nodes.
- Build your own image by setting the
DOCKER_RESPOSITORY
environment variable - Change the
RABBITMQ_REPLICAS
to the new number of nodes - Run the deployment script above
If you want to build use your own images make sure to change the DOCKER_REPOSITORY environment variable to your own docker repository. It will build the images, push them to your docker repository and use them to create all the needed kubernetes deployments.
You can run the same setup in docker-compose using
$ docker-compose build && docker-compose up
Then, go to localhost:15672
and you'll see the cluster is already formed up.
- Allow setting a different number of replicas