Zookeeper K8s
- By Canonical Data Platform
- Databases
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 10 | 09 Mar 2022 | |
latest/beta | 8 | 08 Jun 2021 | |
latest/edge | 21 | 12 Apr 2023 | |
3/stable | 51 | 27 Feb 2024 | |
3/candidate | 51 | 27 Feb 2024 | |
3/beta | 51 | 27 Feb 2024 | |
3/edge | 56 | 24 Apr 2024 |
juju deploy zookeeper-k8s --channel latest/beta
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
Deploying
$ juju add-model myzookeeper
$ juju deploy zookeeper-k8s -n 3
Where:
-
zookeeper-k8s
: the name of this Charmed Operator on the Charmhub. -
-n
: the number of Juju units to deploy, i.e. the number of wanted k8s pods. Any number>= 1
is supported but for production you should pick an odd number>= 3
.
Inspecting/Operating
The deployment can be inspected with juju
and kubectl
:
$ juju status
Model Controller Cloud/Region Version SLA Timestamp
myzookeeper micro microk8s/localhost 2.9.0 unsupported 12:27:29Z
App Version Status Scale Charm Store Channel Rev OS Address Message
zookeeper-k8s active 3 zookeeper-k8s charmhub stable 4 kubernetes
Unit Workload Agent Address Ports Message
zookeeper-k8s/0 active idle 10.1.0.47
zookeeper-k8s/1* active idle 10.1.0.49
zookeeper-k8s/2 active idle 10.1.0.48
$ juju config zookeeper-k8s client-port
2181
$ kubectl get pods --namespace=myzookeeper
NAME READY STATUS RESTARTS AGE
modeloperator-75988dd959-vvh2t 1/1 Running 0 4m33s
zookeeper-k8s-2 2/2 Running 0 92s
zookeeper-k8s-1 2/2 Running 0 92s
zookeeper-k8s-0 2/2 Running 0 92s
This teaches us the IP addresses (here 10.1.0.47-49
) and the TCP port (2181
) to be used in order to access the ZooKeeper data from any client.
ZooKeeper can be seeded with some dummy data:
$ juju run-action zookeeper-k8s/0 seed-data --wait
This data should then be replicated accross the entire ZooKeeper cluster and all units should present that same data:
$ juju run-action zookeeper-k8s/0 zookeeper-k8s/1 zookeeper-k8s/2 dump-data --wait
unit-zookeeper-k8s-0:
UnitId: zookeeper-k8s/0
id: "8"
results:
content: '{''test-seed'': {''my-first-key'': b''my first value'', ''my-second-key'':
b''my second value''}, ''zookeeper'': {''config'': b''server.1=10.1.0.47:2888:3888:participant\nserver.2=10.1.0.48:2888:3888:participant\nserver.3=10.1.0.49:2888:3888:participant\nversion=0'',
''quota'': b''''}}'
status: completed
timing:
completed: 2021-06-02 11:41:36 +0000 UTC
enqueued: 2021-06-02 11:41:33 +0000 UTC
started: 2021-06-02 11:41:35 +0000 UTC
unit-zookeeper-k8s-1:
UnitId: zookeeper-k8s/1
id: "9"
results:
content: '{''test-seed'': {''my-first-key'': b''my first value'', ''my-second-key'':
b''my second value''}, ''zookeeper'': {''config'': b''server.1=10.1.0.47:2888:3888:participant\nserver.2=10.1.0.48:2888:3888:participant\nserver.3=10.1.0.49:2888:3888:participant\nversion=0'',
''quota'': b''''}}'
status: completed
timing:
completed: 2021-06-02 11:41:36 +0000 UTC
enqueued: 2021-06-02 11:41:33 +0000 UTC
started: 2021-06-02 11:41:35 +0000 UTC
unit-zookeeper-k8s-2:
UnitId: zookeeper-k8s/2
id: "10"
results:
content: '{''test-seed'': {''my-first-key'': b''my first value'', ''my-second-key'':
b''my second value''}, ''zookeeper'': {''config'': b''server.1=10.1.0.47:2888:3888:participant\nserver.2=10.1.0.48:2888:3888:participant\nserver.3=10.1.0.49:2888:3888:participant\nversion=0'',
''quota'': b''''}}'
status: completed
timing:
completed: 2021-06-02 11:41:36 +0000 UTC
enqueued: 2021-06-02 11:41:33 +0000 UTC
started: 2021-06-02 11:41:35 +0000 UTC
Any ZooKeeper client can be used to read and write data to/from the deployed ZooKeeper cluster, e.g. ZooNavigator:
$ sudo snap install zoonavigator # ZooNavigator's Web-UI is then served at:
$ firefox http://localhost:9000
Relating
Other Charmed Operators can be related to this one if they require a ZooKeeper database. The zookeeper-dummy-client-k8s is an example:
$ juju add-model myzookeeper
$ juju deploy zookeeper-k8s -n 3
$ juju deploy zookeeper-dummy-client-k8s
$ juju add-relation zookeeper-k8s:client zookeeper-dummy-client-k8s:zookeeper
See how to implement such a Charmed Operator.