Skip to content

feat(deploy): Kubernetes and Compose manifests, and the cluster env vars they need (#146) - #417

Merged
scttfrdmn merged 1 commit into
mainfrom
feat/146-deploy-manifests
Aug 9, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
feat/146-deploy-manifests

Conversation

@scttfrdmn

Copy link
Copy Markdown
Owner

Closes #146.

deploy/ was an empty directory. It now holds a StatefulSet, a DaemonSet, a headless Service and a ConfigMap for Kubernetes, plus a three-node Compose cluster over MinIO for local development.

Four of the environment variables this was to be built on did not exist

#146's spec configured its nodes with OBJECTFS_CLUSTER_ENABLED, _NODE_ID, _ADVERTISE_ADDR and _SEEDS. getEnvMappings had none of them — established by calling it rather than by grep: 24 mappings, no cluster entries. Both sdks/python/README.md and sdks/javascript/README.md already told operators to export the first one.

That is the worst available failure shape. Every pod starts, mounts, and serves reads, each one a cluster of one, with no error anywhere — because an unread variable cannot complain. Cache invalidations from peers are never received, so a node serves an object another node has already overwritten.

Five are now read (_LISTEN_ADDR is the fifth). _ENABLED uses ParseBool and returns the error, joining the monitoring toggles rather than the feature flags that coerce anything but "true" to false — the asymmetry is an integrity argument, since coerced to false it is a mount that succeeds, serves reads, and is invisible to every peer. _SEEDS is comma-separated, trimmed, empties dropped, so a manifest wrapped across lines cannot produce an empty seed (which would reach gossip as an address to dial and be reported as an unreachable peer rather than as the configuration error it is).

Three places this departs from the issue body

A StatefulSet, where #146 specified a DaemonSet — and both ship. A clustered node needs a stable identity: node_id names it in gossip, advertise_addr is what peers dial back, and a seed list must name something still there after a restart. A DaemonSet's pods get generated names that change on reschedule and no per-pod DNS, so no seed list can be written. A StatefulSet plus a headless Service gives ordinal names and resolvable records. advertise_addr comes from the DNS name and not status.podIP, because a pod IP changes on reschedule and a peer holding the old one only sees a member that stopped answering. The DaemonSet stays for the genuinely uncoordinated case — one independent mount per host — and says plainly that those nodes exchange no invalidations, so each cache is its own until cache.ttl expires.

MinIO, not LocalStack. Coordination rests on conditional writes, and a conditional write is a correctness capability: per the project thesis it fails closed rather than degrading, so an endpoint that accepts If-None-Match and ignores it does not give a slower cluster but two nodes each believing it holds the same exclusive claim. docs/design/conditional-write-compatibility.md is the probed matrix — MinIO is a measured row, LocalStack is not. Building the development environment on an unmeasured endpoint would make it the one place a coordination bug is invisible.

replicas: 3 with per-pod identity from the downward API. This is the second reason the env vars must exist: one ConfigMap is shared by every replica, so a per-pod value cannot come from a config file, and Kubernetes delivers a pod's own name and namespace as environment variables and in no other form.

Two settings that are invisible until they are wrong

  • OBJECTFS_HEALTH_ADDR moves health off loopback. DefaultHealthAddr is 127.0.0.1:8081 — right for a host install of an unauthenticated endpoint, unusable in a pod. The kubelet probes over the pod IP, gets a refused connection, never passes readiness, and the pod is restarted forever by a liveness probe that could not have succeeded, while the manifest names the right port and path throughout.
  • terminationGracePeriodSeconds: 120, not the default 30. A FUSE mount is unmounted by its own process on a signal. SIGKILL at the end of the grace period leaves the kernel holding a mount whose server is gone and loses any dirty range that had not reached S3. Liveness is also far more patient than readiness (10 failures vs 3): readiness failing removes a pod from a Service, liveness failing kills it — discarding buffered writes and doing nothing about a slow backend.

The gate, split the way systemd-unit is

kubeconform approves all five resources here and would equally approve a container invoking a subcommand that does not exist — the same hole systemd-analyze verify left in the shipped unit for a year. Schema-valid and wrong is a manifest's default state.

internal/config/deploy_test.go checks what a schema cannot: subcommands and flags scraped from cmd/objectfs/main.go, every OBJECTFS_* name read by something (in both directions), the ConfigMap's embedded config loading through the real LoadFromFile strict unmarshal, and health bound off loopback in every pod spec. A new deploy-manifests CI job adds what Go cannot: kubeconform -strict, and docker compose config to expand the anchors and confirm three distinct node identities.

Verification

Every gate mutation-verified — inventing an env var, misspelling a flag, dropping the health override, typo'ing a config key, deleting one node's identity override, and unquoting the secret each fail with the intended diagnostic, and each file restores clean.

  • kubeconform -strict → 5/5 valid
  • objectfs mount --config deploy/docker/node-config.yaml --dry-run → validates
  • go test -race ./... → no FAIL, panic, or DATA RACE
  • golangci-lint run → 0 issues
  • coverage gate → 35 packages at or above floor, internal/config 91.9% (floor 88%)
  • the CI job's shell logic run locally, and both of its assertions mutation-checked

docker compose config earned its place by finding a defect in my own file: the placeholder secret was 64 unquoted zeros, which YAML reads as the integer 0 and renders back as "0". A one-byte secret fails minSecretLen while nothing in the file appears to set it — and a real openssl rand -hex 32 value would almost never reproduce it, since it usually contains a letter. Quoted now, and the CI job asserts the resolved length.

Not in scope

Applying any of this. That needs a cluster and a FUSE-capable runner, and is worth its own job rather than a half-measure here. The mountPropagation: Bidirectional lines are shipped commented, since they require a privileged container on some versions and a hostPath a pod mounts over deserves an operator's deliberate decision.

…ars they need (#146)

deploy/ was an empty directory. It now holds a StatefulSet, a DaemonSet, a headless Service and a
ConfigMap for Kubernetes, and a three-node Compose cluster over MinIO for local development.

Four of the environment variables this was to be built on did not exist.

#146's spec configured its nodes with OBJECTFS_CLUSTER_ENABLED, _NODE_ID, _ADVERTISE_ADDR and
_SEEDS. getEnvMappings had none of them — established by calling it rather than by grep: 24
mappings, no cluster entries. Both sdks/python/README.md and sdks/javascript/README.md already told
operators to export the first one. That is the worst available failure shape: every pod starts,
mounts, and serves reads, each one a cluster of one, with no error anywhere, because an unread
variable cannot complain. Cache invalidations from peers are never received, so a node serves an
object another node has already overwritten. Five are now read; _LISTEN_ADDR is the fifth.

_ENABLED uses ParseBool and returns the error, joining the monitoring toggles rather than the
feature flags that coerce anything but "true" to false. The asymmetry is an integrity argument:
coerced to false it is a mount that succeeds, serves reads, and is invisible to every peer. _SEEDS
is comma-separated, trimmed, with empties dropped, so a manifest wrapped across lines cannot produce
an empty seed — which would reach gossip as an address to dial and be reported as an unreachable
peer rather than as the configuration error it is.

A StatefulSet where #146 specified a DaemonSet, and both ship.

A clustered node needs a stable identity: node_id names it in gossip, advertise_addr is what peers
dial back, and a seed list must name something still there after a restart. A DaemonSet's pods get
generated names that change on reschedule and no per-pod DNS, so no seed list can be written. A
StatefulSet plus a headless Service gives ordinal names and resolvable records, and the per-pod
values arrive through the downward API — the second reason the variables must exist, since one
ConfigMap is shared by every replica. advertise_addr is built from the DNS name and not
status.podIP, because a pod IP changes on reschedule and a peer holding the old one only sees a
member that stopped answering. The DaemonSet stays for the genuinely uncoordinated case and says
plainly that those nodes exchange no invalidations.

MinIO, not the LocalStack #146 specified. Coordination rests on conditional writes, and a
conditional write is a correctness capability: per the project thesis it fails closed rather than
degrading, so an endpoint that accepts If-None-Match and ignores it does not give a slower cluster
but two nodes each believing it holds the same exclusive claim.
docs/design/conditional-write-compatibility.md is the probed matrix; MinIO is a measured row in it
and LocalStack is not. Building the development environment on an unmeasured endpoint would make it
the one place a coordination bug is invisible.

Two things the manifests get right that are invisible until they are wrong. OBJECTFS_HEALTH_ADDR
moves health off loopback: DefaultHealthAddr is 127.0.0.1:8081, correct for a host install of an
unauthenticated endpoint and unusable in a pod, where the kubelet probes over the pod IP, gets a
refused connection, never passes readiness, and is restarted forever by a liveness probe that could
not have succeeded — while the manifest names the right port and path throughout. And
terminationGracePeriodSeconds is 120, not the default 30, because a FUSE mount is unmounted by its
own process on a signal: SIGKILL at the end of the grace period leaves the kernel holding a mount
whose server is gone and loses any dirty range that had not reached S3.

internal/config/deploy_test.go plus a deploy-manifests CI job are the gate, split the way
systemd-unit is and for the same reason. kubeconform approves all five resources here and would
equally approve a container invoking a subcommand that does not exist — the hole systemd-analyze
verify left in the shipped unit for a year. So Go checks what a schema cannot: subcommands and flags
scraped from cmd/objectfs/main.go, every OBJECTFS_* name read by something, the ConfigMap's embedded
config loading through the real strict unmarshal, and health bound off loopback in every pod spec.
CI adds what Go cannot: kubeconform -strict, and `docker compose config` to expand the anchors and
confirm three distinct node identities.

Verified: all four Go gates and both CI assertions by mutation — inventing an env var, misspelling a
flag, dropping the health override, typo'ing a config key, deleting one node's identity override,
and unquoting the secret each fail with the intended diagnostic. kubeconform -strict reports 5/5
valid. `objectfs mount --config deploy/docker/node-config.yaml --dry-run` validates. go test -race
./... passes with no FAIL or DATA RACE; golangci-lint 0 issues; coverage gate 35 packages at or
above their floor, internal/config 91.9% (floor 88%).

`docker compose config` earned its place by finding a defect in my own file: the placeholder secret
was 64 unquoted zeros, which YAML reads as the integer 0 and renders back as "0". A one-byte secret
fails minSecretLen with nothing in the file appearing to set it — and a real `openssl rand -hex 32`
value would almost never reproduce it, since it usually contains a letter. It is quoted now.
@scttfrdmn
scttfrdmn merged commit 3bc107e into main Aug 9, 2026
39 checks passed
@scttfrdmn
scttfrdmn deleted the feat/146-deploy-manifests branch August 9, 2026 19:56
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.

B2-2: Add Docker Compose and Kubernetes deployment manifests

1 participant