Keycloak zero-downtime patch upgrades

Patch releases within a Keycloak line can be applied without an outage when the cluster is checked, restarted node by node and kept on sticky sessions. This page explains how to plan that work and where it goes wrong.

On this page

How to apply a Keycloak patch release without an outage

If your Keycloak deployment signs users into production applications, a patch release such as 26.8.1 should not require a maintenance window. The same-minor-line rolling restart is the supported path: move from one 26.x patch to a later 26.x patch, one node at a time, while the rest of the cluster keeps serving sign-in. Patch releases differ from minor and major upgrades because the project's compatibility policy limits them to fixes, so they do not carry the schema changes, opt-in breaking changes or Quarkus and cache rework that make a minor or major jump a planned project. Before you start, confirm in the Keycloak upgrading guide that the target patch sits in your current minor line and read its release notes for any entry that asks for action, since a security fix can still change a default.

Work through three checks before the first node restarts. First, confirm the current and target versions match exactly on the image tag or Operator channel you deploy, and that no node is running an older build from a previous rollout. Second, confirm that your database backup is restorable and that you can roll back to the prior image tag, because a rolling restart does not undo a schema change made at startup. Third, confirm that sticky sessions or the load balancer's session affinity are working, so a user who lands on a node being restarted is routed back to the node that holds their session. Test these steps against a non-production realm and an equivalent cluster first, using the same proxy and database configuration as production.

During the rollout, drain one node from the load balancer, wait for active requests to finish, restart it on the new patch, confirm its health endpoint and metrics respond, then return it to the pool before moving to the next node. The Keycloak Operator follows the same logic through its update settings: keep manual approval mode so that a new operator release does not upgrade your Keycloak instances without review, and test each approval on a staging realm first. Watch login success rates, token errors and cache-related log messages during each step. If a node fails its health check, stop the rollout and fall back to the prior image rather than pushing the remaining nodes forward.

What changes in a Keycloak 26 release and what each change asks of the team

This table compares the kinds of change that arrive in Keycloak 26 releases and the work each one asks of your team. Patch releases normally carry fixes, while minor releases can carry changes that need planning, so read the notes for each version before you apply it.

ChangeImpactAction needed
Quarterly minor releases since 26.0The project plans four minor releases a year, so a 26 deployment will keep moving forward on a regular schedule.Schedule a recurring review of each minor release and decide how quickly your environments will follow.
Opt-in breaking changes in minor releasesSince 26.0, breaking changes in a minor release are opt-in, so they should not switch on during a normal restart.Read the migration notes for each release and confirm which options you have enabled before and after the upgrade.
Enforced SMTP StartTLS in 26.8Mail delivery will no longer fall back to plaintext, so a mail relay that lacks StartTLS will fail password reset and notification emails.Confirm that your SMTP relay supports StartTLS and test email flows in a staging realm before the rolling update.
Mandatory signature validation of backchannel logout tokens in 26.8Logout tokens from external identity providers must have valid signatures, so misconfigured providers can cause logout failures.Inventory external providers that send backchannel logout, verify their signing keys, and test logout for each connected application.
Login failures persisted to the database by default in 26.8Failed login records are written to the database, which adds write load and database growth that did not exist before.Review database sizing and retention for login failure data, and check that your database backups cover the growth.
Move from multi-site to the stateless feature in 26.8The deprecated multi-site feature is no longer the recommended path, so multi-site clusters will need a design change, not only a version bump.Identify any multi-site deployments and plan the move to the stateless approach as a separate change with its own test window.

What to back up and inventory before a Keycloak patch

A patch is only safe to roll back if you can prove the database, the configuration and the deployment definition can be restored or reproduced. These six items give the team a baseline to return to and a rehearsal environment that behaves like production.

Database backup and restore test

Take a backup of the Keycloak database immediately before the patch and confirm it restores into a scratch instance. Keycloak migrates its schema automatically at startup by default, so a schema change can start the moment a new pod boots. The supported production databases include PostgreSQL 14 to 18, MariaDB, MySQL, Oracle, Microsoft SQL Server and Azure SQL. Record the restore time you measured, because that number sets your realistic rollback window. Confirm the database owner, not the Keycloak team, holds the restore credentials.

Keycloak database docs

Inventory of custom providers, themes and SPIs

