daniberg.com

posts github chip8 rtc guitar

Kluster Updates

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

EDIT: 2018-07-14 Libraries have been upgraded and the text has been updated to reflect the api changes in the akka cluster management.

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:8558/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": "1520850065",
      "status": "Up",
      "roles": [
        "cruncher",
        "dc-default"
      ]
    },
    {
      "node": "akka.tcp://kluster@kluster2:2550",
      "nodeUid": "-1078410457",
      "status": "Up",
      "roles": [
        "cruncher",
        "dc-default"
      ]
    },
    {
      "node": "akka.tcp://kluster@kluster3:2550",
      "nodeUid": "1026545477",
      "status": "Up",
      "roles": [
        "cruncher",
        "dc-default"
      ]
    }
  ]
}

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.

©2023 daniberg.com