How do code changes reach the cluster? #56

Closed
opened 2026-11-23 16:05:25 -05:00 by bobby · 3 comments
Owner

Part of #44

Question

What is the path from a commit to running in production? Decide CI (e.g. Gitea Actions), container registry, deployment method (GitOps controller such as Argo CD/Flux vs CI-push), manifest format (Helm, Kustomize), database migration execution, and rollback.

Part of #44 ## Question What is the path from a commit to running in production? Decide CI (e.g. Gitea Actions), container registry, deployment method (GitOps controller such as Argo CD/Flux vs CI-push), manifest format (Helm, Kustomize), database migration execution, and rollback.
bobby added the wayfinder:grilling label 2026-11-23 16:05:25 -05:00
bobby added a new dependency 2026-11-23 16:05:35 -05:00
bobby added a new dependency 2026-11-23 16:05:35 -05:00
Author
Owner

Inputs from Which libraries and conventions form the FastAPI app skeleton?: CI should call the just recipes (lint, pyright, import-linter, tests on testcontainers Postgres), build the multi-stage image, smoke-test it, and export the OpenAPI schema as an artifact. Migrations are an explicit hapi migrate step that this ticket must place (Job, hook, etc.). Renovate is committed to; where it runs is decided here.

Inputs from [Which libraries and conventions form the FastAPI app skeleton?](https://git.bobbypalko.com/bobby/hapi/issues/51#issuecomment-196): CI should call the `just` recipes (lint, pyright, import-linter, tests on testcontainers Postgres), build the multi-stage image, smoke-test it, and export the OpenAPI schema as an artifact. Migrations are an explicit `hapi migrate` step that this ticket must place (Job, hook, etc.). Renovate is committed to; where it runs is decided here.
Author
Owner

Constraint from How does hAPI connect to its managed database? (#53, ADR-0004): the DB connection budget caps concurrent app pods at 4, including rollout surge (10 connections each, out of ~46 usable). Replica count, HPA max and maxSurge must respect that. hapi migrate runs as hapi_migrator, a separate credential from the app's.

Constraint from **How does hAPI connect to its managed database?** (#53, [ADR-0004](https://git.bobbypalko.com/bobby/hapi/src/branch/main/docs/adr/0004-database-access.md)): the DB connection budget caps **concurrent app pods at 4, including rollout surge** (10 connections each, out of ~46 usable). Replica count, HPA max and `maxSurge` must respect that. `hapi migrate` runs as `hapi_migrator`, a separate credential from the app's.
bobby self-assigned this 2026-11-24 13:13:26 -05:00
Author
Owner

Resolution

Recorded in ADR-0007.

  • Pull-based delivery with Flux. Flux polls this public repo anonymously over HTTPS every 1 min, with prune and drift correction on, and holds no git credentials. The Owner installs it once over the tailnet. Layout: deploy/clusters/prod, deploy/infrastructure (HelmReleases), deploy/apps/hapi (Kustomize). There's no webhook Receiver.
  • CI on Gitea Actions, on a dedicated runner VM defined in OpenTofu under infra/: deny-all inbound, not on the tailnet.
    • On a PR: just lint, pyright, import-linter, testcontainers tests, image build, smoke test, OpenAPI artifact, and a Trivy scan that fails on fixable critical or high CVEs.
    • On main: the same, then push to Gitea's container registry (public images) and commit the digest bump using a write deploy key allowlisted on protected main.
  • Every green merge to main deploys. There are no release tags.
  • Migrations: a digest-named Job in its own Flux Kustomization, running as hapi_migrator. The app Kustomization dependsOn it with wait: true. Migrations are expand/contract and forward-only.
  • Rollout: 2 replicas, maxSurge: 1, maxUnavailable: 0, no HPA, a PDB with minAvailable: 1, replicas spread across the workers. That's at most 3 app pods.
  • Rollback: git revert of the bump. Break-glass is flux suspend plus kubectl rollout undo. There's no automated rollback.
  • Renovate: a nightly workflow running as its own bot user. It auto-merges only dev tooling; anything that ships comes as a PR.
  • Outside Flux: the Owner applies OpenTofu changes (runner VM, Cilium, CCM) over the tailnet. Talos and Kubernetes upgrades are a manual talosctl runbook.
  • Failures go to ntfy from CI (if: failure()) and from Flux's notification-controller. Topics and auth are designed with notifications.
  • Deferred to cluster hardening: Flux commit-signature verification, and image signing with admission verification.
## Resolution Recorded in [ADR-0007](https://git.bobbypalko.com/bobby/hapi/src/branch/main/docs/adr/0007-flux-pull-delivery.md). - **Pull-based delivery with Flux.** Flux polls this public repo anonymously over HTTPS every 1 min, with `prune` and drift correction on, and holds no git credentials. The Owner installs it once over the tailnet. Layout: `deploy/clusters/prod`, `deploy/infrastructure` (HelmReleases), `deploy/apps/hapi` (Kustomize). There's no webhook Receiver. - **CI on Gitea Actions**, on a dedicated runner VM defined in OpenTofu under `infra/`: deny-all inbound, not on the tailnet. - **On a PR:** `just` lint, pyright, import-linter, testcontainers tests, image build, smoke test, OpenAPI artifact, and a Trivy scan that fails on fixable critical or high CVEs. - **On `main`:** the same, then push to **Gitea's container registry** (public images) and commit the **digest** bump using a write deploy key allowlisted on protected `main`. - **Every green merge to `main` deploys.** There are no release tags. - **Migrations:** a digest-named Job in its own Flux Kustomization, running as `hapi_migrator`. The app Kustomization `dependsOn` it with `wait: true`. Migrations are expand/contract and forward-only. - **Rollout:** 2 replicas, `maxSurge: 1`, `maxUnavailable: 0`, no HPA, a PDB with `minAvailable: 1`, replicas spread across the workers. That's at most 3 app pods. - **Rollback:** `git revert` of the bump. Break-glass is `flux suspend` plus `kubectl rollout undo`. There's no automated rollback. - **Renovate:** a nightly workflow running as its own bot user. It auto-merges only dev tooling; anything that ships comes as a PR. - **Outside Flux:** the Owner applies OpenTofu changes (runner VM, Cilium, CCM) over the tailnet. Talos and Kubernetes upgrades are a manual `talosctl` runbook. - **Failures go to ntfy** from CI (`if: failure()`) and from Flux's notification-controller. Topics and auth are designed with notifications. - **Deferred to cluster hardening:** Flux commit-signature verification, and image signing with admission verification.
bobby closed this issue 2026-11-24 13:36:56 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: bobby/hapi#56