Updating and deploying Keycloak

A Keycloak image change on main publishes to GHCR and creates a numbered GitHub draft release. Kargo promotes the Accounts and Keycloak image pair to tb-dev and tb-stage. Publishing the draft requests promotion to tb-prod.

Warning

Never put credential values, tokens, personal data, realm exports, or environment files in documentation, commits, PRs, screenshots, or shared logs.

1. Upgrade and test

  1. Read the release notes and migration guide for every version crossed. Check database, OIDC, authentication-flow, theme, startup-option, and server-SPI changes.

  2. Update both image stages in Dockerfile.keycloak:

    FROM quay.io/keycloak/keycloak:<new-version> AS mfa-release
    ...
    FROM quay.io/keycloak/keycloak:<new-version> AS mfa-local
    

    Keep them equal and never use latest. Do not update the informational keycloakVersion field in realm exports.

  3. If an API used by keycloak-mfa-rest changed, release a compatible provider and update its version and checksum. Update config-cli only when required by its compatibility notes or tests.

  4. Validate:

    docker manifest inspect quay.io/keycloak/keycloak:<new-version>
    docker compose build keycloak
    docker compose up -d keycloak kcpostgres
    curl --fail http://localhost:9000/health/ready
    
  5. Run the end-to-end suite from test/e2e/README.md. Ensure the theme, OIDC, introspection, MFA/recovery, and mail-authentication tests did not skip.

  6. Open and merge the upgrade PR with upstream links and test results.

2. Verify staging

Confirm that publish-images succeeded for the intended commit. In the Kargo Accounts project, find the Freight with the expected Accounts and Keycloak image digests. Confirm it is verified and current in tb-stage before running e2e-tests-browserstack-stage.yml manually from GitHub Actions. Confirm the suite passed and use Kargo promotion history to confirm that Freight stayed current throughout the run. Separately check login, MFA, introspection, mail authentication, and Keycloak configuration reconciliation.

3. Promote and verify production

Publish the GitHub draft for that commit. Confirm that the promote-release-to-tb-prod workflow succeeds and Kargo shows the expected Freight as current in tb-prod.

Check Keycloak discovery and Accounts health. Check the Keycloak rollout and configuration reconciliation logs in Argo CD. Use the dedicated test account to sign in, complete MFA, confirm the custom theme and configured MFA methods, then send and read a test message.

Rollback

Ask the Kargo operator to select the previous verified Freight. Check Keycloak’s migration guidance before reverting an image across a database migration. Use the approved database-restore procedure if the migration requires it.