Apache Zookeeper - K8s
- Canonical
- Databases
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 10 | 09 Mar 2022 | |
latest/beta | 8 | 08 Jun 2021 | |
latest/edge | 21 | 12 Apr 2023 | |
latest/edge | 16 | 15 Oct 2022 | |
3/stable | 51 | 27 Feb 2024 | |
3/candidate | 51 | 27 Feb 2024 | |
3/beta | 51 | 27 Feb 2024 | |
3/edge | 67 | 16 Oct 2024 |
juju deploy zookeeper-k8s --channel 3/stable
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:
charms.zookeeper_k8s.v0.zookeeper
-
- Last updated 15 Feb 2022
- Revision Library version 0.13
ZooKeeper Library.
This library implements both sides of the
zookeeper
interface.
The provider side of this interface is implemented by the zookeeper-k8s Charmed Operator.
Any Charmed Operator that requires a ZooKeeper database for providing its service should implement the requirer side of this interface. kafka-k8s is an example.
In a nutshell using this library to implement a Charmed Operator requiring a ZooKeeper database (and talking to it as a ZooKeeper client) would look like
$ charmcraft fetch-lib charms.zookeeper_k8s.v0.zookeeper
metadata.yaml
:
requires:
zookeeper:
interface: zookeeper
src/charm.py
:
from charms.zookeeper_k8s.v0.zookeeper import ZooKeeperEvents, ZooKeeperRequires
from ops.charm import CharmBase
class MyCharm(CharmBase):
on = ZooKeeperEvents()
def __init__(self, *args):
super().__init__(*args)
self.zookeeper = ZooKeeperRequires(self)
self.framework.observe(
self.on.zookeeper_clients_changed,
self._on_zookeeper_clients_changed,
)
self.framework.observe(
self.on.zookeeper_clients_broken,
self._on_zookeeper_clients_broken,
)
def _on_zookeeper_clients_changed(self, event):
# Get zookeeper client addresses
client_addresses: str = self.zookeeper.hosts
# client_addresses => "zk-0:2181,zk-1:2181"
def _on_zookeeper_clients_broken(self, event):
# Stop service
# ...
self.unit.status = BlockedStatus("need zookeeper relation")
You can file bugs here!
Index
class ZooKeeperEvents
ZooKeeper events.
Description
This class defines the events that ZooKeeper can emit.
Events: zookeeper_clients_changed (_ClientsBrokenEvent)
class ZooKeeperRequires
Description
ZooKeeper requires relation. None
Methods
ZooKeeperRequires. __init__( self , charm: CharmBase , endpoint_name: str )
Constructor.
Arguments
The charm that implements the relation.
Endpoint name of the relation.
ZooKeeperRequires. hosts( self )
Get zookeeper hosts.
Returns
Comma-listed zookeeper client hosts.
class ZooKeeperProvides
ZooKeeper provides relation.
Methods
ZooKeeperProvides. __init__( self , charm: CharmBase , endpoint_name: str )
Constructor.
Arguments
The charm that implements the relation.
Endpoint name of the relation.
ZooKeeperProvides. update_hosts( self , client_addresses: str , relation_id )
Update hosts in the zookeeper relation.
Arguments
Comma-listed addresses of zookeeper clients.
Id of the relation. If set, it will be used to update the relation data of the specified relation. If not set, the data for all the relations will be updated.
Description
This method will cause a relation-changed event in the requirer units of the relation.