Using multiple role groups

ZooKeeper uses a unique ID called myid to identify each server in the cluster. The Stackable Operator for Apache ZooKeeper assigns the myid to each Pod from the ordinal index given to the Pod by Kubernetes. This index is unique over the Pods in the StatefulSet of the role group.

When using multiple role groups in a cluster, this will lead to different ZooKeeper Pods using the same myid. Each role group is represented by its own StatefulSet, and therefore always identified starting with 0.

In order to avoid this myid conflict, a property myidOffset needs to be specified in each rolegroup. The myidOffset defaults to zero, but if specified will be added to the ordinal index of the Pod.

Example configuration

Here the property is used on the second role group in a ZooKeeperCluster:

apiVersion: zookeeper.stackable.tech/v1alpha1
kind: ZookeeperCluster
metadata:
  name: zookeeper
spec:
  servers:
    roleGroups:
      primary:
        replicas: 2
      secondary:
        replicas: 1
        config:
          myidOffset: 10  (1)
1 The myidOffset property set to 10 for the secondary role group

The secondary role group myid starts from id 10. The primary role group will start from 0. This means, the replicas of the role group primary should not be scaled higher than 10 which results in 10 primary Pods using a myid from 0 to 9, followed by the secondary Pods starting at myid 10.