Skip to content

ADR 011

Change flow and promotion

Every change goes through GitHub. Staging takes an update first, and production takes it once the release is 7 days old.

Status
Accepted
Rollout
1 of 10 gates
Related

Accepted, not yet implemented. The repo is on GitHub and CI runs on Actions. Changes still go straight to main. Only staging syncs from this repo, and production k3s syncs igresc/gitops from Gitea.

Context

One operator runs the homelab, with AI agents and Renovate doing most of the changes. Pushing to main deploys staging today. The Gitea checks run only on PRs, and agents push straight to main, so nothing requires them. Production will move to Talos and sync from this repo too, so one bad commit could reach both clusters. The flow has to stop that without making the owner approve every update.

Decision

Forge

Use GitHub Free with private repos. Free has no protected branches, required checks or CODEOWNERS on private repos. GitHub Pro is optional and only buys the PR gate below. GitLab.com Free is the fallback. Every forge-specific step belongs to the forge migration, so picking a different forge changes that migration and not this design. Gitea is retired.

Pull requests and required checks

This section applies only if the owner buys GitHub Pro. Without Pro, changes go straight to main as they do today, and the checks run after the push.

Every change to main goes through a PR with required checks. Agents and Renovate work as the GitHub App igresc-homelab and merge their own PRs once the checks pass.

