Repository navigation
k3s, setup-secrets: Cluster secrets in a group of their own, run after k3s - #37
Merged
Merged
Conversation
This was referenced Nov 19, 2026
Merged
Merged
Merged
setup-secrets: Cluster sources and destinations through shared's helpers
nixos-homelab/networking#26
Merged
Merged
…r k3s lib.setup-secrets gets helpers for cluster sources and destinations: kubeSecretSource (with an optional generator for a missing Secret or field), kubeExecSource (waits for the rollout first), kubeSecretDestination and clusterDestination. The destinations are in the setup-secrets group cluster and retry while k3s and the workloads come up. The k3s module declares that group and wires its unit to k3s (wanted by, part of and after k3s.service), in place of ordering the old setup-secrets.service after k3s. A deploy that restarts k3s now stores the cluster secrets again once it is back. The k3s VM test covers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andsens
force-pushed
the
setup-secrets-groups
branch
from
November 19, 2026 20:46
5e92349 to
27e1329
Compare
andsens
enabled auto-merge (squash)
November 19, 2026 20:46
This was referenced Nov 19, 2026
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.
Needs andsens/nixos-setup-secrets#13 and #14 (setup-secrets groups as
setup-secrets@<group>.service). Locked to #14's head until those merge; relock to main before merging this.What changes
lib.setup-secretsgets helpers next tomkScript:kubeSecretSource: reads one field of a Secret. Withgenerate, a missing Secret or field makes a new value; an API that doesn't answer still fails the source, so a value is never replaced because k3s was down. (The oldgetKubeSecret … || wg genkeyin client-vpn generated a new key on any failure.)kubeExecSource:kubectl rollout statusfirst, thenkubectl exec, for API keys a workload writes itself.kubeSecretDestination: one Secret fromdata(field → source);clusterDestination: a script of its own.cluster; everything getstimeout = 60sandretries = 5(exec sources 150 s, 2 retries).setup-secrets.groups.clusterand addswantedBy/partOf/after = k3s.servicetosetup-secrets@cluster, in place ofsystemd.services."setup-secrets".after. The cluster secrets are stored after every start of k3s, so a deploy that restarts k3s stores them again once it's back.Test:
checks.k3sgets a subtest (last, since restarting k3s makes it re-apply its own manifests, which the takeover subtest races with): a Secret generated through the helpers appears after boot, a restart of k3s re-runs the group, and the value stays the same. Passes locally (167 s), together with deadnix, manifests, logs and logql.The module repos move their cluster sources and destinations to these helpers in their own PRs (same branch name).
🤖 Generated with Claude Code