Why Keycloak health checks need careful Kubernetes probe design
Kubernetes uses probes for two different decisions: whether to send traffic to a pod, and whether to restart it. A Keycloak cluster on Kubernetes needs both decisions made deliberately, because a probe that fails for the wrong reason can remove a healthy identity provider from service or restart every pod during an outage. Keycloak exposes health endpoints once health is enabled in its configuration, and those endpoints sit on the management interface, the same interface that serves Prometheus metrics at /metrics when metrics are enabled. Keycloak is licensed under Apache 2.0, and the Keycloak Operator, installed through Operator Lifecycle Manager, is the recommended install path. Confirm which probe definitions the operator generates for your release before you write your own.
The main risk is coupling restarts to the database. Keycloak depends on its database for almost every login, so a database failover or brief network interruption will make readiness checks fail. That failure should take pods out of the load balancer until the database recovers. It should not cause the liveness check to fail, because restarting Keycloak pods during a database blip adds reconnection and startup load at the moment the database is trying to recover. Startup also needs its own allowance. Keycloak migrates its database schema automatically at startup by default, so the startup window must be long enough for a migration to finish, or the kubelet may restart a pod that is still doing legitimate work.
Before you deploy, write down what each probe answers and test that answer. Confirm the exact endpoint paths and the port for your Keycloak release in the production configuration guide, and make sure the management port is reachable from the kubelet and load balancer but not exposed through public ingress. In a non-production cluster, simulate a database outage and check that pods leave the load balancer without restarting. Repeat the test after each Keycloak upgrade, since the health behavior is part of what changes between releases.
What the startup, liveness and readiness checks cover in Keycloak
Keycloak exposes separate health endpoints for startup, liveness and readiness, and each one answers a different question for the orchestrator. Mapping each probe to the right failure action is what keeps a brief database interruption from turning into a rolling restart of every Keycloak pod.
Startup probe: is it still booting
The startup probe answers whether Keycloak has finished starting, including the database schema check and any automatic migration that runs at boot. Until it succeeds, Kubernetes holds off the other probes, so a slow first start is not mistaken for a hang. Size the failure threshold for your largest expected migration, and confirm the startup endpoint path for your exact Keycloak version before you copy a manifest. A failed startup probe should restart the container, because a container that never finished booting cannot recover on its own.
Keycloak production guideLiveness probe: is the process healthy
The liveness probe asks whether the Keycloak process is running and able to respond, not whether it can reach its dependencies. A failure triggers a container restart, so the check must never call the database, an identity provider or an LDAP server. If it does, a database outage restarts every Keycloak pod at the moment they are most needed. Keep the liveness check shallow, give it a generous timeout, and set the failure threshold so a short garbage collection pause does not count as a crash.
Readiness probe: can it take traffic
The readiness probe answers whether this instance should receive requests right now. A failure removes the pod from Service endpoints and load balancer targets but does not restart it, which is the correct response to a temporary dependency problem such as a database failover. Confirm what Keycloak reports as ready for your version and configuration, and test a database interruption in a non-production cluster to see how fast traffic drains and returns. Pods that are not ready should wait, not restart.
Management port and endpoint exposure
Health and metrics endpoints are served on the management interface, which is separate from the public HTTP port. Probes should target that interface, and it should not be published through the public reverse proxy or ingress. Confirm the management port setting and the endpoint paths for your Keycloak version, then check that the admin and management hostnames are restricted as the production guide recommends. Load balancer health checks should use the same readiness path so that the balancer and Kubernetes agree on which instances are serving.
Load balancer checks outside Kubernetes
Load balancers in front of Keycloak running on virtual machines or in a hybrid setup need their own health check definitions. Point them at the readiness-style endpoint, not the liveness endpoint, so an instance with a broken database connection is removed from rotation without being killed. Set the check interval and healthy and unhealthy thresholds deliberately, and document the expected response code. Test the behavior during a planned database failover, because the balancer's drain timing often decides whether users see errors.
Testing probe behavior before go-live
Probe settings are easy to get wrong and hard to see until an incident. Run a test that stops the database, slows it, and blocks a dependency, then record which probes fail, how fast pods are removed, and whether any restarts occur. Repeat the test after each Keycloak upgrade, because endpoint behavior and migration timing can change between releases. Ask your implementation partner or platform team to keep these results with the deployment runbook.
Health configuration options and when each fits
This table compares the main choices for exposing Keycloak health and metrics to Kubernetes and load balancers, and the deployment method that owns the probe settings. Read each row for the exposure it creates and the work it leaves with your team. The main takeaway is that probes should stay on an internal listener that the public reverse proxy never routes.
| Option | When it fits | Trade-off | Confirm before you choose |
|---|---|---|---|
| Health on the main HTTP port | Local test clusters and early pilots where one listener is the simplest setup | Health paths share the public listener, so the reverse proxy must block them from public hostnames | Confirm your proxy path rules deny health paths on public hosts |
| Health on the management port | Production clusters where probes need a listener the public proxy never routes | The kubelet and any internal load balancer must reach the management port, so service and network policy need updating | Confirm the kubelet and internal checks can reach the port and the Ingress cannot |
| Metrics on the management interface | Teams scraping Prometheus who want metrics kept off the public path | Metrics requires --metrics-enabled=true, and scrape access must be planned in network policy alongside probes | Confirm the Prometheus scraper can reach /metrics and public routes do not expose it |
| Keycloak Operator custom resource | Teams standardizing on Operator Lifecycle Manager and the project's Keycloak resource | The Operator generates the pod specification, so probe and port changes depend on the fields that Operator version exposes | Confirm which health, port and probe fields your Operator version accepts, and use manual approval for updates |
| Hand-written Deployment manifests | Teams with existing GitOps templates who need direct control over probe timing and startup order | Your team owns probe values, startup timing and the review of each manifest change at every Keycloak upgrade | Confirm probe settings are kept in version control and retested after each upgrade |
How probes, the management port and the database interact
The diagram starts with the kubelet and the load balancer, which both call the management interface rather than the public listener. Startup, liveness and readiness each map to a separate path, and only the liveness path leads to a container restart. Readiness only removes the pod from service, and the external database sits behind the Keycloak pod, so a database outage should not trigger restarts. Check that your liveness probe does not depend on the database.
Probe paths on the management interface, with restart and removal-from-service outcomes labeled.
How to set up Keycloak health probes in Kubernetes
This sequence takes a Keycloak deployment from version confirmation to tested probes, so Kubernetes stops sending logins to pods that cannot serve them and restarts pods only when they are truly stuck. Each step closes with a check you can run before moving on.
Confirm the Keycloak version and install method
Record the Keycloak version from the running image tag, the install method (Keycloak Operator, Helm chart or hand-written manifests) and the Kubernetes version of the cluster. Health paths and settings can change between releases, so read the health section of the server configuration guide for your exact version before writing any manifest. If you use the Keycloak Operator, confirm that update approval is set to manual so that an unplanned upgrade does not change probe behavior. Check: you can name the Keycloak version, the install method and the documentation page you will follow.
Enable health checks and the management interface
Turn on the health feature in the Keycloak startup configuration, using the option named in the configuration guide for your version. Keycloak serves health from a management interface that is separate from the public hostname, so confirm the management port for your version and make sure no Ingress or external load balancer routes that port to the internet. The same interface serves metrics when metrics are enabled, so the restriction applies there too. Check: the container logs show the management interface started on the expected port inside the pod.
Verify endpoints from inside the pod
Open a shell in one Keycloak pod and call each health path with curl against the management port: the overall health endpoint, the readiness endpoint, the liveness endpoint and the startup endpoint if your version provides it. A healthy pod with a reachable database should return a success status, and the response body should list the checks you plan to rely on. If you enabled metrics with --metrics-enabled=true, confirm that the metrics path answers on the same interface. Check: every endpoint returns the status you expect, and you have recorded the response body for later comparison.
Set the startup probe for first start and migration
Add a startup probe that targets the startup check, with a failure threshold large enough to cover first boot. Keycloak migrates its database schema automatically at startup by default, so a healthy pod can take noticeably longer to become ready after a first install or an upgrade. Ask your team to measure startup on a copy of production-sized data and set the threshold from that measurement, not from a guess. Check: a staged rolling restart completes without the startup probe killing any pod.
Split the readiness and liveness targets
Point the readiness probe at the check that covers the database connection, so a pod that cannot reach the database is removed from Service endpoints and stops receiving logins. Point the liveness probe only at a check that confirms the Keycloak process still responds, and leave the database out of it. A database outage then takes pods out of rotation without restarting them, which avoids adding restart load to a system that is already struggling. Check: the manifest lists two different paths, and the pod description shows each probe with its own target.
Configure the load balancer health check
Point the external load balancer or ingress health check at the readiness target. Do not point it at the public login page or the admin console, because those paths depend on more than the pod's ability to serve traffic and expose admin surfaces to probe traffic. Keep the management port reachable only from cluster and load balancer networks. Confirm the check interval and unhealthy threshold in your load balancer's documentation and against the failover time your service can tolerate. Check: every healthy pod shows as healthy, and a pod whose readiness fails moves to unhealthy within your configured window.
Test database loss in a non-production environment
In a non-production cluster, interrupt the connection between Keycloak and its database for a short, controlled period, for example with a network policy or by stopping the database service in a test environment. Watch the readiness state, the pod restart counts and the Keycloak logs during the outage. Restore the database and confirm pods return to ready without restarts. Repeat the test after any probe change. Check: restart counts are unchanged, pods left and rejoined the load balancer pool, and every error in the logs is explained. If pods restarted, move the database check out of liveness before going further.
How to avoid restarts during database blips
The most common way to turn a short database problem into a full outage is to point the liveness probe at the database. Liveness answers one question for the kubelet: is this process stuck and worth restarting? If that probe fails whenever Keycloak cannot reach PostgreSQL, a few seconds of failover or a brief connection storm makes every pod fail at once, and the kubelet restarts them all in the same window. The new pods then start, run schema checks and compete for connections against a database that is still recovering, so the outage lasts longer than the database problem itself. Keep the liveness probe local to the JVM so it only reports whether the Keycloak process is responsive. Confirm the exact liveness path and its behavior for your release in the Keycloak health documentation before you wire it up.
Move the database dependency into the readiness probe instead. When readiness fails, Kubernetes removes the pod from Service endpoints and the load balancer stops sending it traffic, but the container keeps running and reconnects once the database returns. That is the behavior you want during a blip: logins pause or fail for the affected window, and no pod is killed. Set failureThreshold and periodSeconds so that a readiness failure has to persist for a meaningful interval before a pod leaves rotation, and keep timeoutSeconds generous enough that a slow query during failover does not count as a failure. Test these values against a real failover in a non-production environment, because the right numbers depend on your database's failover time and your connection pool settings, which you should confirm with your database team.
These settings only protect you if the database itself can fail over quickly. Keycloak's high availability architectures require a synchronously replicated database, so plan the database tier before tuning probes. Verify with your database team that the replica used for failover is synchronous, that failover time has been measured, and that Keycloak's connection pool recovers without a restart after failover. Also check the load balancer health check separately: it should match readiness, not liveness, so that the same blip does not cause both traffic removal and restarts. Record the chosen thresholds and the failover test results in your runbook so the next person changing a probe can see why it is set that way.
Security and exposure risks of health endpoints
Health and metrics endpoints are small features with large exposure: they reveal how Keycloak is built and where it is failing. The risks below share one root cause, which is letting management traffic travel the same路径 as public sign-in traffic. Each card names a check to run before the probes go live.
Management interface on public ingress
Keycloak serves health and metrics from a management interface, separate from the HTTP listener that serves logins. If your ingress rule forwards every path on the public hostname to the Keycloak service, the health endpoints are reachable from the internet. Check that the ingress routes only the public paths and that the management port is reachable only from the kubelet, the monitoring stack and the load balancer health checks.
Keycloak production guideMetrics leaking internal detail
The Prometheus endpoint at /metrics exposes counters about logins, sessions, caches and the JVM. Attackers use that detail to time brute force attempts and to see when a dependency is failing. Enable metrics only when a scraper needs them, and block /metrics at the reverse proxy so that only the monitoring network can reach it. Confirm this with a request from an outside address.
Keycloak metrics guideHealth responses revealing component state
Health checks can report the state of the database connection and other components. That detail is useful to operators but not to anonymous callers. Review what the health response includes in your Keycloak version, and keep detailed output on the management port while the public side returns no more than a status. Ask your team to confirm the exact fields returned before you publish the route.
Probes bypassing TLS expectations
Keycloak's production guidance calls for TLS on all communication. Probes often use plain HTTP inside the pod, and teams sometimes copy that setting to external load balancer checks. Decide which probe paths may run without TLS, document that exception, and confirm that any path reachable from outside the cluster is served over TLS. Verify this with the certificate chain your load balancer expects.
Keycloak production guideShared hostname for admin and public paths
The admin console and Administration REST API should sit on a different hostname or context path from the public frontend URLs. When management traffic shares a hostname with sign-in pages, a single routing mistake exposes admin surfaces, and probe rules end up mixed into public access logic. Put admin and management paths on a separate hostname or context path and review the proxy configuration whenever a route changes.
Keycloak production guideReverse proxy path restrictions
A reverse proxy with path restrictions is the control that ties these risks together. It allows the public realm paths, denies everything else by default, and passes management paths only from approved source networks. Test the allowlist with requests to admin, metrics and health paths from outside the cluster. Keep the rule set under version control so that an upgrade cannot quietly reopen a path.
Keycloak production guideQuestions teams ask before wiring Keycloak probes
Can our own team wire Keycloak health probes without a partner?
Yes, if your team already runs Kubernetes and Keycloak and can test failure cases in a non-production environment. The basic change is small: enable health checks and the management interface, then point startup, liveness and readiness probes at the documented endpoints. The harder part is deciding what each probe should cover, how thresholds interact with database failover, and proving that a database blip does not restart every pod. Teams with a tested staging cluster and a clear owner for probe settings usually handle this in-house. Teams without that capacity often bring in a partner for the review and the failover test.
What drives the effort of wiring Keycloak probes?
The main drivers are how Keycloak is deployed, how many environments need matching configuration, and how the database and load balancer are arranged. Teams using the Keycloak Operator express probe and management settings through its custom resources, while teams using hand-written manifests manage every probe, service and port themselves. Each additional environment, such as development, staging and production, multiplies the testing. A single database endpoint behaves differently from a failover pair, and a cloud load balancer with its own health check adds a second place where a failing check can drop traffic. Ask any provider to list these items in the written scope before agreeing on a quote.
What do we need to provide for a probe engagement?
The work needs access to the Kubernetes cluster and namespaces where Keycloak runs, along with read access to the current manifests or Operator resources. It also needs a database failover test window agreed in advance, because the probe behavior is only proven when the database is actually interrupted. Your team should sign off on the probe thresholds, timeouts and failure counts, since those values decide when pods restart and when traffic is removed. Finally, name the people who approve changes to production, and confirm who owns the load balancer health check settings, which often sit outside the Kubernetes team.
How long does a Keycloak probe engagement take?
Duration depends on the scope written into the engagement, not on a fixed template. A single cluster with one environment and a simple load balancer check is a much smaller task than several environments with separate databases, custom health paths and a failover test in each. Time also depends on how quickly your change approvals and test windows can be scheduled, since the database failover test cannot run at an arbitrary time. DeployOpen does not publish durations. Request a timeline as part of the written scope, and ask for the dependencies that would move it.
Why does a database blip restart Keycloak pods, and how do we stop it?
A readiness or liveness check that queries the database will fail during a short database failover, and Kubernetes then removes the pod from service or restarts it. The usual fix is to keep the liveness probe focused on whether the process is running, and to let the readiness probe reflect whether the instance can serve requests. Thresholds, initial delays and timeouts should be long enough to absorb the time a failover takes in your database topology. Confirm the actual failover duration with your database team by testing it, rather than assuming a value. Keep a record of the chosen settings so that later changes are reviewed against the same test.
What changes when we upgrade Keycloak to a new minor release?
Probe endpoints and their intent should be rechecked during each upgrade, because the Keycloak project plans four minor releases a year and the upgrade notes can change behavior that affects health. Since Keycloak 26.0, breaking changes in a minor release are opt-in, which makes the upgrade notes the place to check for settings that have moved. Test the new version against the same probe thresholds in a non-production cluster, then confirm that startup time still fits the startup probe. Keep the upgrade path in the same change process as your probe settings, so that a version bump and a probe change are never reviewed in isolation. The Keycloak upgrading guide is the natural next read for each release.
Does the Keycloak Operator change how we manage probes?
The Operator changes where probe and management settings live, not the underlying checks. When you use the Keycloak Operator, installed through Operator Lifecycle Manager, you manage Keycloak through its custom resources, and your probe and port settings should be reviewed there alongside the Operator version. The Operator documentation recommends manual approval mode for operator updates, which keeps automatic upgrades from changing behavior without review. Teams that run manifests by hand must keep probe definitions aligned with each Keycloak image they deploy. Either way, confirm the chosen install method and approval mode before setting thresholds.
Limits to confirm in your environment
Health checks look simple until a probe restarts a healthy node during a database blip or a load balancer rejects the check type you chose. The cards below list the points to confirm against your exact Keycloak version, load balancer and Kubernetes release before you wire probes into production.
Health endpoint paths and responses
Confirm the exact health endpoint paths and response details for the Keycloak version you run, on the management interface and not the public port. Check which endpoints exist, what HTTP status each returns when healthy and when degraded, and whether the response body changes. Treat the version in use as the source of truth, because probe definitions copied from older examples can point at paths that no longer behave the same way.
- Current release
- 26.8.1
Load balancer check support
Confirm that your load balancer can send the check type you need, such as an HTTP request to a specific path on the management port with an expected status code. Some managed load balancers only support TCP checks or cannot reach a separate management port. If the check cannot target the management interface, decide whether the public hostname is exposed for health and whether that is acceptable under your hardening rules.
Kubernetes version support window
Check which Kubernetes minor versions your provider runs and how long each stays under maintenance. As of September 2026 the project maintained 1.37, 1.36 and 1.35, with 1.35 ending February 28, 2027. Probe fields and their defaults can change between releases, so validate your probe manifests on the cluster version you will operate, and plan to retest them when the cluster is upgraded.
Kubernetes releasesProbe behavior during slow database failover
Test what the probes do when the database slows or fails over. A readiness check that depends on the database should remove a pod from traffic without killing it. A liveness check that depends on the database can cause restart loops that make a short database event much longer. Run a controlled failover in a staging environment, record how many pods restart and how long logins fail, and set failure thresholds and timeouts from that observed behavior.
Operator update approval timing
Confirm how your Keycloak Operator update approval mode affects when a new version reaches the cluster. The Operator documentation strongly recommends manual approval to avoid unintended automatic upgrades. Under manual approval, probe changes that ship with a new Keycloak version wait for an approver, so the probe settings you tested may not match production for days. Ask who approves updates, how probe changes are reviewed, and whether staging receives each version first.
Operator installationHow DeployOpen validates probes before go-live
Before a Keycloak deployment goes live, DeployOpen tests how the probes behave when the database is unavailable, because that is the failure most likely to turn a short blip into a restart loop. The test starts from the probe configuration the client intends to use, then interrupts the connection between Keycloak and the production-grade database for a controlled period while traffic runs against the cluster. The team watches whether the readiness check removes affected pods from the load balancer, whether the liveness check stays green long enough that pods are not killed, and whether pods recover without manual action once the database returns. Where a probe restarts pods during the interruption, the finding goes into the report with the specific setting, such as the timeout, failure threshold or the check it targets, and a proposed change to test again.
The second check confirms that the management interface is not reachable from public routes. Keycloak serves health and metrics endpoints on a management port that is separate from the public HTTP port, so DeployOpen tests from outside the cluster, through the ingress, the reverse proxy and any load balancer rules, that requests to the health paths and the /metrics endpoint on the management port fail. The same test is run from a pod in another namespace to confirm that network policies behave as the client's design says. Results depend on the client's network controls, so the client should confirm the exact ingress, proxy and firewall rules that apply in their environment before the test is scheduled.
The last step is documentation for the operations team. DeployOpen records the final probe configuration for the startup, liveness and readiness checks, the load balancer health check settings, the management port and its exposure rules, and the observed behavior during each test, so that on-call engineers can tell a database problem from a pod problem during an incident. The handover also lists the changes that would need a retest, such as a Keycloak version upgrade, a change to the database connection pool or a change to the ingress. Validation reduces risk but does not guarantee that a future incident will behave the same way, so the document should be reviewed after each upgrade and after any change to the database platform.
How DeployOpen scopes and delivers Keycloak probe work
DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure, including Keycloak. For health checks and Kubernetes probes, the work starts from how your cluster, load balancer and database behave during failures, so that probe wiring reflects your environment rather than a generic template.
How we scope
- Engagements are fixed-scope, with the probe work, deliverables and timelines agreed in writing before build starts.
- The written scope names which Keycloak endpoints, management port settings and Kubernetes probe types are in and out of scope.
- Scope records how each probe will be tested, including the database outage scenarios that should not trigger a restart.
How we build
- Health and management settings are configured in your Keycloak deployment manifests, Helm values or Operator resources, under your change control.
- Startup, liveness and readiness probes are set against the chosen Keycloak endpoints and tested with the database stopped and restored.
- Load balancer health checks are aligned with the readiness behavior, and the results are reviewed with your platform team before handover.
How we hand over
- Handover documents the probe configuration, the endpoints behind each check and the reasoning for each timing value.
- Runbooks describe what operators should expect during a database failover and when a pod not ready state needs investigation.
- Your team receives the test scripts and failure scenarios used, so retests can be run after upgrades or cluster changes.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, covering probe changes after Keycloak upgrades.
- Retainers can include rechecking probe behavior when Kubernetes or Keycloak versions change, with the scope agreed in writing.
- Ask any provider to confirm how probe changes are tested before they reach production clusters.

