This procedure moves an OpenSlice **docker compose** installation from Keycloak 16.1.1 (WildFly) to
Keycloak 26.8.2 (Quarkus). It exports all realms from the old server and imports them into a new,
empty database. The old database is never modified, so you can always roll back.
It was rehearsed end to end on a copy of a production database (165 users, 3 realms, Google/GitHub login).
Users, passwords, roles, clients and signing keys came across unchanged (see [What is kept / lost](#what-is-kept--lost)).
**Expected downtime:** about 5 minutes (export ≈ 1 min, import + first start ≈ 3 min).
All users have to log in again afterwards.
## Kit contents
The kit lives in [`org.etsi.osl.main/compose/keycloak-upgrade/`](https://labs.etsi.org/rep/osl/code/org.etsi.osl.main/-/tree/develop/compose/keycloak-upgrade).
| File | Purpose |
|---|---|
| `kc16-export.sh` | Stops the KC 16 container and exports all realms to a folder using a one-shot KC 16 container. Then applies `kc26-fixup.jq`. |
| `kc26-fixup.jq` | Caps client session timeouts that exceed the realm limits. KC 16 accepted them, KC 26 refuses to import them. |
| `create-kc26-db.sql` | Creates the new empty `keycloak26` database (utf8mb4) and grants it to the `keycloak` DB user. |
| `keycloak26-service.yaml` | The new `keycloak:` service block for `docker-compose.yaml`. |
| `kc26-import.sh` | One-shot import into the empty DB, then starts Keycloak 26 and waits until it answers. |
| `kc26-verify.sh` | Prints users / clients / roles / IdPs / signing-key id per realm. Run it before and after, then compare. |
## Prerequisites
-**MySQL 8.0 or newer** for the new database. Keycloak 26 does not support MySQL 5.7.
The default `docker-compose.yaml` already runs `mysql:8` as `amysql8`. If you still run MySQL 5.7
(`docker-compose.yaml.configure`, older installs), add a MySQL 8 service first and point `KC_DB_URL` to it.
-`bash`, `curl` and Docker with the compose plugin. On Windows use Git Bash; the scripts handle its path conversion.
The scripts pull `ghcr.io/jqlang/jq:1.7.1`, so jq does not need to be installed.
- The **master admin password** of the old Keycloak (`KEYCLOAK_PASSWORD`, default `keycloakadminpass`).
It keeps working after the upgrade.
- Run all commands from `org.etsi.osl.main/compose` (the folder with `docker-compose.yaml`), with the kit copied
| `KEYCLOAK_USER/KEYCLOAK_PASSWORD` | not needed: the admin comes from the import (see below) |
| `KEYCLOAK_IMPORT` + `./keycloak-init:/tmp` | `command: start --import-realm` + `realm-export.json` mounted in `/opt/keycloak/data/import`. It only imports a realm that does not exist yet, so after the upgrade it logs `Realm 'openslice' already exists. Import skipped`. |
| ports 8080 + 8443 | 8080 only (TLS is terminated by nginx). Health and metrics are on 9000 inside the network. |
| `JAVA_OPTS` | `JAVA_OPTS_APPEND`. KC 26 sizes the heap itself (70% of the container memory). |
> ⚠️ **Do not set `KC_BOOTSTRAP_ADMIN_USERNAME/PASSWORD`** on the upgrade path. The import brings the existing
> master admin, the bootstrap user then collides with it, and the **whole import is rolled back**.
> `kc26-import.sh` refuses to run if they are set.