Chapter 5. Avoiding downtime with rolling updates


Avoid downtime when changing themes, providers, or configurations in optimized images.

By default, the Red Hat build of Keycloak Operator will perform rolling updates on configuration changes without downtime, and recreate updates with downtime when the image name or tag changes.

This chapter describes how to minimize downtimes by configuring the Red Hat build of Keycloak Operator to perform rolling updates of Red Hat build of Keycloak automatically where possible, and how to override automatic detection for rolling updates.

Use it, for example, avoid downtimes when rolling out

  • an update to a theme,
  • provider or build time configuration in a custom or optimized image, or
  • patch releases of Red Hat build of Keycloak.

5.1. Prerequisites

5.1.1. Verify the graceful shutdown

In order for rolling updates to work as expected, check if Red Hat build of Keycloak nodes perform a graceful shutdown when receiving a TERM signal.

Check the log file of the node shutting down for the following log entry. If it shows, the shutdown was graceful.

INFO  [io.quarkus] (Shutdown thread) Keycloak stopped in ...s

See the {links_server_container_name} chapter for details for possible causes when it does not show.

Your load balancer should honor the Red Hat build of Keycloak readiness probe to stop forwarding traffic to nodes shutting down.

See Tracking instance status with health checks and Configuring a reverse proxy chapters for details.

5.2. Supported Update Strategies

The Operator supports the following update strategies:

Rolling Updates
Update the StatefulSet in a rolling fashion, avoiding a downtime when at least two replicas are running.
Recreate Updates
Scale down the StatefulSet before applying updates, causing temporary downtime.

5.3. Configuring the Update Strategy

Specify the update strategy within the spec section of the Keycloak CR YAML definition:

apiVersion: k8s.keycloak.org/v2beta1
kind: Keycloak
metadata:
  name: example-kc
spec:
  update:
    strategy: RecreateOnImageChange|Auto|Explicit 
1

    revision: "abc" 
2
1
Set the desired update strategy here.
2
Revision value for Explicit strategy. Ignored by the other strategies.
Table 5.1. Possible field values
ValueDowntime?Description

RecreateOnImageChange (default)

On image name or tag change

Mimics Red Hat build of Keycloak 26.1 or older behavior. When the image field changes, the Operator scales down the StatefulSet before applying the new image.

Auto

On incompatible changes

The Red Hat build of Keycloak Operator detects if a rolling or recreate update is possible.

Red Hat build of Keycloak supports rolling updates for patch releases. It performs a rolling update if the Red Hat build of Keycloak version is the same or when upgrading to a newer patch version in the same major.minor release stream. It uses the configuration, the image and the version to determine if a rolling update is possible. Future versions might use additional information to make this decision.

Explicit

Only the revision field changes

The Red Hat build of Keycloak Operator checks the spec.update.revision value. If it matches the previous deployment, it performs a rolling update.

When using the Auto update strategy, the Red Hat build of Keycloak Operator automatically starts a Job to assess the feasibility of a rolling update. Read more about the process in the Checking if rolling updates are possible chapter. This process consumes cluster resources for the time of the check and introduces a slight delay before the StatefulSet update begins.

Warning

If the Keycloak CR configured a podTemplate as part of the unsupported configuration parameters, the Keycloak Operator will do its best to use those settings for the started Job. Still it might miss some settings due to the flexibility of the podTemplate feature and its unsupported nature.

As a consequence, the Operator might draw the wrong conclusions if a rolling update is possible from changes to the podTemplate or information pulled in from Secrets, ConfigMaps or Volumes in the podTemplate.

Therefore, if you are using the unsupported podTemplate, you may need to use one of the other update strategies.

The Explicit update strategy delegates the update decision to the user. The revision field acts as a user-controlled trigger. While the Red Hat build of Keycloak Operator does not interpret the revision value itself, any change to the Custom Resource (CR) while the revision remains unchanged will prompt a rolling update.

Exercise caution when using this with automatic Operator upgrades. The Operator Lifecycle Manager (OLM) may upgrade the Red Hat build of Keycloak Operator, and if the Explicit update strategy is in use, this could lead to unexpected behavior or deployment failures as the Operator would attempt a rolling update when this is actually not supported. If you are using the Explicit update strategy, thorough testing in a non-production environment is highly recommended before upgrading.

5.3.2. CR Statuses

The Keycloak CR status of RecreateUpdateUsed indicates the update strategy employed during the last update operation. The lastTransitionTime field indicates when the last update occurred. Use this information to observe actions and decisions taken by the Operator.

Table 5.2. Condition statuses
StatusDescription

Unknown

The initial state. It means no update has taken place.

False

The Operator applied the rolling update strategy in the last update.

True

The Operator applied the recreate update strategy in the last update. The message field explains why this strategy was chosen.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top