Cutover from Kanidm to Keycloak #575

Stängd
öppnade 2026-10-08 14:52:42 +00:00 av supernaut · 8 kommentarer
Ägare

Switch prod from Kanidm to Keycloak in one window. Use the infra-apply skill for every apply.

  • Freeze sign-up (SIGNUPS_OPEN=false). Stop the reconciler timer and path unit.
  • Take a final Kanidm backup and run the identity inventory. Keep both.
  • Apply the Postgres change, the keycloak role and the prod realm.
  • Import users. Compare counts. Stop on any mismatch.
  • Switch the Forgejo source and Grafana. Pin the new reconciler and payment tags. Unpin web.
  • Run the reconciler once in dry-run: no renames, no email changes, no quota moves. Then re-enable the timer.
  • Send the re-enrolment emails. Operator accounts enrol and are checked.
  • Run sign-in chain probes, health gates and one restore drill.
  • Reopen sign-up.
  • Stop the Kanidm unit. Keep its volume and image for the rollback window.

Done when: all sign-in paths work on prod, counts match, and Kanidm is stopped but restorable.

Depends on: #572
Depends on: #573
Depends on: #574
Depends on: bitborg/bitborg-auth-reconciler#78
Depends on: bitborg/bitborg-web#311
Depends on: bitborg/bitborg-payment#111
Depends on: a private task
Epic: bitborg/bitborg-docs#127

Switch prod from Kanidm to Keycloak in one window. Use the `infra-apply` skill for every apply. - [ ] Freeze sign-up (`SIGNUPS_OPEN=false`). Stop the reconciler timer and path unit. - [ ] Take a final Kanidm backup and run the identity inventory. Keep both. - [ ] Apply the Postgres change, the `keycloak` role and the prod realm. - [ ] Import users. Compare counts. Stop on any mismatch. - [ ] Switch the Forgejo source and Grafana. Pin the new reconciler and payment tags. Unpin web. - [ ] Run the reconciler once in dry-run: no renames, no email changes, no quota moves. Then re-enable the timer. - [ ] Send the re-enrolment emails. Operator accounts enrol and are checked. - [ ] Run sign-in chain probes, health gates and one restore drill. - [ ] Reopen sign-up. - [ ] Stop the Kanidm unit. Keep its volume and image for the rollback window. Done when: all sign-in paths work on prod, counts match, and Kanidm is stopped but restorable. Depends on: #572 Depends on: #573 Depends on: #574 Depends on: bitborg/bitborg-auth-reconciler#78 Depends on: bitborg/bitborg-web#311 Depends on: bitborg/bitborg-payment#111 Depends on: a private task Epic: bitborg/bitborg-docs#127
Upphovsperson
Ägare