List every custom login theme, account theme, email template, SPI provider and user storage extension, with the Keycloak version each was built against. Note which ones load at startup and which were compiled into a JAR you deploy alongside the server. A patch that changes internal APIs can break a provider that worked on the prior patch, and that failure often shows up only on the first login. Owner: the identity engineering team that wrote the code, with the application team signing off on theme changes.

Current configuration and realm exports

Export each realm, including clients, roles, groups, authentication flows, identity providers and client scopes, and store the files under version control. Capture the server startup options, such as hostname, proxy headers, cache settings and the metrics flag, as they are set in your environment. Realm exports do not contain every secret or every runtime setting, so keep a separate record of secrets managed in your vault. Owner: the platform team, with the realm administrators reviewing the diff after the patch.

Operator or deployment manifests and their versions

Record the exact image tag or Operator version, the Keycloak custom resource manifest, the Helm values or the container arguments, and the Kubernetes or VM environment they run on. If you install the Keycloak Operator through Operator Lifecycle Manager, note the subscription channel and whether approval is set to manual, since the Operator documentation recommends manual approval for operator updates. Keep the rendered manifests in Git so a rollback targets a known state. Owner: the platform or DevOps team that deploys Keycloak.

Operator installation docs

Staging environment that matches production

Build a staging deployment with the same topology as production: the same number of nodes, the same database engine and version, the same reverse proxy and hostname settings, and the same cache and clustering mode. Load a recent realm export and a sanitized copy of user data, then run the patch there first and test logins, token refresh, logout and admin access. A staging system with one node cannot show the mixed-version behavior that a rolling restart creates. Owner: the platform team, with the QA or security team defining the test scripts.

Session, cache and health baseline

Before the patch, record active session counts, login success and failure rates, and the health and metrics endpoints under normal load. Keycloak exposes Prometheus-format metrics at /metrics on its management interface when started with metrics enabled, so these values can be captured from existing monitoring. Note the cluster member list and the cache state, which you will compare after each node restarts. Without this baseline, teams cannot tell whether a failed login spike was caused by the patch or was already happening. Owner: the operations or SRE team that runs the monitoring stack.

Metrics configuration docs

How a rolling patch moves through the Keycloak cluster

The roll starts at the load balancer, which keeps sticky sessions pinned to nodes while one node at a time is drained, patched and restarted. Before any node restarts, the update-compatibility check runs against the shared database, and any schema step is applied there first. After each restarted node, a health check decides whether the roll continues to the next node or stops and rolls back. Confirm the health checks cover login and token issuance, not only process liveness.

Patch roll order across the load balancer, nodes, shared database and health gate.

Running the rolling patch in order

This sequence moves a running Keycloak cluster to a new patch release one node at a time, so users keep signing in while each change is checked and every node has a defined point to roll back to.

  1. Confirm the target patch and read its notes

    The platform owner identifies the exact patch release to apply, confirms it is a patch within the current minor line, and reads the release notes and the upgrade notes for every version between the running build and the target. Look for changes to defaults, mandatory validation steps, and anything that touches sessions, tokens, email or clustering. The step is done when the team has a written list of changes that affect their own realms, clients and providers. Exact commands and flags must be confirmed in the Keycloak upgrading guide for the chosen version.

  2. Run the update-compatibility check against the running configuration

    The platform engineer runs the update-compatibility check that the Keycloak upgrading guide describes for the target version, pointed at the configuration and database the production nodes actually use. The check reports whether the current build options, custom providers, themes and database state are compatible with the new release. The team records each finding, fixes or accepts it, and reruns the check until nothing blocks the upgrade. The step is done when the check output is saved with the change ticket.

  3. Verify a restorable database backup

    The database administrator takes a fresh backup of the Keycloak database and confirms it can be restored, not only that the backup job succeeded. A restore test on a separate instance shows whether the backup is usable. The team notes the backup identifier and time so it can be matched to the rollback plan. The step is done when a restore has been demonstrated and the backup is linked to the change record.

  4. Stage and test the patch in a non-production environment

    The team deploys the target patch to a staging environment built from the same configuration, container image or Operator version, and a copy of production realms and clients. They run login, logout, token refresh, admin console and client integration tests, including any custom themes or providers. Test results are compared against the current production behavior. The step is done when every critical flow passes on staging and any failures are fixed in configuration or code before production work begins.

  5. Confirm the sticky session and load balancer behavior

    The network or platform engineer confirms that the load balancer or ingress keeps each browser session pinned to a node, so that removing one node does not break logins that are in progress. They also confirm that the remaining nodes can accept the traffic that would otherwise go to the node being restarted. The step is done when a drain of a single node in staging shows users routed to the other nodes without forced logouts.

  6. Define the rollback point before each node restart

    Before touching any node, the change owner writes the rollback point: the previous image or package, the backup identifier, the configuration version, and the condition that triggers a rollback, such as failed health checks or a rise in failed logins. Because Keycloak applies database changes at startup by default, the team also confirms whether the patch changes the schema and what a rollback would require. The step is done when the rollback steps have been reviewed by a second engineer and are attached to the change.

  7. Restart one node at a time with health checks and metric watch

    The platform engineer drains one node, applies the patch, and starts it. Before the next node is touched, the engineer checks the node's health endpoint, confirms it has joined the cluster, and watches login success rate, token issuance and error metrics for the period the team agreed in advance. Only after these checks pass does the process move to the next node. The step is done when every node runs the target patch, all health checks pass, and the login and token metrics match the pre-upgrade baseline.

