new: delivery via Flux pull and CI-committed digests (ADR-0007)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
86281226fc
commit
3d8e3c7e6f
1 file changed
+24
@@ -0,0 +1,24 @@
|
||||
# Flux pulls from git; CI builds images and commits their digest
|
||||
|
||||
Every green merge to protected `main` reaches production, with no release tags and no staging. **Gitea Actions** runs CI on a dedicated runner VM. On a PR it runs lint, pyright, import-linter, the testcontainers test suite, the image build, a smoke test, the OpenAPI export, and a Trivy scan that fails on fixable critical or high CVEs. On `main` it also pushes the image to **Gitea's container registry** and commits the new **digest** into `deploy/apps/hapi`. **Flux** in the cluster polls this repo every minute and applies what's committed. The cluster pulls; CI never pushes to it. CI holds no cluster credentials, and the cluster holds no git credentials (the repo is public, so Flux fetches anonymously over HTTPS). Kubernetes and Talos APIs stay reachable only from the management tailnet (ADR-0002), and no CI system ever joins it.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **CI push** (`kubectl apply` / `helm upgrade` from a workflow). Rejected: the runner would join the management tailnet with a kubeconfig, so a compromised workflow or dependency would become cluster-admin, and Tailnet Lock would have to trust another node.
|
||||
- **Argo CD.** Rejected for its web UI, which would need keeping off the internet, and its weight. One operator with `flux`/`kubectl` over the tailnet doesn't need a UI.
|
||||
- **Flux image automation** writing digest bumps back to git. Rejected: it needs a write deploy key inside the cluster, turning a cluster compromise into a source-code compromise. CI already decides which image runs, so giving CI the write key adds little.
|
||||
- **A Flux webhook `Receiver`** for instant deploys. Rejected: it's a new public HTTP route without per-Principal auth (ADR-0002). A one-minute poll is fine.
|
||||
- **A runner on the Gitea host or in the cluster.** Rejected: a job with Docker access on the Gitea host can read every repo and every Actions secret, and the cluster shouldn't run CI workloads.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Layout:** `deploy/clusters/prod` (Flux's entry point), `deploy/infrastructure` (`HelmRelease`s for upstream components), `deploy/apps/hapi` (the Kustomize base, including the migrate Job). Flux runs with `prune: true` and drift correction on. The Owner installs Flux once over the tailnet with `flux install` plus a `GitRepository`/`Kustomization`. From then on Flux manages itself from git.
|
||||
- **Migrations run as a Job in their own Flux Kustomization** (`hapi-migrate`), using `hapi_migrator` credentials (ADR-0004). The Job name carries the image digest, so each release gets a new Job. The app Kustomization `dependsOn` it with `wait: true`, so a failed migration stops the rollout and the old pods keep serving. **Migrations must be backward-compatible** (expand, then contract in a later release) because old pods run against the new schema. **Migrations go forward only:** there are no down-migrations.
|
||||
- **Rollout:** 2 replicas, `maxSurge: 1`, `maxUnavailable: 0`, no HPA, a PodDisruptionBudget with `minAvailable: 1`, and replicas spread across the two workers. That's at most 3 app pods, within ADR-0004's cap of 4.
|
||||
- **Rollback is `git revert` of the digest bump.** A rollout that never becomes ready stalls, and the old pods keep serving. There's no automated rollback. Break-glass: `flux suspend`, then `kubectl rollout undo`, then bring git back in line.
|
||||
- **Images are public**, because Gitea package visibility follows the owner. Images must never contain secrets. Deploys reference digests, never mutable tags. Builds are amd64 only.
|
||||
- **The CI write credential is a deploy key with write access**, stored as an Actions secret and allowlisted past `main`'s branch protection. The build workflow's path filter skips bump commits, so a bump doesn't trigger another build.
|
||||
- **Renovate runs nightly** on the same runner as its own bot user. It auto-merges only dev-only tooling. Anything that ships (runtime dependencies, base image, charts, Flux, Talos, OpenTofu providers) arrives as a PR the Owner merges.
|
||||
- **Not delivered through Flux:** the runner VM, Cilium, and the Linode CCM live in OpenTofu under `infra/`, and the Owner runs `tofu apply` over the tailnet. Talos and Kubernetes upgrades are a manual `talosctl` runbook. CI never holds the Tofu state key.
|
||||
- **Failures notify through ntfy:** a final `if: failure()` step in each workflow, and Flux's notification-controller for failed reconciles and rollouts. Topics and auth are designed with notifications.
|
||||
- **Deferred:** having Flux verify commit signatures, and signing images (cosign) with admission-time verification. Both guard against a compromised Gitea and belong together in cluster hardening.
|
||||
Reference in new issue
Block a user