CODEOWNERS requires the owner's approval for these paths:

  • docs/decisions/**
  • .github/**
  • CODEOWNERS
  • renovate.json
  • AGENTS.md

The owner is on the bypass list, so they can merge their own PRs.

Agents are trusted. CODEOWNERS controls what merges, not what runs. Any same-repo PR workflow can run code and write commit statuses before anyone approves it, so an agent could forge a status. We accept that. The checks guard against mistakes, not against a hostile agent.

Identities

  • Agents and Renovate use the private GitHub App igresc-homelab, owned by igresc and installed only on selected repos. There is no machine account. They mint installation tokens that expire after 1 hour from the App private key in OpenBao at kv/infra/github/homelab-app (keys app_id and private_key). Commits show as igresc-homelab[bot]. With Pro, the App can be a ruleset bypass actor.
  • Flux gets one read-only deploy key per cluster.
  • GHCR pulls use a classic PAT on igresc with only read:packages. It is stored in OpenBao at kv/infra/github/ghcr-pull (keys username and token), and External Secrets turns it into image pull secrets. GHCR accepts only classic PATs outside Actions, so App tokens and fine-grained PATs don't work for it.
  • The Docker host Git backup uses a read-only fine-grained PAT per GitHub owner, kept outside the NFS backup tree.
  • Recovery codes and a second authenticator live in Bitwarden cloud, and the recovery email is outside the lab.

GitOps promotion

Both clusters sync main, each from its own directory: kubernetes/clusters/staging and kubernetes/clusters/prod. Chart versions, image tags and values that change behavior live in the environment directories. No shared base changes both clusters at once. That means:

  • the shared Traefik, cert-manager and External Secrets pins in kubernetes/infrastructure/controllers move into per-environment patches;
  • the Flux selector in each FluxInstance is per environment;
  • each environment pins Cilium once, in its Flux source, and the bootstrap in terraform/cilium.tf reads that version;
  • the Talos version, the Kubernetes version, the image schematic and the ISO are inputs of each cluster (ADR 002).

The Longhorn, cert-manager and External Secrets releases upgrade their CRDs with the chart (upgrade.crds: CreateReplace).

Renovate

Renovate runs as a scheduled workflow on the self-hosted runners. It uses installation tokens from the igresc-homelab App, so its PRs trigger CI. Staging and production have separate rules, split with matchFileNames and additionalBranchPrefix.

  • Staging PRs merge themselves after the checks pass.
  • Production PRs open once the release is 7 days old (minimumReleaseAge).
  • Patch and minor app updates merge themselves on production.
  • Apps on the real-data list stay manual on production.

No check ties a production PR to what staging ran. The 7 days give a bad release time to show on staging or upstream. Flux remediation rolls back a failed HelmRelease upgrade, and an alert fires when a staging reconciliation fails. A staging-soak check that held each production PR until staging had run the same candidate for 24 healthy hours was dropped on 2026-11-21. It needed commit statuses from Flux, a status-only token and a scheduled re-run.

Majors and the platform set stay manual. The platform set is Talos, Kubernetes, Cilium, Flux, Longhorn, CNPG, OpenBao, cert-manager, External Secrets, Mimir and Loki. A minor or major version of Talos, Kubernetes, Cilium or Longhorn runs on a temporary cluster first (ADR 002). Patch releases of the platform go to staging, then to production.

Renovate also covers Terraform providers, Ansible collections and workflow actions.

Updates tested with real data

Some apps need their update tested against real data before production gets it. Immich is the first. The list lives in the Renovate configuration.

To test one, refresh staging from last night's production backup. Volumes come from a Longhorn restore out of the B2 backup store, and databases from a CloudNativePG recovery bootstrap. Large media stays on TrueNAS, and staging reads a snapshot copy of it. Apply the update on staging, check the app, then merge the production PR by hand. Every such test is also a restore test.

Staging then holds personal data. It stays private and handles secrets the way production does. It reads the production backup stores with read-only credentials and never writes to them. The public docs site moves to production before staging holds personal data.

CI runners

Runner containers on the Docker host run the jobs. GitHub Free has no account-level self-hosted runners, so each repo registers its own. igresc/homelab has four, one job each, so its jobs run in parallel. Repos that only build an image use GitHub-hosted runners instead, which fit in the 2,000 free minutes a month. The Gitea runners are retired.

Actions Runner Controller on production is deferred until the cluster has dedicated workers. CI builds come in bursts and would share nodes with etcd.

There is no separate privileged runner. The repos are private and only the owner and agents can push, so there is no fork threat to isolate.

Registry

Images go to GHCR and stay private.

Terraform in CI

CI plans the app root on every PR and applies it on main. It logs into OpenBao with the GitHub Actions OIDC token through a JWT auth mount.

  • tf-plan is read-only and accepts any branch of igresc/homelab.
  • tf-apply accepts only refs/heads/main with event_name=push, so a main-ref token never runs PR code.
  • Both roles also bind the repository, the audience and the Terraform workflow file (workflow_ref).
  • GCS access uses Workload Identity Federation with the same conditions.
  • PR plans run with -lock=false.
  • The vault provider sets skip_child_token = true in CI, so tf-plan doesn't need token-create rights.

No Terraform secrets are stored in GitHub. The first apply, which creates these roles, runs locally.

Consequences

Most updates reach staging and then production with no owner action. With Pro, CODEOWNERS paths need the owner's approval. Majors and the platform set stay manual. A bad staging change still reaches staging.

Production takes an app update 7 days after its release unless someone closes the PR, whether or not staging ran it well. That is weaker than a soak check and has nothing to maintain. Moving every pin into the environment directories is the cost of updating the two clusters apart.

CI keeps running on the Docker host, outside the cluster, so CI does not survive the loss of that one VM.

A compromised agent could merge a production change. CODEOWNERS doesn't cover terraform/**, so any merge on main triggers a tf-apply of the app root. That root holds the OpenBao policies and auth, and Grafana. This design accepts both risks under the trusted-agent assumption, in exchange for not reviewing every PR.

References

Rollout gates

  • If the owner bought Pro, the pilot in a throwaway private repo passes with real App installation tokens. Direct and force pushes to main fail. Missing or failing checks block merges. Passing checks let the App merge without approval. CODEOWNERS paths need the owner. The owner's bypass works. open
  • If the owner bought Pro, branch protection and CODEOWNERS are on for igresc/homelab. open
  • CI runs on Actions and renders both environments on every PR. done
  • Flux on both clusters syncs from GitHub with its own deploy key. open
  • No shared base pins a version or behavior-changing value for both clusters. Each FluxInstance selector is per environment, and each environment pins Cilium once. open
  • Renovate runs on a schedule with split staging and production rules, and production PRs open 7 days after a release. open
  • Flux has rolled back one failed HelmRelease upgrade, and an alert fires when a staging reconciliation fails. open
  • One app on the real-data list has been updated on staging against a refresh from the production backup. open
  • The tf-plan and tf-apply roles and the GCS federation exist. A PR plan and a main apply have run in CI, and a PR token has failed to get tf-apply. open
  • Images pull from GHCR through the External Secrets pull secret. open

docs/decisions/011-change-flow-and-promotion.md