How sticky sessions keep users signed in during restarts

A load balancer with sticky sessions sends each user's requests to the same Keycloak node for as long as that node is available, so a rolling restart only disturbs users whose node is being replaced. Stickiness is usually implemented with a cookie that the load balancer sets and reads. Keycloak's own session and authentication state lives in its distributed caches, and the node a user lands on determines whether that state is local or must be fetched from peers. If the node is restarted without any session handling, the sessions it held in memory are gone, and users on that node are sent back to the login page. Confirm in the Keycloak documentation for your exact version how sessions are kept in its clustered caches and whether persistent user sessions are enabled, because that setting changes what a restart can lose. Also confirm the cookie name and affinity behavior your load balancer or Ingress controller uses, since a mismatch between the two is a common cause of users being moved between nodes mid-login.

The high availability architecture you chose decides how much stickiness you need to rely on. In a single cluster, nodes share session state through the cluster's replicated caches and the database, so a restart should move a user to another node with less disruption, though you still need to test it. In a multi-site design, the state crosses sites, and the upstream guidance on high availability makes the database replication requirement the central constraint. Sticky routing reduces the number of cross-node reads during normal operation, but it also concentrates load on one node and makes that node's loss more visible. Replication avoids the reliance on routing but adds cache traffic and tuning work. Choose the mix deliberately, write it into the change plan, and rehearse one node restart in a non-production environment before you roll production.

During the roll, watch the metrics endpoint rather than relying on the login page alone. Keycloak exposes Prometheus-format metrics at /metrics on its management interface when it is started with --metrics-enabled=true, and optional HTTP request and cache histograms can show whether login latency and cache behavior change as each node is replaced. Plan an alert or a dashboard panel for failed logins and unexpected re-authentication before the first node is drained, and agree a stop condition with the application owners. A rise in cache activity on the remaining nodes during a restart is expected, but a sustained increase in errors or sign-in retries is the signal to pause the roll and check the routing and session settings before continuing.

Choosing a rolling update method by deployment type

When your team runs Keycloak on virtual machines or containers with its own scripts, configuration management or a general-purpose orchestrator, the rolling update is a sequence you design and verify. Keycloak nodes share one database and, for sessions, a distributed cache, so you can take one node out of the load balancer, patch it, start it, confirm it is healthy, and then move to the next node. The sticky session setup at the load balancer decides whether users keep their login state during each step.

  • Pre-check first: Run the update-compatibility check against the target patch release before touching any node, and keep the output with your change record.
  • One node at a time: Drain each node from the load balancer, wait for active requests to finish, then restart it on the new image or package.
  • Health gate: Do not return a node to rotation until its health endpoint reports ready and a test login succeeds through it.
  • Schema changes: Confirm in the release notes whether the patch changes the database schema, and decide whether automatic migration at startup is acceptable for your database size.
  • Rollback path: Keep the previous image or package and a database backup so a failed node can be reverted without a second outage.

Before relying on this method, confirm with your team which health and readiness endpoints your Keycloak configuration exposes and how your load balancer drains connections.

What makes a patch upgrade take longer

This table lists the factors that stretch a Keycloak patch upgrade beyond a simple rolling restart, along with what each one does to the work. Read it before you estimate the window, and use the right-hand column as a checklist of what to fix or measure in your own environment.

