On this page
Short answer
The supported way to run Keycloak on Kubernetes is the Keycloak Operator: install it, give it an external PostgreSQL (or other supported) database, then declare one Keycloak resource with a real hostname, TLS and at least two instances.
The supported way to run Keycloak on Kubernetes is the Keycloak Operator: install it, give it an external PostgreSQL (or other supported) database, then declare one Keycloak resource with a real hostname, TLS and at least two instances. The Operator does not run your database, and that is where most production work sits.
This guide follows the current upstream docs (Keycloak 26.8.2, read 4 December 2026) and the order of work we use in our Keycloak support work. Command lines are quoted from the official pages.
What do you need before you install the Keycloak Operator?
You need a database, a public hostname with a TLS certificate, and a decision on who terminates TLS. The Operator manages Keycloak pods, not the database, so the database must exist, be backed up and be sized before the first pod starts.
- Database: the database guide lists PostgreSQL 14 to 18, MySQL 8.0 and 8.4, MariaDB, SQL Server and Oracle as supported, and says versions outside its table are not supported.
- Hostname: the hostname guide says production needs either
hostnameset orhostname-strictexplicitly false, and that strict mode should stay on unless your proxy overwrites the Host header. - Ingress: the Operator creates an Ingress by default; if you use your own, you point it at the
<cr-name>-serviceService.
How do you install the Keycloak Operator on Kubernetes?
Create a namespace and apply the Operator manifests with kustomize at the version tag you chose. The installation page does this in two commands and notes the Operator watches only the namespace it is installed in, unless you use the cluster-wide variant.
- Create the namespace:
kubectl create namespace keycloak - Apply the manifests, pinning the tag:
kubectl apply -k 'github.com/keycloak/keycloak-k8s-resources/kubernetes?ref=26.8.2' - Confirm the CRDs exist (
keycloaks.k8s.keycloak.organdkeycloakrealmimports.k8s.keycloak.org) and the Operator pod is running.
The guide warns that kubectl delete -k on the same kustomization also deletes the CRDs, and with them your Keycloak resources. Keep the Operator version in step with the server version you run, and read the official installation page for the cluster-wide option.
How do you deploy a production Keycloak with the Operator?
Create a database credentials Secret, a TLS Secret, then a Keycloak custom resource that references both. The basic deployment guide gives a working example; treat it as a starting point, not the finished production file.
- Create the database Secret:
kubectl create secret generic keycloak-db-secret --from-literal=username=... --from-literal=password=... - Create the TLS Secret from your CA-issued certificate:
kubectl create secret tls example-tls-secret --cert certificate.pem --key key.pem - Write the
Keycloakresource (apiVersionk8s.keycloak.org/v2beta1) with the fields in the table below, thenkubectl apply -fit. - Read the status conditions with the go-template command from the guide until ready.
- Fetch the generated
<cr-name>-initial-adminSecret, sign in, change the credentials and enable MFA, as the guide advises.
| Field | What it sets | Production note from the docs |
|---|---|---|
spec.instances | Replica count | Rolling updates avoid downtime only with at least two replicas |
spec.db | Vendor, host, credential Secrets | The Operator does not manage the database |
spec.http.tlsSecret | Certificate and key | Use httpEnabled: true only for edge or re-encrypt TLS |
spec.hostname.hostname | Public hostname | Must match what clients and issuers see |
spec.proxy.headers | forwarded or xforwarded | Omit it and a legacy default logs deprecation warnings |
spec.networkPolicy | Access to the ingress controller | Limits header spoofing |
How many instances and what update strategy should you use?
Run at least two instances and choose the update strategy on purpose. The production guide says two or more instances let logins survive a node failure, and the rolling-updates page says rolling updates avoid downtime only when at least two replicas are running.
The spec.update.strategy field takes three values, per the rolling updates page:
| Strategy | Behavior |
|---|---|
RecreateOnImageChange (default) | Scales the StatefulSet down before applying a new image, so there is downtime |
Auto | Runs a check Job and rolls only when the change is the same version or a patch within the same major.minor stream |
Explicit | Rolls when spec.update.revision is unchanged; you take responsibility for compatibility |
The same page lists two prerequisites: nodes must stop gracefully on TERM, and the load balancer must honor the readiness probe. Production guidance also says to route traffic using /health/ready. For placement, spec.scheduling accepts affinity, tolerations and topology spread constraints, and the Operator spreads pods across zones and nodes by default.
What should you verify before going live?
Verify that you can lose a pod, restore the database and upgrade the server without surprises. A green status condition proves the pods started; it does not prove any of these three.
- Delete one pod under load and confirm sign-ins continue.
- Restore a database backup into a scratch environment and start Keycloak against it. The database guide gives no backup procedure, so this is yours to define.
- Check the hostname: open the OpenID configuration endpoint and confirm every URL uses the public hostname.
- Confirm only the paths you intend to expose reach the internet; the production guide says to block REST API paths at the proxy if they should not be public.
- Set resource requests and limits in
spec.resources; the Operator defaults are 1700MiB requested and 2GiB limit when unset. - Rehearse a patch upgrade and read the
RecreateUpdateUsedcondition to see which path was taken.
When should you ask for help?
Ask when the first upgrade, a database restore or a multi-node session problem is closer than your team's experience. AceMQ's senior engineers support Keycloak on the Operator or on other installs, community or Red Hat build; see Keycloak consulting for design reviews and Keycloak support for 24/7 operations.
We sell no Red Hat subscription and give no Red Hat licensing advice. Defects in Red Hat's own build go to Red Hat. For what comes next, see our notes on upgrade and rollback failure modes.
Sources
Frequently Asked Questions
Should I use the Keycloak Operator or a Helm chart?
The Operator is the Keycloak project's own Kubernetes install route and is the one documented on keycloak.org. Third-party Helm charts are maintained elsewhere. Pick whichever your team can upgrade and debug, and keep the Keycloak version and your database versions inside the supported lists.
Does the Keycloak Operator manage the database?
No. The basic deployment guide states the Operator does not manage the database. You supply a supported database, the host and credentials through Secrets, and you own its backups, sizing and upgrades.
How many Keycloak instances do I need in production?
At least two. Keycloak's production guide says two or more instances let logins survive a node failure, and the Operator's rolling-update page says rolling updates avoid downtime only with at least two replicas running.
Talk to an engineer
Need a hand with Keycloak?
Senior engineers who run it in production. Get a quote or a free consultation, no sales pitch.