Staging cutover rehearsed 2026-10-09 with the new kanidm_enabled switch (#574 branch). Items the prod flip must also cover, not exercised on staging:

  • Backup and drill: the Kanidm dump is skipped once the container is gone, and the weekly drill still boots Kanidm and asserts its restore (bitborg-backup-drill.py.j2). Gate the Kanidm part on kanidm_enabled and decide whether the kept volume is still backed up.
  • Grafana OIDC still uses Kanidm-style URLs under kanidm_domain (roles/monitoring/defaults/main.yml). Move it to /realms/bitborg/protocol/openid-connect/ in the same window. Keep a break-glass local login until then.
  • Prod web_oidc_issuer default and scripts/signup-drill.sh still use the Kanidm issuer shape.
  • Apply order: kanidm,keycloak,caddy,forgejo,reconciler. Forgejo must start after Caddy serves Keycloak on the auth name.
  • Reconciler: pin v2 in the same apply as the switch.
Staging cutover rehearsed 2026-10-09 with the new `kanidm_enabled` switch (#574 branch). Items the prod flip must also cover, not exercised on staging: - [ ] Backup and drill: the Kanidm dump is skipped once the container is gone, and the weekly drill still boots Kanidm and asserts its restore (`bitborg-backup-drill.py.j2`). Gate the Kanidm part on `kanidm_enabled` and decide whether the kept volume is still backed up. - [ ] Grafana OIDC still uses Kanidm-style URLs under `kanidm_domain` (`roles/monitoring/defaults/main.yml`). Move it to `/realms/bitborg/protocol/openid-connect/` in the same window. Keep a break-glass local login until then. - [ ] Prod `web_oidc_issuer` default and `scripts/signup-drill.sh` still use the Kanidm issuer shape. - [ ] Apply order: `kanidm,keycloak,caddy,forgejo,reconciler`. Forgejo must start after Caddy serves Keycloak on the auth name. - [ ] Reconciler: pin v2 in the same apply as the switch.
Upphovsperson
Ägare

Updated by the id.* rename (branch feat/identity-id-domain): Keycloak serves id.bitborg.se beside Kanidm, so cutover needs no domain swap. kanidm_enabled: false now also switches the Forgejo source name, web OIDC issuer and secret, Grafana OIDC URLs, admin group and secret, and drops the Kanidm /status probe. See the runbook "Cutover switch".

Still by hand at cutover:

  • Prod realm applied, with the Bitborg-id callback on the forgejo client, before the switch.
  • Reconciler v2 tag and web_keycloak_required: true.
  • Check that the Grafana podman secret actually rotates to the Keycloak client secret (podman_secret with changed data).
  • Drop the stale comment in grafana.container.j2.
Updated by the `id.*` rename (branch `feat/identity-id-domain`): Keycloak serves `id.bitborg.se` beside Kanidm, so cutover needs no domain swap. `kanidm_enabled: false` now also switches the Forgejo source name, web OIDC issuer and secret, Grafana OIDC URLs, admin group and secret, and drops the Kanidm `/status` probe. See the runbook "Cutover switch". Still by hand at cutover: - [ ] Prod realm applied, with the `Bitborg-id` callback on the `forgejo` client, before the switch. - [ ] Reconciler v2 tag and `web_keycloak_required: true`. - [ ] Check that the Grafana podman secret actually rotates to the Keycloak client secret (`podman_secret` with changed data). - [ ] Drop the stale comment in `grafana.container.j2`.
Upphovsperson
Ägare

Post-cutover check, carried over from the staging rehearsal:

  • Renovate on a user repo. Opt a test account in to Renovate in the portal, create a repo with an old pinned dependency, and confirm the reconciler adds bitborg-renovate as a Write collaborator. The first nightly run (00:30) must open the "Configure Renovate" onboarding PR.

On staging the opt-in and the collaborator grant passed. The Renovate role runs on prod only, so the run itself is verified here.

Post-cutover check, carried over from the staging rehearsal: - [ ] Renovate on a user repo. Opt a test account in to Renovate in the portal, create a repo with an old pinned dependency, and confirm the reconciler adds `bitborg-renovate` as a Write collaborator. The first nightly run (00:30) must open the "Configure Renovate" onboarding PR. On staging the opt-in and the collaborator grant passed. The Renovate role runs on prod only, so the run itself is verified here.
Upphovsperson
Ägare

Per-user checks for the cutover window, decided 2026-10-11. They replace a separate rehearsal against a restored Forgejo.

After import and before the reconciler timer is re-enabled, for every imported person:

  • Keycloak user id equals the Forgejo login_name of the linked external account.
  • Forgejo uid unchanged (compare user.id before and after).
  • Repos and org memberships unchanged (count per user before and after).
  • Quota group unchanged after one reconciler run in dry-run mode.

Any mismatch stops the cutover before step 7, where rollback is still cheap.

Take the "before" snapshot from the prod Forgejo database at the start of the window, read-only.

Per-user checks for the cutover window, decided 2026-10-11. They replace a separate rehearsal against a restored Forgejo. After `import` and before the reconciler timer is re-enabled, for every imported person: - [ ] Keycloak user id equals the Forgejo `login_name` of the linked external account. - [ ] Forgejo uid unchanged (compare `user.id` before and after). - [ ] Repos and org memberships unchanged (count per user before and after). - [ ] Quota group unchanged after one reconciler run in dry-run mode. Any mismatch stops the cutover before step 7, where rollback is still cheap. Take the "before" snapshot from the prod Forgejo database at the start of the window, read-only.
supernaut refererade till detta ärende från en incheckning 2026-10-11 11:34:13 +00:00
Upphovsperson
Ägare

Cutover done on prod, 2026-10-11. Keycloak (id.bitborg.se, realm bitborg) is the identity provider. Kanidm is stopped; its volume and config are kept for the rollback window.

Stage A, beside Kanidm:

  • Sign-up frozen, reconciler stopped, alerts silenced.
  • Final Kanidm dump kanidm-final-20261011.json.age, stored locally and at both off-site buckets.
  • Keycloak first start, realm applied (161 resources), bootstrap client deleted.
  • 6 accounts imported with their ids kept. verify OK. Per-user id and username match for every linked Forgejo account.

Stage B, the switch (#659):

  • auth.bitborg.se redirects to id.bitborg.se.
  • The Forgejo OAuth2 source is updated in place: id 2, now Bitborg-id.
  • The portal runs latest with the Keycloak issuer. Grafana signs in through Keycloak.
  • Reconciler v2.0.0: a dry run, then apply mode.
  • The before and after snapshots of Forgejo (uid, source, login_name, repos, orgs, quota) are identical, also after two apply-mode reconciler runs.
  • tofu plan shows no changes.
  • Migration mail sent to 4 people. One operator account enrolled and checked on Forgejo (same uid, linked), the portal and Grafana.

Stage C:

  • Sign-up drill passed against Keycloak, then sign-up reopened (#660).
  • Backup includes keycloak.dump, without Kanidm. The restore drill passed (#572 closed).
  • All probes are 1.

Follow-ups: web#352 (sign-out from a session started before the cutover). CoreUnitDown{name="kanidm"} cleared by applying monitoring-agent after the switch.

Left open for the rollback window. Rollback re-pins web to pin-c01b015 (runbook "Cutover switch"). The Renovate check after the next nightly run is still to do.

Cutover done on prod, 2026-10-11. Keycloak (`id.bitborg.se`, realm `bitborg`) is the identity provider. Kanidm is stopped; its volume and config are kept for the rollback window. Stage A, beside Kanidm: - Sign-up frozen, reconciler stopped, alerts silenced. - Final Kanidm dump `kanidm-final-20261011.json.age`, stored locally and at both off-site buckets. - Keycloak first start, realm applied (161 resources), bootstrap client deleted. - 6 accounts imported with their ids kept. `verify` OK. Per-user id and username match for every linked Forgejo account. Stage B, the switch (#659): - `auth.bitborg.se` redirects to `id.bitborg.se`. - The Forgejo OAuth2 source is updated in place: id 2, now `Bitborg-id`. - The portal runs `latest` with the Keycloak issuer. Grafana signs in through Keycloak. - Reconciler `v2.0.0`: a dry run, then apply mode. - The before and after snapshots of Forgejo (uid, source, `login_name`, repos, orgs, quota) are identical, also after two apply-mode reconciler runs. - `tofu plan` shows no changes. - Migration mail sent to 4 people. One operator account enrolled and checked on Forgejo (same uid, linked), the portal and Grafana. Stage C: - Sign-up drill passed against Keycloak, then sign-up reopened (#660). - Backup includes `keycloak.dump`, without Kanidm. The restore drill passed (#572 closed). - All probes are 1. Follow-ups: web#352 (sign-out from a session started before the cutover). `CoreUnitDown{name="kanidm"}` cleared by applying monitoring-agent after the switch. Left open for the rollback window. Rollback re-pins web to `pin-c01b015` (runbook "Cutover switch"). The Renovate check after the next nightly run is still to do.
Upphovsperson
Ägare

Post-cutover follow-ups, 2026-10-11: Keycloak heap flag fixed (#666) after KeycloakMemoryHigh fired; memory caps (#662); reconcile right after a first Forgejo sign-in (#665, quota in 3 s on staging); billing may manage the trial groups (#667, applied on staging and prod with a two-step replace, runbook #669); test-passkey-check removed for good (#663). The move to its own user and PostgreSQL is #670. Still open here: the Renovate check after tonight's 00:30 run, then the rollback window.

Post-cutover follow-ups, 2026-10-11: Keycloak heap flag fixed (#666) after `KeycloakMemoryHigh` fired; memory caps (#662); reconcile right after a first Forgejo sign-in (#665, quota in 3 s on staging); billing may manage the trial groups (#667, applied on staging and prod with a two-step replace, runbook #669); `test-passkey-check` removed for good (#663). The move to its own user and PostgreSQL is #670. Still open here: the Renovate check after tonight's 00:30 run, then the rollback window.
Upphovsperson
Ägare

Final Kanidm dump, 2026-10-15: the host copy and the Glesys copy are deleted. The Hetzner copy is under the bucket's object lock until 2026-10-25, so it gets deleted on 2026-10-26. This issue closes after that.

Final Kanidm dump, 2026-10-15: the host copy and the Glesys copy are deleted. The Hetzner copy is under the bucket's object lock until 2026-10-25, so it gets deleted on 2026-10-26. This issue closes after that.
Upphovsperson
Ägare

Final Kanidm dump, 2026-10-27: the Hetzner copy is deleted after its object lock ended. No copy remains on the host, Glesys or Hetzner. The rollback state was purged the same day (#585), so the rollback window is over. Closing.

Final Kanidm dump, 2026-10-27: the Hetzner copy is deleted after its object lock ended. No copy remains on the host, Glesys or Hetzner. The rollback state was purged the same day (#585), so the rollback window is over. Closing.
Logga in för att delta i denna konversation.
Ingen milstolpe
Inga tilldelade
1 deltagare
Notiser
Förfallodatum
Förfallodatumet är ogiltigt eller utanför gränserna. Använd formatet "åååå-mm-dd".

Inget förfallodatum satt.

Beroenden

Inga beroenden satta

Referens
bitborg/bitborg-infra#575
Ingen beskrivning angiven.