DriverWhy it mattersHow to reduce it
Custom providers and themesCustom SPI providers and theme overrides must be rebuilt and retested against the new patch, and a mismatch can stop a node from starting.Pin provider versions, automate the build, and run login and provider tests against the target patch in a non-production environment first.
Node count and restart time per nodeEach node restarts in turn, so total window grows with node count and with how long each node takes to pass its health check.Measure real startup and readiness time in staging, set the rolling strategy to replace one node at a time, and confirm health endpoints are used before traffic returns.
Database size and startup schema migrationIf schema migration runs at startup, the first node may hold the upgrade while it migrates, and large tables can extend that step.Check whether the patch changes the schema, review the upgrade notes, consider manual migration for large databases, and take a restorable backup first.
Realms and clients to smoke testMore realms, identity providers and clients mean more login, token, logout and admin flows to verify before and after each node moves.Maintain a prioritized smoke test list per realm, automate sign-in and token checks, and cover the flows business owners rely on most.
Sticky session and cache behaviorSessions tied to a node, or cache state that does not survive a restart, can force users to sign in again or cause errors during the roll.Confirm session persistence and sticky routing settings for your release, and test a restart of one node while a live login is in progress.
Environments patched in sequenceDev, test, staging and production usually move in order, so a delay in one environment pushes back the production date.Keep environments on the same release line, script the patch steps, and record the outcome of each environment before moving to the next.
Monitoring and alerting during the rollWithout watching error rates, login latency, health checks and cache or database metrics, a failing node can go unnoticed until users report it.Enable Prometheus metrics, set alerts on login failures and health status before starting, and assign someone to watch dashboards for the full window.

How to test a patch and roll it back safely

Test every sign-in path the organization actually uses before a patch reaches production. Build the test plan from your client inventory rather than from the Keycloak documentation: one sign-in per protocol (OpenID Connect and SAML 2.0 where both are in use), per client type (web app, single-page app, mobile, service account), and per realm. For each, confirm the token claims the application reads, token refresh, and logout, including front-channel and back-channel logout to applications that depend on them. Add brokered logins through each upstream identity provider, LDAP or Active Directory federation syncs, and a password reset and email verification flow, since outbound mail is a common silent failure. Finally, sign in to the admin console with a non-emergency administrator account and confirm that the Administration REST API still responds from its restricted hostname. Run the same script against a staging cluster on the target patch and keep the results as change evidence.

Decide the rollback path before the rollout starts. Reverting a single node is the right response when the new pod fails its health checks or a defect affects request handling but the database schema has not changed. Restoring the database from backup is a different decision, and it is much harder. Keycloak migrates its schema automatically at startup by default, so once a newer node has written migrated tables, an older binary may not start against that schema, and rolling back the image alone will not restore the earlier state. Patch releases normally carry no schema change, but confirm that with the release notes for your exact version before relying on it. Also confirm with Keycloak, your distribution vendor, or your own test results whether a patch can run with a schema change applied by a newer node, and whether the older binary can read data written after the upgrade. Record the restore point, its time and the sessions and events that would be lost if you restore.

Write the rollback runbook and rehearse it in staging. Name the owner who can call a rollback, the symptoms that trigger each option, and the order of steps: drain traffic from the affected node, revert the image in the rolling update, and only then consider a database restore. Confirm that your backups are restorable by performing a restore into a separate environment, and measure how long the restore takes against your outage tolerance. If you run the Keycloak Operator, check how the custom resource and the operator version roll back together, because approving an older operator against a newer Keycloak custom resource may not be supported. Ask your vendor for the supported downgrade path for your version, and document any gap as a risk you accept before the patch window.

Questions teams ask before upgrading Keycloak without downtime

How much does a Keycloak patch upgrade cost?

The cost is mostly internal staff time plus any outside help you buy, and no supplied figure sets a price for either. Your team pays for the hours spent reading release notes, running the update-compatibility check, building a test environment that resembles production, testing realms and logins, and performing the rolling restart. Environment parity usually drives the largest share: a staging cluster with a copy of the database costs more to run than a single test node. These costs are mostly one-time per release, while the recurring part is the quarterly patch cadence itself. Ask any partner for a quote that lists each of these components separately, the number of environments included, and whether retesting is included when a patch fails.

How long does a zero-downtime Keycloak patch upgrade take?

Duration depends on how many Keycloak nodes you run, how complete your test coverage is, and how many approvals your change process requires. The mechanics of a rolling restart are short for each node, but the surrounding work of compatibility checks, staging validation and rollback rehearsal usually takes longer than the restart itself. No duration figure is supplied for this topic, so confirm the expected timeline with your own change calendar and with any partner against your node count and environments. Also check whether the Keycloak release you target has migration notes that require a separate review before testing begins.

