Choices and tradeoffs are explained in detail at https://www.mirantis.com/blog/clustered-rabbitmq-kubernetes/
- Start minikube with you preferred defults
minikube start --cpus=2 --memory=4096 --vm-driver=kvm
- Create a namespace so you can easily reset an environment when something goes wrong
kubectl create namespace demo
- Make some etcd installation available under
etcd
namekubectl run etcd --image=microbox/etcd --port=4001 --namespace=demo -- --name etcd kubectl --namespace=demo expose deployment etcd
- Build a Docker image
eval $(minikube docker-env) docker build . -t rabbitmq-autocluster
- Initialize k8s secret for erlang cookie
kubectl create secret generic --namespace=demo erlang.cookie --from-file=./erlang.cookie
- Deploy RabbitMQ cluster
kubectl create -f rabbitmq.yaml
- Check that clustering indeed worked
FIRST_POD=$(kubectl get pods --namespace demo -l 'app=rabbitmq' -o jsonpath='{.items[0].metadata.name }') kubectl exec --namespace=demo $FIRST_POD rabbitmqctl cluster_status
And we should see some output similar to the following one (where the most important bit of information is that
nodes
andrunning_nodes
both contain 3 names):Cluster status of node 'rabbit@172.17.0.3' ... [{nodes,[{disc,['rabbit@172.17.0.3','rabbit@172.17.0.4', 'rabbit@172.17.0.7']}]}, {running_nodes,['rabbit@172.17.0.4','rabbit@172.17.0.7','rabbit@172.17.0.3']}, {cluster_name,<<"rabbit@rabbitmq-deployment-861116474-cmshz">>}, {partitions,[]}, {alarms,[{'rabbit@172.17.0.4',[]}, {'rabbit@172.17.0.7',[]}, {'rabbit@172.17.0.3',[]}]}]