Start bootstrap helm charts #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I'm curious if the base level helm charts needed for cluster operations can be started from the nixos flake for the master of the kubernetes cluster. These repositories show some promise.
https://github.com/nix-community/nixhelm
https://github.com/farcaller/nix-kube-generators
@hermes-bot do an evaluation and propose an implementation in a response here.
hermes-bot referenced this issue2026-10-06 05:37:55 +00:00
Evaluation: nixhelm + nix-kube-generators as the bootstrap path
I audited both projects against our actual setup (
richardpickler.com/nixosmodules/kubernetes/*, and the 28 chart repos + ~28 releases inrichardpickler.com/helm/helmfile.yaml). Short answer: yes, this can work, and the master flake is a reasonable place to start — but as a hybrid, not a big-bang helmfile replacement.What each project actually is
charts/<repo>/<chart>with version+hash pinned in Nix, sonix flake update nixhelmmoves charts as reviewable commits instead of at deploy time. Public Cachix (nixhelm.cachix.org) serves prebuilt chart derivations. It accepts PRs adding charts viahelmupdater.buildHelmChart(runshelm templatein the Nix sandbox → a manifests derivation) andfromHelm(same, parsed to a Nix attrset). It renders; it never installs. Note the maintenance caveat: ~27 commits total, last activity Nov 2025 — stable but not lively, so we should pin it by rev.Coverage vs our helmfile.yaml
Already vendored in nixhelm:
authentik,traefik(+traefik-crds),prometheus-community,argoproj(argo-cd/workflows — the ArgoCD TODO item),nextcloud,forgejo-helm,kubernetes-sigs(node-feature-discovery),coredns,nvidia, pluslonghorn/metallb/external-secrets/oauth2-proxy/kyvernoif we ever want them.Not vendored (would need upstream PRs or the fallback below):
woodpecker-ci,wg-easy(slybase OCI),zigbee2mqtt,homeassistant,node-red(schwarzit),dependency-track,helmforge,btrfs-nfs-csi(ours — it's a git-repo chart anyway),adnoctem/fmjstudios,bokysan smtp,cowboysysop whoami, CrunchyDatapgo/postgres,local-path-provisioner.Important for the bootstrap question specifically: the cluster plumbing (CNI, DNS, scheduler, RBAC bootstrap) is already done by nixpkgs
services.kubernetes(flannel,addons.dns,addonManager.bootstrapAddons) onlurch. So "bootstrap helm charts" for us is really: traefik (+CRDs) → authentik → storage → monitoring — and the first two are exactly what nixhelm covers.Proposed implementation (phased)
Phase 0 — inputs on the nixos flake (the master,
lurch, is the apply point):Phase 1 — a
bootstrap/library in the nixos repo. One Nix file per bootstrap chart that takes chart + values (values moved out of helmfile.yaml intobootstrap/values/*.nixor.yaml) and produces a rendered-manifests derivation:Expose as flake
packages.<system>outputs sonix build .#traefik-manifestsis a pure, reproducible render, and review happens as a git diff of rendered output.Phase 2 — apply mechanism, deliberately thin. A
nix run .#apply-bootstrapscript (or asystemd.onActivationservice onlurchgated by a flag) doingkubectl apply -f ${result}with the master's kubeconfig. Charts not in nixhelm render viakubelib.downloadHelmChart { repo = ...; chart = ...; version = ...; chartHash = ...; }— one hash-bootstrap build per chart, then pinned forever. That keeps helmfile as the escape hatch for the long tail instead of forcing ~12 upstream PRs up front.Phase 3 — GitOps convergence. The helmfile TODO already says "Install ArgoCD & continuous deployment": rendered manifests from Phase 1 are exactly ArgoCD's preferred input. ArgoCD itself rendered from
nixhelm.argoproj.argo-cd, self-hosting its own app definitions. At that point helmfile retires except where the long tail still lives.Risks / things I'd verify in the pilot
buildHelmChartrenders without cluster validation: it can't catch bad-vs-cluster API drift, so pinningkubeVersion/apiVersionsper chart matters (our apiserver version comes from nixpkgs, not from the chart repo).helm repo addside effects (we have twogit+https://repos) won't — those stay on downloadHelmChart/helmfile.lurch) or external-secrets later; rendering with decrypted values baked into a derivation would leak into the Nix store.helm templateoutput ordering is stable but not guaranteed across helm upgrades; diffs will occasionally be noisy.fromHelm's YAML parsing had an octal-permissions bug upstream (fixed via their fromYAML workaround) — pin by rev, not branch.Suggested first concrete step
A pilot PR rendering traefik + traefik-crds + authentik three ways — helmfile template vs
nix buildof the nixhelm chart vs nix-kube-generators render — and ahelm diff-equivalent comparison against what's live on the cluster. If the diff is clean, Phase 2's apply wrapper is ~30 lines of Nix and we've got the bootstrap pattern. Happy to build that pilot on request.— hermes-bot (evaluation: nixhelm tree/API + nix-kube-generators README/lib checked 2026-10-09; coverage cross-checked against all repos in helmfile.yaml)
@hermes-bot
I would prefer it if the charts we embed in this way are directly injected into kubernetes as part of a nixos-rebuild switch. This could happen as a systemd service, which would simply mean we render the charts to a derivation, and have the service call helm apply from that path.
I also want what is controlled by this work to be as minimal as possible to stand up the cluster. The btrfs storage csi seems the most obvious as it's tied to the same version that's installed horse. It's also needed for anything else to store their data. Next would probably be metallb, traefik and argocd. The rest of the infrastructure should be managed by argocd, including forgejo.
Agreed on all three points — implemented as PR #23 (
issue-5-bootstrap-helm), scoped to exactly the minimum you named.Render-to-derivation + systemd apply, as requested. New
modules/kubernetes/bootstrap/module: the chart is rendered byhelm templateinside a derivation (pure — builds with no cluster), landed at/etc/kubernetes/bootstrap-manifestsviaenvironment.etc, and akubernetes-bootstraponeshot unit (wantedBykubernetes.target) applies it duringnixos-rebuild switch. The unit is a reconciler — it waits for the API server and retries (Restart=on-failure), so ordering against apiserver readiness on a fresh cluster is handled — and applies with--server-side --prune, so removed resources go away on the next switch.Minimal = the btrfs storage CSI, and only that. The chart source is
inputs.btrfs-nfs-csi + /charts/btrfs-nfs-csi— the same flake pin that builds the agent binaryservices.btrfs-nfs-csiships on horse, so the "tied to the same version installed horse" property is structural: chart, appVersion, and agent move together on onenix flake update btrfs-nfs-csi. StorageClass names/values keep parity with the current helmfile release (btrfs-nfs-nosync,btrfs-nfs-backup,kubeletDir=/var/lib/kubernetes). metallb/traefik/argocd are deliberately not in this slice — per your line, they're the ArgoCD bootstrapper's job, which slots into this same module as a follow-up.Details worth noting for review:
helm templatein a derivation) in ~25 lines. Worth reconsidering only when we render many charts outside ArgoCD.existingSecret); the unit creates it once from a sops-nix secret file at runtime. I verified in the driver source (integrations/kubernetes/controller/config.go) that the controller reads exactly keyagentTokenfrom that Secret.snapshotClassdefaults off — the chart's VolumeSnapshotClass needs the snapshot CRDs + controller, which stockservices.kubernetesdoesn't ship; enabling it would fail the apply. Snapshots belong to the ArgoCD layer.hosts/lurch.nixcarries the config block withenable = false: flip-on is (1) encrypt abtrfs-csi-agent-tokensops key, (2) setenable = true. Once enabled on the live master the switch is an idempotent re-apply.One honest caveat: this environment has no Nix runner, so the config isn't
nix eval-verified yet — reviewed against the nixpkgsservices.kubernetesmodule sources and the chart at the pinned rev. CI/woodpecker on the PR (or anix eval .#nixosConfigurations.lurch) will close that out before merge.