ADR: Per-environment Git branches via Komodo ResourceSync
Context
The homelab uses Komodo with ResourceSync to declare servers, stacks, deployments, and related resources from Git (an “app-of-apps” style flow: Git remains the audit trail; Komodo reconciles).
Goals:
mainshows the whole picture —dev/,test/, andprod/(or equivalentkomodo/{dev,test,prod}/) layouts exist together onmainso reviews and long-lived docs match reality after merges.- Per-environment steering — each environment’s sync can follow
mainor follow a named branch (for example to soak a stack change in Dev before it lands onmain). - Homelab-realistic ergonomics — accept some manual merge hygiene instead of building full release automation up front.
An earlier sketch of this approach lived in wip/komodo-artifact-templates/scratch/branch_management_ideas.md.
Decision
Single infrastructure repo;
mainis the default line of truth
After work merges,mainholds the canonical layout for all managed environments (folder-separated configs, per existing repo structure docs).One ResourceSync configuration per Komodo-managed environment (Dev, Test, Prod — or whichever environments are GitOps-managed)
Each[[resource_sync]](or equivalent Komodo sync configuration) sets, at minimum:- Repository (and git provider / account as required).
- Branch (or other ref field supported by Komodo’s ResourceSync schema — see Resource sync config) independently per environment.
- Resource path scope limited to that environment’s subtree (for example only
komodo/dev/**for Dev), so a branch used for experiments does not accidentally apply Prod definitions.
Branch-testing workflow
- Create a feature branch for the change under test.
- Point the target environment’s ResourceSync at that branch (for example Dev follows
feature/xyzwhile Test and Prod continue to followmain). - After validation, merge the feature branch to
main. - Manually reconcile the ResourceSync metadata on
mainso environments that should trackmainagain have their branch/ref set back tomain(or another agreed default).
Known quirk (accepted): the ResourceSync TOML that sets
branch = "feature/xyz"lives in Git. On the feature branch that file typically must reference the same branch so the sync pulls a self-consistent tree. After merge tomain, that same file’s branch field must be updated tomain(or removed to default) for environments that should no longer track the feature branch. This is intentional small, explicit edits onmain, not hidden automation, until/unless you add tooling.Releases / tags as a pin for Prod (optional, not required now)
Using tags or GitHub Releases so Prod tracksrefs/tags/v…whilemainmoves forward is a valid pattern when you want Prod immutability without branch gymnastics. With separate per-environment directories and per-sync branch control, the urgency is lower than in a single-shared-path model. We defer mandatory release-based promotion; revisit ifmainchurn becomes painful for Prod.
Consequences
Positive
- Clear mental model: folders = promotion path; branch on ResourceSync = “which revision of that tree is live for this environment.”
- Feature work can soak on Dev/Test without forking the whole repo layout conceptually on
main. - Decisions stay in Git and stay reviewable.
Negative / risks
- Merge hygiene: forgetting to repoint a ResourceSync after merge can leave an environment tracking a stale or abandoned branch.
- Self-consistency: sync config and synced paths must agree on branch, or behavior is confusing during transitions.
Mitigations (recommended, non-blocking)
- Short checklist when merging infra PRs: “ResourceSync branches updated for Dev/Test/Prod as intended?”
- Keep ResourceSync definitions in small, dedicated files (for example under
komodo/sync/or similar) so diffs are obvious. - Optionally add CI later (grep/assert expected branch for Prod) if mistakes recur.
Alternatives considered
| Alternative | Why not chosen (for now) |
|---|---|
| Prod pinned only by releases/tags | Valuable later; deferred to reduce moving parts until branch steering is proven in daily use. |
| Separate repos per environment | Duplicates structure; conflicts with single-repo promotion story already documented. |
Only ever sync from main | Forces feature testing via copy/paste or temporary files outside Git flow; rejected. |
References
- Komodo: Sync resources
- Homelab repo layout: Planned repository structure (includes promotion flow between environment folders)
- Prior scratch note:
wip/komodo-artifact-templates/scratch/branch_management_ideas.md