This project contains tools to facilitate the deployment of Apache ZooKeeper on Kubernetes.
This helm chart provides an implementation of the ZooKeeper StatefulSet found in Kubernetes Contrib Zookeeper StatefulSet. This chart will currently not work with any release of Helm.
This chart will do the following:
You can install the chart with the release name my-zk
as below.
$ helm repo add k8szk https://kow3ns.github.io/kubernetes-zookeeper/helm/repo/
$ helm install --name my-zk k8s/zookeeper --values=<values>
If you do not specify a name, helm will select a name for you.
You can use kubectl get
to view all of the installed components.
$ kubectl get all -l component=zk-my-zk
NAME READY STATUS RESTARTS AGE
po/zk-my-zk-0 1/1 Running 0 49s
po/zk-my-zk-1 1/1 Running 0 49s
po/zk-my-zk-2 1/1 Running 0 49s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/zk-cs-my-zk ClusterIP 10.0.22.15 <none> 2181/TCP 49s
svc/zk-hs-my-zk ClusterIP None <none> 2888/TCP,3888/TCP 49s
NAME DESIRED CURRENT AGE
statefulsets/zk-my-zk 3 3 49s
zy-my-zk
is the StatefulSet created by the chart.zk-my-zk-0
- zk-my-zk-2
are the Pods created by the StatefulSet. Each Pod has a single
container running a ZooKeeper server.zk-hs-my-zk
is the Headless Service used to control the network domain of the ZooKeeper
ensemble.zk-cs-my-zk
is a Service that can be used by clients to connect to an available ZooKeeper
server.You can specify each parameter using the --set key=value[,key=value]
argument to helm install
.
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
$ helm install --name my-release -f values.yaml incubator/zookeeper
You can use values.yaml, value-mini.yaml, or value-micro.yaml as a starting point for configuring an ensemble.
The configuration parameters in this section control the resources requested and utilized by the ZooKeeper ensemble.
Parameter | Description | Default |
---|---|---|
Servers |
The number of ZooKeeper servers. This should always be (1,3,5, or 7) | 3 |
MaxUnvailable |
The maximum number of servers that may be unavailable during eviction. This should always be one. | 1 |
Cpu |
The amount of CPU to request. As ZooKeeper is not very CPU intensive, 2 is a good choice to start with for a production deployment. |
1 |
Heap |
The amount of JVM heap that the ZooKeeper servers will use. As ZooKeeper stores all of its data in memory, this value should reflect the size of your working set. The JVM -Xms/-Xmx format is used. | 2G |
Memory |
The amount of memory to request. This value should be at least 2 GiB larger than Heap to avoid swapping. You many want to use 1.5 * Heap for values larger than 2GiB. The Kubernetes format is used. |
2Gi |
Storage |
The amount of Storage to request. Even though ZooKeeper keeps is working set in memory, it logs all transactions, and periodically snapshots, to storage media. The amount of storage required will vary with your workload, working memory size, and log and snapshot retention policy. Note that, on some cloud providers selecting a small volume size will result is sub-par I/O performance. 250 GiB is a good place to start for production workloads. | 50Gi |
StorageClass |
The storage class of the storage allocated for the ensemble. If this value is present, it will add an annotation asking the PV Provisioner for that storage class. | default |
These parameters control the network ports on which the ensemble communicates.
Parameter | Description | Default |
---|---|---|
ServerPort |
The port on which the ZooKeeper servers listen for requests from other servers in the ensemble. | 2888 |
LeaderElectionPort |
The port on which the ZooKeeper servers perform leader election. | 3888 |
ClientPort |
The port on which the ZooKeeper servers listen for client requests. | 2181 |
ClientCnxns |
The maximum number of simultaneous client connections that each server in the ensemble will allow. | 60 |
ZooKeeper uses the Zab protocol to replicate its state machine across the ensemble. The following parameters control the timeouts for the protocol.
Parameter | Description | Default |
---|---|---|
TicktimeMs |
The number of milliseconds in one ZooKeeper Tick. You might want to increase this value if the network latency is high or unpredictable in your environment. | 2000 |
InitTicks |
The amount of time, in Ticks, that a follower is allowed to connect to and sync with a leader. Increase this value if the amount of data stored on the servers is large. | 10 |
SyncTicks |
The amount of time, in Ticks, that a follower is allowed to lag behind a leader. If the follower is longer than SyncTicks behind the leader, the follower is dropped. | 5 |
ZooKeeper writes its WAL (Write Ahead Log) and periodic snapshots to storage media. These parameters control the retention policy for snapshots and WAL segments. If you do not configure the ensemble to automatically periodically purge snapshots and logs, it is important to implement such a mechanism yourself. Otherwise, you will eventually exhaust all available storage media.
Parameter | Description | Default |
---|---|---|
SnapRetain |
The number of snapshots to retain on disk. If PurgeHours is set to 0 this parameter has no effect. |
3 |
PurgeHours |
The amount of time, in hours, between ZooKeeper snapshot and log purges. Setting this to 0 will disable purges. | 1 |
Spreading allows you specify an anti-affinity between ZooKeeper servers in the ensemble. This will prevent the Pods from being scheduled on the same node.
Parameter | Description | Default |
---|---|---|
AntiAffinity |
If present it must take the values ‘hard’ or ‘soft’. ‘hard’ will cause the Kubernetes scheduler to not schedule the Pods on the same physical node under any circumstances ‘soft’ will cause the Kubernetes scheduler to make a best effort to not co-locate the Pods, but, if the only available resources are on the same node, the scheduler will co-locate them. | hard |
In order to allow for the default installation to work well with the log rolling and retention policy of Kubernetes, all logs are written to stdout. This should also be compatible with logging integrations such as Google Cloud Logging and ELK.
Parameter | Description | Default |
---|---|---|
LogLevel |
The log level of the ZooKeeper applications. One of ERROR ,WARN ,INFO ,DEBUG . |
INFO |
The servers in the ensemble have both liveness and readiness checks specified. These parameters can be used to tune the sensitivity of the liveness and readiness checks.
Parameter | Description | Default |
---|---|---|
ProbeInitialDelaySeconds |
The initial delay before the liveness and readiness probes will be invoked. | 15 |
ProbeTimeoutSeconds |
The amount of time before the probes are considered to be failed due to a timeout. | 5 |
This parameter controls when the image is pulled from the repository.
Parameter | Description | Default |
---|---|---|
ImagePullPolicy |
The policy for pulling the image from the repository. | Always |
ZooKeeper can not be safely scaled in versions prior to 3.5.x. There are manual procedures for scaling an ensemble, but as noted in the ZooKeeper 3.5.2 documentation these procedures require a rolling restart, are known to be error prone, and often result in a data loss.
While ZooKeeper 3.5.x does allow for dynamic ensemble reconfiguration (including scaling membership), the current status of the release is still alpha, and it is not recommended for production use.