Move Keycloak to its own user and PostgreSQL #670

Stängd
öppnade 2026-10-11 17:09:20 +00:00 av supernaut · 5 kommentarer
Ägare

Move Keycloak to its own rootless user bitborg-id and its own PostgreSQL, as decided in ADR 0042 (bitborg-docs#147, #148). Keycloak cut over on 2026-10-11 under the shared user and the shared Postgres. Until the move, a container escape on the shared user reaches the Keycloak database password.

  • User, pinned subordinate IDs, data bind, host-only address 10.90.0.1, networks (#661). Applied and reboot-tested on staging. Applied on prod 2026-10-11 with #677.
  • Publish the current Keycloak also on 10.90.0.1:8080 and :9000. Point Caddy, keycloak_internal_url and vmagent at it. Proves the network path on staging before any user move. Also pin the bitborg-id-data subnet.
  • Unit metrics per user, node_exporter second textfile directory, health gate per-user service list.
  • Keycloak role under bitborg-id: keycloak-postgres, secrets, keycloak_restore_from, cleanup of the old unit. One PR. Staging migration by dump and restore.
  • Backups: hourly encrypted dump under bitborg-id, handoff to the hot and daily backups, verify and drill decrypt it.
  • Prod: apply in a planned window (dump and restore, minutes of downtime), then reboot once to prove the mount guard.
  • After a week and a green drill: drop the old keycloak database and role from the shared Postgres.

Done when: prod Keycloak runs as bitborg-id on its own PostgreSQL, the drill restores it, and the shared Postgres has no keycloak database.

Move Keycloak to its own rootless user `bitborg-id` and its own PostgreSQL, as decided in ADR 0042 (bitborg-docs#147, #148). Keycloak cut over on 2026-10-11 under the shared user and the shared Postgres. Until the move, a container escape on the shared user reaches the Keycloak database password. - [x] User, pinned subordinate IDs, data bind, host-only address `10.90.0.1`, networks (#661). Applied and reboot-tested on staging. Applied on prod 2026-10-11 with #677. - [x] Publish the current Keycloak also on `10.90.0.1:8080` and `:9000`. Point Caddy, `keycloak_internal_url` and vmagent at it. Proves the network path on staging before any user move. Also pin the `bitborg-id-data` subnet. - [x] Unit metrics per user, node_exporter second textfile directory, health gate per-user service list. - [ ] Keycloak role under `bitborg-id`: `keycloak-postgres`, secrets, `keycloak_restore_from`, cleanup of the old unit. One PR. Staging migration by dump and restore. - [ ] Backups: hourly encrypted dump under `bitborg-id`, handoff to the hot and daily backups, verify and drill decrypt it. - [ ] Prod: apply in a planned window (dump and restore, minutes of downtime), then reboot once to prove the mount guard. - [ ] After a week and a green drill: drop the old `keycloak` database and role from the shared Postgres. Done when: prod Keycloak runs as `bitborg-id` on its own PostgreSQL, the drill restores it, and the shared Postgres has no `keycloak` database.
Upphovsperson
Ägare

PR 3 (#677) applied, 2026-10-11.

Staging (18:27 UTC): bitborg-id-data recreated with the pinned 10.89.11.0/24. Caddy and web reach Keycloak on 10.90.0.1, sign-up and sign-in work, the session records the real client IP. Second --check changed=0.

Prod (19:38 UTC): the apply also brought #661 (user bitborg-id, subordinate IDs 231072:65536, data bind mount, 10.90.0.1 on lo, user@2001 drop-in). Reconciled clean, second --check changed=0. up{job="keycloak",instance="10.90.0.1:9000"} is 1, all blackbox probes 1, sign-in works and the session records the real client IP. Only Watchdog fires.

Next: PR 4.

PR 3 (#677) applied, 2026-10-11. Staging (18:27 UTC): `bitborg-id-data` recreated with the pinned `10.89.11.0/24`. Caddy and web reach Keycloak on `10.90.0.1`, sign-up and sign-in work, the session records the real client IP. Second `--check` changed=0. Prod (19:38 UTC): the apply also brought #661 (user `bitborg-id`, subordinate IDs `231072:65536`, data bind mount, `10.90.0.1` on `lo`, `user@2001` drop-in). Reconciled clean, second `--check` changed=0. `up{job="keycloak",instance="10.90.0.1:9000"}` is 1, all blackbox probes 1, sign-in works and the session records the real client IP. Only `Watchdog` fires. Next: PR 4.
Upphovsperson
Ägare

Correction to the prod note above: the PR 3 apply was scoped to podman,keycloak,web,billing,caddy,monitoring-agent, so the base role was not in it and the second --check did not cover it. Prod is missing the ip daddr 10.90.0.1 drop rule from #661. Exposure is nil today: the input chain policy is drop and only 22, 80, 443 and the allowlisted 2222 are open. The next prod apply (PR 4, with base) adds the rule.

Correction to the prod note above: the PR 3 apply was scoped to `podman,keycloak,web,billing,caddy,monitoring-agent`, so the `base` role was not in it and the second `--check` did not cover it. Prod is missing the `ip daddr 10.90.0.1 drop` rule from #661. Exposure is nil today: the input chain policy is drop and only 22, 80, 443 and the allowlisted 2222 are open. The next prod apply (PR 4, with `base`) adds the rule.
Upphovsperson
Ägare

PR 3 (#677) and PR 4 (#687) are live on staging and prod. Next: PR 5, the Keycloak role under bitborg-id with its own Postgres.

PR 3 (#677) and PR 4 (#687) are live on staging and prod. Next: PR 5, the Keycloak role under `bitborg-id` with its own Postgres.
supernaut refererade till detta ärende från en incheckning 2026-10-14 19:30:25 +00:00
Upphovsperson
Ägare

Status 2026-10-14.

  • Staging: sign-in tests passed (passkey, and password with TOTP, on the portal and Forgejo). They found one bug: Keycloak trusted only the bitborg-id subnet, but rootlessport connects from its bitborg-id-data address. Fixed in #750, applied on staging. LOGIN events now show the real client IP.
  • Prod gate: a manual drill passed on archive bitborg-20261014T153837Z, which carries keycloak.dump.age. The dump decrypts and restores.
  • Prod change: #752 (keycloak_isolated: true plus the vault password). Apply on 2026-10-15 per the runbook "Move Keycloak to bitborg-id": fresh verify, dry-run, apply, counts, reboot, sign-in check. Merge after the apply.
  • Order: before the host rename (#584), so prod matches the staging rehearsal.
Status 2026-10-14. - Staging: sign-in tests passed (passkey, and password with TOTP, on the portal and Forgejo). They found one bug: Keycloak trusted only the `bitborg-id` subnet, but rootlessport connects from its `bitborg-id-data` address. Fixed in #750, applied on staging. `LOGIN` events now show the real client IP. - Prod gate: a manual drill passed on archive `bitborg-20261014T153837Z`, which carries `keycloak.dump.age`. The dump decrypts and restores. - Prod change: #752 (`keycloak_isolated: true` plus the vault password). Apply on 2026-10-15 per the runbook "Move Keycloak to bitborg-id": fresh verify, dry-run, apply, counts, reboot, sign-in check. Merge after the apply. - Order: before the host rename (#584), so prod matches the staging rehearsal.
Upphovsperson
Ägare

Applied on prod 2026-10-15 from #752. Counts matched before and after (users, groups, clients, credentials). The health gate passed, the reboot came back clean, and the LOGIN session shows the real client IP. The dump hand-off is owned by bitborg-id. The shared keycloak database stays as the rollback copy until the purge (#585).

Applied on prod 2026-10-15 from #752. Counts matched before and after (users, groups, clients, credentials). The health gate passed, the reboot came back clean, and the LOGIN session shows the real client IP. The dump hand-off is owned by bitborg-id. The shared keycloak database stays as the rollback copy until the purge (#585).
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#670
Ingen beskrivning angiven.