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.
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
Prerequisites
A credentials secret
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):cpln secret reveal SECRET_NAME -o yaml. Set credentialsSecretName to this name.For global, a GVC with at least 3 locations
spec.staticPlacement.locationLinks):locations. A server whose GVC lacks a listed location refuses to start.Installation
Install with the default shape, an independent 3-server ensemble in every location of the GVC:UI
CLI
Terraform
Pulumi
Configuration
Credentials
Ensemble
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
Connecting
ZooKeeper does not point at your applications. Each client configures the connect string and the SASL login itself, andinternalAccess 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:
-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.
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:
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.Scaling and Availability
- Fault tolerance. An ensemble of 3 survives 1 server down, an ensemble of 5 survives 2. A
globalensemble 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. Inglobal, 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
srvras 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.capacitydoes 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 rotateusername 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
Nothing starts and cpln logs is empty
Nothing starts and cpln logs is empty
Workload is misconfigured (multizone enabled in an incompatible cluster)
Workload is misconfigured (multizone enabled in an incompatible cluster)
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.Servers stay initializing after multiZone was turned off
Servers stay initializing after multiZone was turned off
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.FATAL: listed locations are not in GVC
FATAL: listed locations are not in GVC
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.FATAL: /data/myid is …
FATAL: /data/myid is …
global, the order of locations changed, which changes a server’s id. Restore the original order; it is fixed at install.This ZooKeeper instance is not currently serving requests
This ZooKeeper instance is not currently serving requests
Session closed because client failed to authenticate
Session closed because client failed to authenticate
Client section against cpln secret reveal SECRET_NAME -o yaml.Important Notes
- Never turn
multiZoneoff 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 upgradedoes not reuse earlier values, so keepmultiZone: truein your values file on every upgrade. - Create the credentials secret before you install.
topology,replicasandlocationsare fixed at install. Install a new release and move your data to change them. Inglobal, never reorderlocations.- 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. Nevercpln workload stopandstart. - Connect through the per-server
replica-Naddresses, never the workload address.