Repository navigation
feat(deploy): Kubernetes and Compose manifests, and the cluster env vars they need (#146) - #417
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ADDRand_SEEDS.getEnvMappingshad none of them — established by calling it rather than by grep: 24 mappings, no cluster entries. Bothsdks/python/README.mdandsdks/javascript/README.mdalready 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_ADDRis the fifth)._ENABLEDusesParseBooland 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._SEEDSis 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_idnames it in gossip,advertise_addris 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_addrcomes from the DNS name and notstatus.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 untilcache.ttlexpires.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-Matchand ignores it does not give a slower cluster but two nodes each believing it holds the same exclusive claim.docs/design/conditional-write-compatibility.mdis 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: 3with 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_ADDRmoves health off loopback.DefaultHealthAddris127.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-unitiskubeconformapproves all five resources here and would equally approve a container invoking a subcommand that does not exist — the same holesystemd-analyze verifyleft in the shipped unit for a year. Schema-valid and wrong is a manifest's default state.internal/config/deploy_test.gochecks what a schema cannot: subcommands and flags scraped fromcmd/objectfs/main.go, everyOBJECTFS_*name read by something (in both directions), the ConfigMap's embedded config loading through the realLoadFromFilestrict unmarshal, and health bound off loopback in every pod spec. A newdeploy-manifestsCI job adds what Go cannot:kubeconform -strict, anddocker compose configto 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 validobjectfs mount --config deploy/docker/node-config.yaml --dry-run→ validatesgo test -race ./...→ no FAIL, panic, or DATA RACEgolangci-lint run→ 0 issuesinternal/config91.9% (floor 88%)docker compose configearned its place by finding a defect in my own file: the placeholder secret was 64 unquoted zeros, which YAML reads as the integer0and renders back as"0". A one-byte secret failsminSecretLenwhile nothing in the file appears to set it — and a realopenssl rand -hex 32value 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: Bidirectionallines 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.