ZooKeeper cluster migration when using K8s node local storage
Describes how to migrate a ZooKeeper cluster when using K8s node-local storage such as static PV, local-path
, TopoLVM
.
Requires HA setup (3+ pods).
This solution is more risky than migration by adding followers because it reduces
the number of active consensus members but is operationally simpler. When running with clickhouse-keeper
, it can be
performed gracefully so that quorum is maintained during the whole operation.
- Find the leader pod and note its name
- To detect leader run
echo stat | nc 127.0.0.1 2181 | grep leader
inside pods
- To detect leader run
- Make sure the ZK cluster is healthy and all nodes are in sync
- (run on leader)
echo mntr | nc 127.0.0.1 2181 | grep zk_synced_followers
should be N-1 for N member cluster
- (run on leader)
- Pick the first non-leader pod and delete its
PVC
,kubectl delete --wait=false pvc clickhouse-keeper-data-0
-> status should beTerminating
- Also delete
PV
if yourStorageClass
reclaim policy is set toRetain
- If you are using dynamic volume provisioning make adjustments based on your k8s infrastructure (such as moving labels and taints or cordoning node) so that after pod delete the new one will be scheduled on the planned node
kubectl label node planned-node dedicated=zookeeper
kubectl label node this-pod-node dedicated-
kubectl taint node planned-node dedicated=zookeeper:NoSchedule
kubectl taint node this-pod-node dedicated=zookeeper:NoSchedule-
- For manual volume provisioning wait till a new
PVC
is created and then provision volume on the planned node - Delete the first non-leader pod and wait for its PV to be deleted
kubectl delete pod clickhouse-keeper-0
kubectl wait --for=delete pv/pvc-0a823311-616f-4b7e-9b96-0c059c62ab3b --timeout=120s
- Wait for the new pod to be scheduled and volume provisioned (or provision manual volume per instructions above)
- Ensure new member joined and synced
- (run on leader)
echo mntr | nc 127.0.0.1 2181 | grep zk_synced_followers
should be N-1 for N member cluster
- (run on leader)
- Repeat for all other non-leader pods
- (ClickHouse® Keeper only), for Zookeeper you will need to force an election by stopping the leader
- Ask the current leader to yield leadership
echo ydld | nc 127.0.0.1 2181
-> should print something likeSent yield leadership request to ...
- Make sure a different leader was elected by finding your new leader
- Finally repeat for the leader pod