ZNodes

Apache ZooKeeper organizes all data into a hierarchical system of ZNodes, which act as both files (they can have data associated with them) and folders (they can contain other ZNodes) when compared to a traditional (POSIX-like) file system.

In order to isolate different clients using the same ZooKeeper cluster, each client application should be assigned a unique root ZNode, which it can then organize as it sees fit.

In the Stackable Operator for Apache ZooKeeper, we manage this using the ZookeeperZnode Kubernetes resource. The operator creates a new ZNode in the linked ZooKeeper cluster, as well as Discovery Profiles that are configured to restrict access to the configured ZNode. The operator does not manage the contents of the ZNode.

The operator automatically deletes the ZNode from the ZooKeeper cluster if the Kubernetes ZookeeperZnode object is deleted. Recreating the ZookeeperZnode object will not restore access to the data.

Usage

The ZookeeperZnode object should be created by the user administering the system that will use the ZNode. For example, when using Apache ZooKeeper to manage an Apache Kafka cluster, the ZookeeperZnode object would be created by the user creating the KafkaCluster object.

A basic ZNode can be created like so:

---
apiVersion: zookeeper.stackable.tech/v1alpha1
kind: ZookeeperZnode
metadata:
  name: example-znode
spec:
  clusterRef: (1)
    name: zookeeper-cluster
    namespace: my-namespace (2)
1 Refererence to the ZookeeperCluster object
2 The namespace is implied to be the same as the namespace of the ZookeeperZnode if omitted

This will create corresponding Discovery Profiles referring to the specific ZNode, which will look roughly like this:

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: example-znode (1)
deta:
  ZOOKEEPER: pod-1:2181,pod-2:2181,pod-3:2181/{path} (2)
1 The base name of the discovery profile will be the same as the name of the ZookeeperZnode
2 $PATH will be a unique and unpredictable path that is generated by the operator