Skip to content

feat(common): add statefulset template alongside deployment#68

Merged
eskp merged 1 commit intomainfrom
feat/common-statefulset-template
May 8, 2026
Merged

feat(common): add statefulset template alongside deployment#68
eskp merged 1 commit intomainfrom
feat/common-statefulset-template

Conversation

@eskp
Copy link
Copy Markdown
Member

@eskp eskp commented May 8, 2026

Summary

Adds opt-in StatefulSet mode to the common chart. Mirrors deployment.yaml 1:1 — only kind, serviceName, podManagementPolicy, terminationGracePeriodSeconds, and container lifecycle are new.

Use case Mode
Stateless web/worker, multiple replicas, rolling deploys deployment.enabled: true (existing — unchanged)
Stateful single-replica with persistent state, RWO PVC statefulset.enabled: true (new)

First consumer is raita-bot (Discord daemon with EBS-backed Hermes profile). Multi-Attach errors during deploys + cleaner serial pod replacement semantics motivated the change.

What's new

  • templates/statefulset.yaml — gated on statefulset.enabled. Surfaces `terminationGracePeriodSeconds` + container `lifecycle` hooks (preStop sleep, etc.) which the deployment template doesn't currently expose.
  • templates/pvc.yaml + templates/storageclass.yaml — now iterate the union of `deployment.volumes` and `statefulset.volumes` so PVCs/StorageClasses are created regardless of which workload kind is enabled.
  • values.yaml — new `statefulset:` section, fully documented inline.
  • Chart bump 0.2.3 → 0.3.0 (minor: additive, backward compatible).

PVC name preservation = seamless migration

The PVC name pattern (<fullname>-<volume>-pvc) is identical between the two templates. A consumer can flip from Deployment to StatefulSet on the same Helm release without re-provisioning storage — the StatefulSet binds to the existing PVC.

For raita-bot specifically:

  • Existing PVC: `raita-bot-prod-common-hermes-home-pvc`
  • After flip: same PVC, same EBS volume, no data migration needed

Migration sequence (for the consumer)

  1. `helm upgrade ... --set deployment.enabled=false --set statefulset.enabled=true ...`
  2. Helm replaces the Deployment with a StatefulSet; PVC is unchanged.
  3. New StatefulSet pod (`-0`) attaches to the same EBS volume.

Out of scope

  • `volumeClaimTemplates` (per-replica volumes) — intentionally not in this iteration. The multi-replica + per-replica-PVC story needs more thought (PVC lifecycle on scale-down, naming, etc.). Today's StatefulSet mode supports the single-replica migration case, which is what raita-bot needs.
  • Multi-replica StatefulSets are technically supported but will share the single PVC (so all replicas would mount-fail under RWO). For multi-replica, wait for the volumeClaimTemplates follow-up or use the existing Deployment mode.

Test plan

  • `helm template` renders cleanly with `statefulset.enabled=true` and a raita-bot-like values set
  • PVC name matches what existing Deployment-based releases already use
  • Pre-existing chart lint error (`templates/tests/test-connection.yaml` referencing undefined `service.port`) is unchanged — not introduced here
  • Reviewer: render with each existing service's values to confirm no behavioural change when `statefulset.enabled` is left at its default (false)

Companion PR

  • raita-bot repo: KeeperHub/raita-bot#6 — flips raita-bot to StatefulSet once this lands and the chart is published.

Adds an opt-in StatefulSet mode to the common chart for stateful
single-replica workloads (raita-bot is the first consumer). Mirrors
deployment.yaml structure so existing values map 1:1 — only the kind,
serviceName, and podManagementPolicy fields are new.

- templates/statefulset.yaml: gated on `statefulset.enabled`. Adds
  terminationGracePeriodSeconds + container `lifecycle` hooks (e.g.
  preStop sleep) that the deployment template doesn't surface.
- templates/pvc.yaml + storageclass.yaml: now iterate the union of
  `deployment.volumes` and `statefulset.volumes` so PVCs/StorageClasses
  get created regardless of which workload kind is enabled. PVC name
  pattern is unchanged (`<fullname>-<volume>-pvc`), so a Deployment can
  be flipped to a StatefulSet on the same release without re-provisioning
  storage — the existing PVC binds.
- values.yaml: new `statefulset:` section documenting the schema and
  marking it mutually exclusive with `deployment.enabled`.
- Chart.yaml: 0.2.3 → 0.3.0 (minor — additive feature, backward
  compatible; existing services with `deployment.enabled: true` continue
  to work unchanged).

Volume claim templates (per-replica volumes) intentionally not added in
this iteration — needs more thought on multi-replica StatefulSets and
PVC lifecycle. Today's mode supports the single-replica migration case
which is what raita-bot needs.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

🎉 Helm Chart Tests Passed!

All modified charts have been successfully validated:

Chart Version Check Template Validation Dry-run Installation Overall Status
common ✅ Incremented ✅ Passed ✅ Passed ✅ Passed

Summary:

  • ✅ Charts tested: common
  • ✅ All template validations passed
  • ✅ All dry-run installations passed

📋 Detailed Information:

The PR is ready for review! 🚀

Note: Charts will be automatically released when this PR is merged to main.

@eskp eskp merged commit 6d4e278 into main May 8, 2026
4 checks passed
@eskp eskp deleted the feat/common-statefulset-template branch May 8, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant