The kluster project got a few updates today. kluster is a minimal akka cluster running on docker and it was first introduced here.

The first major change is that it’s now easier to add and remove nodes from the cluster.

./run.sh -a 3 # add three nodes to the cluster
./run.sh -r 2 # remove kluster2 from the cluster

The nodes in the cluster are also running the akka management api and the containers were updated to include curl and jq.

The api can be triggered from the console using docker exec. For example, to get the members of the cluster, run:

docker exec -ti kluster1 curl http://localhost:19999/members | jq .

The command above outputs the json response:

{
  "selfNode": "akka.tcp://kluster@kluster1:2550",
  "leader": "akka.tcp://kluster@kluster1:2550",
  "oldest": "akka.tcp://kluster@kluster1:2550",
  "unreachable": [],
  "members": [
    {
      "node": "akka.tcp://kluster@kluster1:2550",
      "nodeUid": "-1569330506",
      "status": "Up",
      "roles": [
        "cruncher"
      ]
    },
    {
      "node": "akka.tcp://kluster@kluster2:2550",
      "nodeUid": "2119541425",
      "status": "Up",
      "roles": [
        "cruncher"
      ]
    },
    {
      "node": "akka.tcp://kluster@kluster3:2550",
      "nodeUid": "865465060",
      "status": "Up",
      "roles": [
        "cruncher"
      ]
    }
  ]
}

Another important change is that the option of auto-downing has now been removed. Although good for development, auto-downing leads to split brain scenarios. The run.sh script relies in the akka management api to remove a node from the cluster.

Nodes are still added to the cluster on bootstrap but the hardcoded dependency on kluster1 is now gone. The code will look for the oldest hostname in the kluster family to be used as a seed node. The first node, kluster1 joins itself.