No, I meant something else. First of all, Akka cluster is implemented on top of Akka remoting. And for Akka remoting to work, each node needs to know it's self address, which is the IP the other nodes will use to connect to it. The node address becomes the part of remote ActorRefs. Any incoming message that contains different address than the node's self address is dropped. This is a good thing, because you could have actors with the same local paths on different node clusters and the results of delivering message to a wrong instance could potentially be disastrous. Because of this, even if you create wallet-seed service with virtual IP 10.0.0.2 you cannot use this IP as the address of the seed, because the containers backing the service will expect to receive messages addressed to 10.0.0.5, 10.0.0.6 and so on and will discard messages addressed to 10.0.0.2.
You could use docker-swarm service in a different way: to advertise the proper IP address of the cluster seed, but you cannot use Akka remoting protocol for that, for reason given above. Suppose you implement it the following way: define a HTTP endpoint, say at port 5000 that will respond to GET /seeds with a text/plain message containing IP address of cluster seed. Each node upon startup will do the following:
- attempt a GET wallet-seed:5000/seed
- if it succeeds, join the cluster at received IP
- if it fails, this node is the first one and it should:
- bootstrap the cluster by joining itself
- publish a HTTP service at port 5000 advertising it's own address
The definition of wallet-seed service should include a health check condition so that only containers publishing the HTTP at port 5000 would be act as it's backend
That would work, but has a glaring problem: there is a race condition between the seed nodes. More than one container can "elect itself" as the seed. Then the other nodes would access different seeds through wallet-seed in round-robin fashion and join their respective clusters.
Using a consistent store like consul or etcd provides a solution to the race condition but also solves a second problem: it can be used to advertise seed address without crafting a custom service.
Cheers,
Rafał