Search

Explore Fieldwork

Writing / Case study

Replacing a deprecated dependency without losing data

Swapping Bitnami ZooKeeper for the Docker Official image on an unchanged Ceph PVC meant matching on-disk log layout and catching three rehearsal traps first.

Conceptual dark-glass editorial artwork showing a translucent upper housing aligning onto an unchanged glass foundation block along a continuous acid-lime thread and a small amber alignment pin.
Conceptual illustration of an in-place container image replacement over preserved persistent storage.

Replacing a container image looks simple in YAML until you inspect where the old distribution actually wrote its state.

After an internal policy banned Bitnami container images across our clusters, one PostHog stack still depended on a Bitnami ZooKeeper 3.9.3 StatefulSet backed by a 10 GiB ceph-rbd persistent volume. Rather than rewriting the architecture to ClickHouse Keeper or downgrading to ZooKeeper 3.8, we chose an in-place distribution swap on the same 3.9 engine line using the digest-pinned Docker Official library/zookeeper:3.9.6 image (sha256:17d9b6af91d97ad4feec7b088102d34f1c42df52d6320fd794af5d01d48883a0).

Why ZooKeeper's two data files dictate the mount layout

The critical difference between the two images was not the ZooKeeper version; it was how they split snapshots from transaction logs.

ZooKeeper reconstructs its state on startup by loading its latest snapshot and then replaying the transaction log of recent writes. Bitnami placed both file sets in one folder (data/version-2) on the PVC. The Docker Official image defaults to separate /data (dataDir) and /datalog (dataLogDir) folders. Starting the official image with its default paths over the Bitnami volume would mount the snapshots at /data while creating an empty /datalog folder, silently dropping recent writes.

Pointing both directory settings at the PVC's existing data subdirectory preserved the exact on-disk contract without copying data or changing file ownership. We mounted the PVC's data subdirectory at /data, set both dataDir and dataLogDir to /data, kept UID/GID 1001 along with the 1536 MiB memory limit and 1024 MiB JVM heap, and replaced Bitnami's shell readiness scripts with native srvr and ruok checks:

Plain text
dataDir=/data
dataLogDir=/data
PVC subPath: data -> /data
UID/GID: 1001:1001
Readiness/Liveness: srvr / ruok

Because ownership and paths matched the existing volume, the cutover required no root init container, recursive chown, data copy, or PVC recreation.

Three surprises caught in an isolated clone rehearsal

Before touching the live StatefulSet, we built an automated rehearsal that cloned the production Ceph PVC into a network-isolated pod protected by a Cilium deny policy and verified that the official image could read the existing ClickHouse table namespace fingerprint. That dry run caught three operational traps:

  1. Because the ceph-rbd storage class uses WaitForFirstConsumer, creating the cloned PVC and waiting for it to bind deadlocked; the rehearsal script had to launch the isolated consumer pod before waiting on claim binding.
  2. Interactive zkCli probing behaved differently under JLine when driven over non-interactive stdin, requiring explicit command handling to verify the namespace fingerprint reliably.
  3. Our workstation kubectl configuration wraps delete with an interactive confirmation prompt that returns exit code 0 when cancelled. Automated teardown could appear to pass while leaving rehearsal resources behind, so cleanup had to bypass the prompt and verify removal explicitly.

The guarded rehearsal and cutover sequence ran through these tasks:

Shell
task validate-no-bitnami
task plan-posthog-zookeeper-migration
task rehearse-posthog-zookeeper-migration
# Teardown enforces non-interactive deletion before opening the apply gate:
kubectl delete --interactive=false -n <rehearsal-namespace> <clone resources>

Nine offline regression tests covered the migration planner, rehearsal cleanup guardrails, and the validate-no-bitnami CI check before the production window opened.

The production cutover and verification boundary

On 30 October 2026, we quiesced ClickHouse and ZooKeeper, took cold Ceph snapshots of both PVCs, applied the official ZooKeeper manifest against the unchanged StatefulSet and PVC UUIDs, and resumed ClickHouse. Post-cutover checks confirmed all 79 ClickHouse replicated tables online with zero read-only tables, zero expired sessions, a passing /_readyz?role=web check, and zero remaining Bitnami image references in active cluster workloads or manifests.

Two boundaries stay explicit in the record. An isolated PVC clone rehearsal and replica-table health check prove state continuity across the image swap, not a full PostHog disaster-recovery drill. In addition, our validate-no-bitnami CI gate enforces source manifests and active cluster specs; it does not audit the transitive build ancestry of third-party images.

Public sources

  1. Apache ZooKeeper releaseszookeeper.apache.org
  2. Docker Official ZooKeeper imagehub.docker.com
  3. ZooKeeper 3.9.6 image definitiongithub.com

Share this article

Continue reading

A graph read that crashed on its own edge schema ↗

All writing ↗