spec.additionalVolumeMounts mounts extra volumes into the Dragonfly main
container. It is the missing counterpart to the existing spec.additionalVolumes
(which only adds volumes to the pod, without mounting them). Pairing the two lets
you compose several snapshot/cache patterns without any snapshot-specific API —
the operator does not need to know what the volume is for.
Status:
additionalVolumeMountsis proposed in a fork of dragonfly-operator (based on v1.6.1).additionalVolumes,initContainersandspec.snapshot.dirare existing v1.6.1 fields. All examples below were validated end-to-end on a real cluster (Dragonfly v1.27.0, operator v1.6.1 + the field).
- In-place container restarts lose data. A kubelet minor upgrade that changes
the container hash (e.g. 1.30→1.31) restarts every container on the node in place
(same pod,
restartCount++). Without a snapshot, the Dragonfly master comes back empty and a replica full-syncs from the empty master → both empty. - Dragonfly saves a snapshot on
SIGTERMto--dirand loads the latest snapshot from--diron start. So a snapshot dir that survives the container restart is enough to preserve data. emptyDiris ideal for that: it survives in-place container restarts (pod is alive → volume is alive), does not pin the pod to a node (unlike a local-path PVC), and is free.- Operator v1.6.1 adds
--break_replication_on_master_restart=trueby default, which alone protects the rolling case (nodes upgraded one at a time — a restarted empty master no longer poisons the surviving replica). A snapshot volume additionally protects the simultaneous both-pods restart / hard crash of both.
| You want… | Use | File |
|---|---|---|
| Survive in-place restarts / simultaneous crash without pinning the pod | writable emptyDir as snapshot dir |
pattern-1-emptydir-crash-protection.yaml |
| Immutable warm-up cache: every start loads a golden snapshot, runtime writes never touch it | readOnly seed volume as snapshot dir |
pattern-2-readonly-warmup-cache.yaml |
| Warm up from a golden seed and keep runtime state across in-place restarts | init-seed → writable emptyDir |
pattern-3-combo-seed-plus-emptydir.yaml |
| Scenario | Pattern 1 emptyDir | Pattern 2 readOnly seed | Pattern 3 combo |
|---|---|---|---|
| Fresh pod startup | starts empty (or replicates) | loads golden seed | loads golden seed (init) |
| Runtime writes | persist to emptyDir on save | in-memory only, never hit disk | persist to emptyDir on save |
| In-place container restart | ✅ reloads saved state | ✅ reloads golden seed | ✅ reloads grown state |
| Both pods restart at once | ✅ each reloads own snapshot | n/a (warm-up) | ✅ each reloads own snapshot |
| Pod reschedule (node death) | fresh emptyDir → replica resync | re-loads golden seed | re-seeds golden baseline |
Ran on a real cluster (Dragonfly v1.27.0, 1000-key dataset), triggering an in-place
container restart with kill -TERM 1 (same effect as a kubelet container-hash restart):
| Scenario | Check | Result |
|---|---|---|
| S1 — emptyDir | restart of both containers at once | ✅ 1000/1000 |
| S2 — read-only warm-up | loads seed / runtime write gone after restart | ✅ 1000 → write → restart → 1000, k:HACK absent |
| S3 — combo | warm-up → grow → container restart → pod reschedule | ✅ 1000 → 1002 → 1002 (growth kept) → 1000 (re-seed) |
additionalVolumeMountsis a plain[]corev1.VolumeMount, sosubPath,readOnly,mountPropagationetc. are available — set only what you need.readOnly+snapshot.crondon't mix: cron/SIGTERM saves logFailed to perform snapshot Read-only file system(a warning, not a crash). Omitcronon read-only snapshot dirs.emptyDirsurvives container restart, not pod deletion/reschedule — it is runtime protection, not durable backup. For durable snapshots use a PVC or S3.- The combo pattern relies on init containers running once per pod creation, not
per container restart, and on Dragonfly always loading the latest dump in
--dir(runtime saves are newer than the seed).