I'm trying to run Rabbitmq using Kubernetes on AWS. I'm using the official Rabbitmq docker container. Each time the pod restarts the rabbitmq container gets a new hostname. I've setup a service (of type LoadBalancer) for the pod with a resolvable DNS name.
But when I use an EBS to make the rabbit config/messsage/queues persistent between restarts it breaks with:
exception exit: {{failed_to_cluster_with,
['rabbitmq@rabbitmq-deployment-2901855891-nord3'],
"Mnesia could not connect to any nodes."},
{rabbit,start,[normal,[]]}}
in function application_master:init/4 (application_master.erl, line 134)
rabbitmq-deployment-2901855891-nord3
is the previous hostname rabbitmq container. It is almost like Mnesia saved the old hostname :-/
The container's info looks like this:
Starting broker...
=INFO REPORT==== 25-Apr-2016::12:42:42 ===
node : rabbitmq@rabbitmq-deployment-2770204827-cboj8
home dir : /var/lib/rabbitmq
config file(s) : /etc/rabbitmq/rabbitmq.config
cookie hash : XXXXXXXXXXXXXXXX
log : tty
sasl log : tty
database dir : /var/lib/rabbitmq/mnesia/rabbitmq
I'm only able to set the first part of the node name to rabbitmq
using the RABBITMQ_NODENAME
environment variable.
Setting RABBITMQ_NODENAME
to a resolvable DNS name breaks with:
Can't set short node name!\nPlease check your configuration\n"
Setting RABBITMQ_USE_LONGNAME
to true
breaks with:
Can't set long node name!\nPlease check your configuration\n"
Update:
Setting
RABBITMQ_NODENAME
to rabbitmq@localhost works but that negates any possibility to cluster instances.Starting broker... =INFO REPORT==== 26-Apr-2016::11:53:19 === node : rabbitmq@localhost home dir : /var/lib/rabbitmq config file(s) : /etc/rabbitmq/rabbitmq.config cookie hash : 9WtXr5XgK4KXE/soTc6Lag== log : tty sasl log : tty database dir : /var/lib/rabbitmq/mnesia/rabbitmq@localhost
Setting
RABBITMQ_NODENAME
to the service name, in this caserabbitmq-service
like so rabbitmq@rabbitmq-service also works since kubernetes service names are internally resolvable via DNS.Starting broker... =INFO REPORT==== 26-Apr-2016::11:53:19 === node : rabbitmq@rabbitmq-service home dir : /var/lib/rabbitmq config file(s) : /etc/rabbitmq/rabbitmq.config cookie hash : 9WtXr5XgK4KXE/soTc6Lag== log : tty sasl log : tty database dir : /var/lib/rabbitmq/mnesia/rabbitmq@rabbitmq-service
Is this the right way though? Will I still be able to cluster multiple instances if the node names are the same?