Can our own team run a Keycloak patch upgrade without help?

Yes, if the team has Kubernetes or Linux operations experience, can operate the production database, and can test the realms and clients that your applications depend on. The work needs people who understand Keycloak clustering, load balancer session affinity, and how the Keycloak Operator or your deployment tooling rolls pods or nodes. Most gaps appear in testing rather than in the restart: someone must know which login flows, custom providers and token lifetimes need checking. If one of these skills is missing, buy support for that part only, such as a review of the migration notes, or a fixed-scope rehearsal, and keep routine patch work in-house.

Can a Keycloak patch upgrade cause an outage, and how do you prevent one?

Yes. A patch can cause an outage if a node restarts without draining its sessions, if the database schema changes in a way the old nodes cannot read, or if a configuration or provider no longer loads after the update. Prevention relies on a few controls: run the update-compatibility check before changing anything, keep sticky sessions so users are not moved mid-login, restart nodes one at a time while the others serve traffic, and take a restorable database backup first. With the Operator, keep manual approval mode for updates so an upgrade does not start unplanned. Rehearse a rollback on a copy of production before the window.

What should we ask for in a fixed-scope Keycloak upgrade quote?

Ask for a written scope that names the Keycloak version range, the environments covered, the number of realms, clients and custom providers in scope, and the deployment type (Operator, container or virtual machine). The quote should list deliverables such as a compatibility report, a runbook, a test plan, the rolling restart itself, and post-upgrade verification. Confirm who performs rollback, what happens if a defect is found during testing, and whether a retest is included. Request the assumptions behind the price, including what the client must provide such as access, staging capacity and business testers, so you can compare quotes on equal terms.

How do minor and major Keycloak upgrades need different planning from patch upgrades?

Patch releases are normally planned as a rolling update, while minor and major releases need a deeper review of migration notes, because they can change database schema, configuration keys, provider APIs and default behavior. Since Keycloak 26.0, breaking changes in a minor release are opt-in, which reduces surprises but still requires reading each release's upgrade notes. Major releases can require custom code changes and a new test cycle. Check your multi-site or cluster design before planning, since some topologies require stopping all but one site for minor and major versions. Plan these upgrades as separate projects with their own test scope and timeline.

Do we need a separate test environment before applying a Keycloak patch?

Yes, in practice, because a patch is only safe to apply to production once you have seen it run against your realms, clients and providers. The test environment should use the same Keycloak version path, the same database engine and a recent copy of production data where your policy allows it. Matching the database and the load balancer behavior matters more than matching the hardware. If you cannot maintain a full staging cluster, at least run the compatibility check and a short test cycle against a disposable environment before each window. Confirm with your compliance team how production data may be used in tests.

How DeployOpen plans and delivers a Keycloak patch upgrade

DeployOpen plans Keycloak zero-downtime patch upgrades as a written, fixed-scope engagement inside your own infrastructure. The work starts with the current topology and ends with a documented, rehearsed rollout that your team can repeat for the next patch release.

How we scope

  • We record your current Keycloak version, deployment shape, database and hostname setup before agreeing the upgrade target.
  • The written scope names the environments, realms, custom providers and client applications that the patch upgrade covers.
  • Engagements are fixed-scope, and ongoing patch support can be added as a retainer once the first rollout is complete.

How we build

  • We run the update-compatibility check against a copy of your realms and flag any changes that need action before the rollout.
  • We set up rolling restarts behind your load balancer with sticky sessions and confirm that existing user sessions survive each node restart.
  • We configure the Operator rolling update strategy and manual approval mode where your platform runs Keycloak on Kubernetes.

How we hand over

  • You receive a runbook covering the pre-upgrade checks, restart order, rollback steps and post-upgrade verification for your environment.
  • We document the exact configuration changes made during the engagement so your team can reproduce them in later patch cycles.
  • We walk your platform and security teams through the rehearsal results and the evidence captured during each test run.

How we support

  • Ongoing support can cover patch testing, upgrade rehearsals and updates to the runbook as Keycloak releases arrive.
  • Continuous security testing of your Keycloak setup can be included in a retainer, with findings and retests documented.
  • Support scope, response expectations and review cadence are agreed in writing before any retainer work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.