I'm trying to deploy couchbase community edition in a docker swarm environment. I followed the steps suggested by Arun Gupta, though I'm not sure if a master-worker model is desired as Couchbase doesn't have the notion of master/slave model.
Following are the problems I encountered. I'm wondering if anyone is able to run Couchbase successfully in a swarm mode.
Docker swarm assigns different IP address each time the service is restarted. Sometimes, docker moves the service to a new node which, again assigns a different IP address. It appears that Couchbase doesn't start if it finds a new IP address. (log says
"address on which the service is configured is not up. Waiting for the interface to be brought up"
). I'm using a host mounted volume as the data folder (/opt/couchase/var
) to persist data across restarts.I tried to read overlay network address used internally and update
ip
andip_start
files in arun
script within the container. This doesn't help either. Server comes up as a new instance without loading old data. This is a real problem as production data can be lost ifdocker swarm
moves services around.docker swarm's
internal router assigns an address from overlay network in addition to other interfaces. I tried usinglocalhost
,master.overlaynet
, IP address of the overlaynet, private address assigned by docker to container etc. as server address in the Couchbase cluster configuration. While the cluster servers are able to communicate to each other, this created another problem with client connections. Client normally connects to an address/port exposed by the swarm cluster. This is different from cluster node address. In case of a python client, it reads Couchbase cluster server addresses and tried to connect to that if overlay address is given as server address at the time of joining the cluster. The client times out as the address is not reachable.- I might be able to add a network address constraint to the
yaml
file to ensure that master node will come up with the same address. For eg.
networks:
default:
ipv4_address: 172.20.x.xx
- Above approach may not work for worker nodes as that will impact ability to scale worker nodes based on load/growth.
- In this model (master/worker), how does a worker get elected as leader if master node goes down? Is master/worker the right approach for a Couchbase cluster in swarm environment?
It will be helpful if I can get some references to Couchbase swarm mode setup or some suggestions on how to handle IP address change.