Ephemeral environments
Brouillon : cette page n'a pas encore été relue et peut être incomplète ou inexacte.
Two flavours of throwaway environment live in this repo. Pick by what you’re testing.
| App preview | Full-platform ephemeral | |
|---|---|---|
| Workflow | preview-deploy.yml / preview-teardown.yml |
ephemeral-deploy.yml / ephemeral-teardown.yml |
| Triggered by | a PR on an app repo (label preview) |
a PR on this superrepo (label ephemeral) |
| Deploys | ONE app pair (the PR’s frontend + that app’s dev backend) | the WHOLE stack: portal /, GED /ged, AFCM /afcm |
| Chart used | superrepo chart from main |
the chart on the PR |
| Images | the app repo builds its own | this workflow builds all four from the PR’s submodule commits |
| Host | pr-<N>-<slug>.dev.dowonou.com |
eph-<N>.dev.dowonou.com |
| Use it for | iterating on one app | cross-app behaviour: the portal chooser, shared-realm SSO, ingress/routing changes, chart changes |
Both reuse dev’s Keycloak/MinIO and are removed automatically.
Full-platform ephemeral — how to use
Section intitulée « Full-platform ephemeral — how to use »- Open a PR on this superrepo whose submodule gitlinks point at the branches/commits you want to preview together (bump the submodule you’re testing; leave the others at dev).
- Add the
ephemerallabel. Optionally addclone-ged-datato seed the isolated GED DB from dev’s documents (otherwise GED starts empty). - The workflow comments the URL (
https://eph-<N>.dev.dowonou.com/) when ready (~10 min: it builds four images). - New commits to the PR redeploy. Remove the
ephemerallabel or close the PR to tear it down.
Manual trigger: Actions → Ephemeral environment deploy → Run workflow with the PR number.
Design & isolation model
Section intitulée « Design & isolation model »- Full stack, PR’s chart. The deploy runs from the superrepo checkout, so chart changes on the PR (ingress, portal, subcharts) are exercised.
values-ephemeral.yamlturns the whole platform on;values-dev.yamlunderneath supplies the (test) secrets and service config. - Images built from submodule commits. Frontends are baked with the ephemeral host (
VITE_*→https://eph-<N>.dev.dowonou.com/...) but Keycloak stays on dev (VITE_KEYCLOAK_URL=https://dev.dowonou.com/auth) — the realm session is dev’s. Build args mirror each app’sbuild-env.yml; if an app changes its args, update this workflow too. - GED database is isolated. The GED backend runs
migrateon startup, so it must never touch shared dev. The env gets its own in-namespace Postgres (ephemeral, no PVC);clone-ged-datarestores a read-onlypg_dumpof dev’sagbale_ged_dbinto it and lets the backend migrate on top — a faithful rehearsal of a real dev GED-backend upgrade. - AFCM database is isolated too. AFCM gets its own
afcm_dbon the same in-namespace Postgres (its initdb createsagbale_ged_dbandafcm_db). The AFCM migration Job runsmigrateanddb:seedagainst that fresh database, so SSO-provisioned users and any AFCM writes never reach dev’safcm_db. The seed is required, not cosmetic: AFCM resolves a user’s company from the Keycloak realm (resolveCompanyForRealm) and fails closed when no company maps to that realm, so an unseededafcm_dbmeans SSO can provision nobody. It is gated behind an explicitafcm-backend.migrations.seedflag precisely so it can never be switched on against a shared database. - Keycloak redirect URIs. The deploy registers
https://eph-<N>.dev.dowonou.com/*on bothafcm-clientandagbale-ged— one wildcard covers each app’s OAuth callback and its/…/silent-check-sso.htmlpage. Teardown removes them. Serialized via theephemeral-kcconcurrency group. - AFCM chat. Reverb runs inside the env (
<release>-afcm-reverb,wss://eph-<N>.dev.dowonou.com/afcm/ws) with the app credentials invalues-ephemeral.yaml; the workflow bakes that file’s public key into afcm-frontend. Attachments go to dev’s MinIO, bucketafcm-files, prefixephemeral-chat/(not cleaned on teardown). Seemessaging.md. - TLS/DNS are automatic.
*.dev.dowonou.comresolves to the ingress LB, and cert-manager (letsencrypt-prod) issues a per-host cert. No manual steps.
Gotchas (learned the hard way)
Section intitulée « Gotchas (learned the hard way) »- Always pass
--set global.domain=<host>. The chart names the TLS cert<domain>-tls; omitting the override makes the release try to adopt dev’sdev.dowonou.comcert and the upgrade fails with an ownership error. (For the same reason, neverhelm upgrade --reuse-valueswith a-f values-dev.yamlthat resetsglobal.domain.) - Frontend↔backend must be compatible. Deploying a new frontend against an older backend surfaces as subtle bugs, not errors — e.g. a frontend calling
/api/me/against a backend that predates that endpoint (404 → blank user), or an RBAC-menu frontend against a backend without the KC→RBAC sync (empty menu). Point both submodules at compatible commits. pg_dumpversion must be ≥ the server. Dev’s Postgres is v18 → the clone Job usespostgres:18-alpine. A v15 client aborts with a “server version mismatch”.- Never migrate or seed a shared DB from an ephemeral env. Both GED and AFCM run against the in-namespace Postgres for exactly this reason.
afcm-backend.migrations.seedmust stayfalseanywhere the database is shared. - Subcharts are vendored as
.tgzand committed.helm/agbale-platform/charts/*.tgzis what actually renders — no workflow runshelm dependency update. Editinghelm/charts/<app>/alone changes nothing at deploy time; you must re-runhelm package helm/charts/<app> -d helm/agbale-platform/charts/and commit the rebuilt tarball. - Same host ⇒ first-party cookies. Silent SSO works because KC (
/auth) and the apps sharedev.dowonou.com; the hidden-iframe KC session cookie isn’t third-party-blocked.
Known limitations / future work
Section intitulée « Known limitations / future work »- Keycloak is still dev’s, so realm-level changes (mappers, groups, clients) are not exercised by an ephemeral env —
--import-realmonly seeds a realm that does not yet exist. Apply them to the live realm withdeploy/scripts/apply-realm-mappers.sh. - Images build sequentially (~10 min). A build matrix would parallelize.
- The Keycloak redirect RMW is serialized among ephemeral runs, but a concurrent app-preview on the same client is a rare unguarded race; re-run the affected deploy if a redirect goes missing.