Skip to main content

Overview

Apache ZooKeeper is a coordination service for distributed applications: configuration storage, leader election, distributed locks, service discovery and group membership, kept consistent by a quorum of servers. This template runs either an independent ensemble of 3 or 5 servers in each location (perLocation) or one ensemble spread across 3, 5 or 7 locations with one server in each (global). Clients and servers authenticate with SASL.
This template deploys into an existing GVC you already have; it does not create, provision or manage one. With perLocation and no locations list, an ensemble runs in every location of the GVC; with a list, only the listed locations run servers and any other GVC location starts nothing. With global, every listed location must already be a location of your GVC.

What Gets Created

Nothing is published to the internet: the servers accept connections only from inside Control Plane and make no outbound internet connections.

Prerequisites

1

A credentials secret

A dictionary secret with three keys: username and password (the login every client uses) and quorumPassword (the servers authenticate to each other with it). Create it in the same org before you install, with hex passwords (no spaces, quotes or backslashes):
Read it back with cpln secret reveal SECRET_NAME -o yaml. Set credentialsSecretName to this name.
2

For global, a GVC with at least 3 locations

Read the GVC’s locations (spec.staticPlacement.locationLinks):
List 3, 5 or 7 of them in locations. A server whose GVC lacks a listed location refuses to start.
If the credentials secret does not exist when you install, the deployment waits silently and cpln logs stays empty. cpln workload get-deployments RELEASE_NAME-zookeeper --gvc GVC_NAME -o yaml names the missing secret in status.versions[].message. After the secret exists, the deployment recovers on its own within about 10 minutes. To skip the wait, run cpln workload force-redeployment RELEASE_NAME-zookeeper --gvc GVC_NAME.

Installation

Install with the default shape, an independent 3-server ensemble in every location of the GVC:
Topology, replicas and locations cannot be changed on a running release, so choose them now; see Ensemble. To install with another method, follow the instructions for your preferred tool:

UI

Browse, install, and manage templates visually

CLI

Manage templates from your terminal

Terraform

Declare templates in your Terraform configurations

Pulumi

Declare templates in your Pulumi programs

Configuration

Credentials

Name of the prerequisite secret described above.

Ensemble

With perLocation, ensembles in different locations share nothing: a znode written in one location does not exist in another. With global, one server in each listed location forms one ensemble that survives the loss of a minority of locations (1 of 3, 2 of 5, 3 of 7); every write is confirmed by a majority of locations, so it takes at least one cross-region round trip. For one ensemble across three regions:
multiZone spreads each location’s servers and their volumes across that location’s availability zones, so one zone failing takes down at most a minority of a location’s ensemble. Not every Control Plane location supports it: check that every location the release runs in does before you turn it on (see multi-zone). You can turn it on at install or at any later upgrade, but never turn it off again; see Important Notes.

Image and resources

Storage

Network access

This limits which workloads may connect. The rule covers every port, and the servers can always reach each other.

Connecting

ZooKeeper does not point at your applications. Each client configures the connect string and the SASL login itself, and internalAccess decides which workloads are allowed to reach the servers. Clients log in with SASL DIGEST-MD5 using the secret’s username and password, through a JAAS Client section:
Pass it to a Java client with -Djava.security.auth.login.config=/path/to/jaas.conf -Dzookeeper.fips-mode=false (ZooKeeper 3.9 clients disable DIGEST-MD5 unless FIPS mode is off). Unauthenticated sessions are closed. In the table, LOCATION is a location running servers. Each server logs the exact connect string for its location at start (clients connect with: …). In perLocation, point each client at its own location’s servers. Never use the workload address RELEASE_NAME-zookeeper.GVC_NAME.cpln.local: it can route a client to another location’s separate ensemble, where its data does not exist. To verify, open a shell inside a server; it is already logged in. LOCATION is the location whose ensemble you want to open:
Check a server’s role with echo srvr | nc 127.0.0.1 2181 from inside the container: Mode: leader or Mode: follower. A server that answers This ZooKeeper instance is not currently serving requests is not in a quorum.

Operations

Restoring a Backup

Restoring from a volume snapshot is manual and this template does not automate it: every server of an ensemble must be restored from snapshots taken at the same time.
Repeat the restore for every volume index of every location in the ensemble.

Scaling and Availability

  • Fault tolerance. An ensemble of 3 survives 1 server down, an ensemble of 5 survives 2. A global ensemble survives the loss of a minority of locations.
  • Rolling changes. In perLocation, servers in a location are replaced one at a time, so the ensemble keeps serving. In global, an upgrade that changes the workload restarts every location’s server at the same time, so the ensemble is unavailable until a majority is back.
  • Ready is not in quorum. A server reports ready as soon as it answers on port 2181. Check srvr as above before relying on a fresh ensemble.
  • Topology, replicas and locations are fixed at install. To change them, install a new release and move your data.
  • Growing storage. Changing volumeset.capacity does not resize an existing volume; it only sizes new ones. Grow a live volume:

Rotating Credentials

Servers read the credentials secret only at start. To rotate username or password, change one key and keep the others, then force a redeployment:
quorumPassword uses the same steps, but expect a quorum outage partway through: servers restart one at a time, and servers on the old and new passwords cannot form an ensemble together, so the ensemble stops serving until a majority runs on the new password. Writes that were acknowledged are kept. Do not use cpln workload stop and start for this: they replace the chart’s per-location server counts.

Troubleshooting

The credentials secret does not exist. See the warning under Prerequisites.
multiZone: true is set and a location the release runs in does not support multi-zone. Install with multiZone: false, or leave that location out.
Each server’s volume stays in the zone it was created in, and with multiZone: false a server whose volume is in another zone cannot be scheduled. Upgrade again with multiZone: true, then run cpln workload force-redeployment RELEASE_NAME-zookeeper --gvc GVC_NAME.
A global install lists a location your GVC does not have. Add the location to the GVC or list only GVC locations, then install a new release.
In global, the order of locations changed, which changes a server’s id. Restore the original order; it is fixed at install.
The server is not in a quorum because too few servers of the ensemble are running. Read the logs and restore a majority:
The client has no SASL login or the wrong password. Check the JAAS Client section against cpln secret reveal SECRET_NAME -o yaml.

Important Notes

  • Never turn multiZone off once it has been on. Each server’s volume stays in the zone it was created in, so with it off a server whose volume is in another zone cannot be scheduled. It is off by default and not every location supports it; see multi-zone. cpln helm upgrade does not reuse earlier values, so keep multiZone: true in your values file on every upgrade.
  • Create the credentials secret before you install.
  • topology, replicas and locations are fixed at install. Install a new release and move your data to change them. In global, never reorder locations.
  • SASL authenticates; it does not authorize. Any client with the login can read and change every znode. Set ACLs on your znodes (setAcl /path sasl:app:cdrwa) for per-application restrictions.
  • Rotate credentials with a secret update plus cpln workload force-redeployment. Never cpln workload stop and start.
  • Connect through the per-server replica-N addresses, never the workload address.

External References