---
title: Charmhub | Deploy Charmed Apache Zookeeper - K8s using Charmhub - The Open
  Operator Collection
description: Deploy the latest version of Charmed Apache Zookeeper - K8s as a Kubernetes
  Operator on any cloud.
url: https://charmhub.io/zookeeper-k8s/libraries/cluster
---

# Charmed Apache Zookeeper - K8s

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")
* [Databases](https://charmhub.io/?filter=databases)

Platform:

3/stable 78

```
juju deploy zookeeper-k8s --channel 3/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/zookeeper-k8s/libraries/cluster#drawer)

## charms.zookeeper\_k8s.v0.cluster

* [*Docstrings*Docstrings](https://charmhub.io/zookeeper-k8s/libraries/cluster)
  [*Code*Source code](https://charmhub.io/zookeeper-k8s/libraries/cluster/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.zookeeper_k8s.v0.cluster
    ```

    [Download cluster.py](https://charmhub.io/zookeeper-k8s/libraries/cluster/download)
  + *Last updated* 15 Feb 2022
  + *Revision* Library version 0.1

Library for the ZooKeeper Cluster peer relation.

---

Index

* [class ZooKeeperClusterEvents](https://charmhub.io/zookeeper-k8s/libraries/cluster#zookeeperclusterevents)
* [class ZooKeeperCluster](https://charmhub.io/zookeeper-k8s/libraries/cluster#zookeepercluster)
* + [def \_\_init\_\_(
    self,
    charm,
    client\_port,
    server\_port,
    election\_port)](https://charmhub.io/zookeeper-k8s/libraries/cluster#zookeepercluster-__init__)
* + [def cluster\_addresses(
    self)](https://charmhub.io/zookeeper-k8s/libraries/cluster#zookeepercluster-cluster_addresses)
* + [def client\_addresses(
    self)](https://charmhub.io/zookeeper-k8s/libraries/cluster#zookeepercluster-client_addresses)
* + [def register\_server(
    self,
    host)](https://charmhub.io/zookeeper-k8s/libraries/cluster#zookeepercluster-register_server)

#### class ZooKeeperClusterEvents

ZooKeeper cluster events.

Description

This class defines the events that the ZooKeeper cluster can emit.

Events:
servers\_changed (\_ServersChangedEvent)

#### class ZooKeeperCluster

ZooKeeper cluster peer relation.

Methods

ZooKeeperCluster.
\_\_init\_\_(

*self*

,
charm: CharmBase

,
client\_port: int

,
server\_port: int

,
election\_port: int
)

Constructor.

Arguments

charm
(CharmBase)

The charm that implements the relation.

client\_port
(int)

Client port. Defaults to 2181.

server\_port
(int)

Server port. Defaults to 2888.

election\_port
(int)

Election port. Defaults to 3888.

ZooKeeperCluster.
cluster\_addresses(

*self*
)

Get the zookeeper servers from the relation.

Returns

List[str]

list containing the zookeeper servers. The servers are represented
with a string that follows this format: <host>:<server-port>:<election-port>

ZooKeeperCluster.
client\_addresses(

*self*
)

Get the zookeeper servers from the relation.

Returns

List[str]

list containing the zookeeper servers. The servers are represented
with a string that follows this format: <host>:<server-port>:<election-port>

ZooKeeperCluster.
register\_server(

*self*

,
host: str
)

Register a server as part of the cluster.

Arguments

host
(str)

IP or hostname of the zookeeper server to be registered.

Description

This method will cause a relation-changed event in the other units,
since it sets the key "host" in the unit relation data.
