What moving Keycloak from virtual machines to Kubernetes involves
Moving a Keycloak running on virtual machines to Kubernetes is a re-platforming exercise, not a data migration. The database and the stored data stay in place, while the runtime, the way configuration is delivered, how nodes find each other, and how traffic reaches the server all change. On the VM estate, configuration is usually set through startup options, environment variables and a configuration file on each host. On Kubernetes, the Keycloak Operator manages the Keycloak, KeycloakRealmImport, KeycloakOIDCClient and KeycloakSAMLClient custom resources, so realms, clients and server settings need to be rewritten as those objects and kept under version control. Cluster discovery moves away from the VM-era setup, and the proxy and ingress layer has to pass the forwarding headers Keycloak reads so that issuer URLs and redirects stay correct.
The effort is best estimated by asking three questions before any build starts. First, how many custom providers and themes are deployed, since each one must be rebuilt against the target Keycloak version and packaged into the server image. Second, how many realms and clients exist, since every one must be exported, translated into custom resources or import files, and tested. Third, which database is in use and whether its version and connectivity from the cluster are already proven. Any engineer who can name these three counts from the current estate can ask a partner for a quote on a written scope. Ask the provider to confirm how they will handle the Operator's update approval mode, the database schema migration at startup or manual migration, and the parallel run that precedes DNS cutover. Confirm the exact Keycloak and Operator versions with the vendor and your own environment before fixing the plan.
Which VM Keycloak settings map cleanly to the Operator
This table compares VM-era Keycloak settings with their Operator or container equivalents and flags the items that need rework. Read each row as a checklist: a check mark means the item carries over with only field changes, while a dash or cross means it needs a rebuild or a decision. Confirm the Operator field support for each setting against the Operator documentation before you write manifests.
| VM-era item | Operator or container equivalent | Maps cleanly | What to confirm or change |
|---|---|---|---|
| Server options in keycloak.conf or standalone.conf | Keycloak custom resource spec and container environment or arguments | Not applicable | Confirm each key is exposed as a Keycloak CR field; set the rest as server options passed through the container |
| Hostname, proxy and HTTP settings | Keycloak CR hostname and proxy fields, plus ingress resources | Not applicable | Reverse proxy headers and admin hostname separation need explicit ingress rules, not copied VM proxy config |
| Cache stack (jdbc-ping default) | Default jdbc-ping cache stack using the database as node registry | No | VM configs using kubernetes, tcp, udp, ec2, azure or google stacks are deprecated; move to jdbc-ping and retest clustering |
| Realm exports and imports | KeycloakRealmImport custom resource | No | Full exports include secrets and users differently than partial imports; plan how realm JSON is split and secured |
| Clients registered in the admin console | KeycloakOIDCClient and KeycloakSAMLClient custom resources | No | Client secrets, redirect URIs and mappers must be re-expressed and checked against the Operator field set |
| User federation (LDAP, Active Directory, Kerberos) | Federation configured in the realm, with bind credentials held in Kubernetes Secrets | Not applicable | Confirm how the Operator handles federation settings and where bind passwords are stored and encrypted at rest |
| Custom providers, SPIs and JARs | Custom image built with providers copied in at build time | No | Each provider must be rebuilt and tested against the target Keycloak version; the Operator does not carry them over |
| Themes and theme files on disk | Theme packaged into the custom container image | Not applicable | Theme directories are not mounted from the VM by default; confirm the packaging approach for your image pipeline |
Documented import and export paths for the move
Realm export and import is the path most teams try first. Keycloak can export a realm to JSON, either as a full export that includes users and credentials or as a configuration-only export without users. The file can then be loaded into a new instance with the import mechanism of the target version. Full exports are useful when you need a portable copy of realm data for a rehearsal, but they are not a secure transport format, so they should be stored and deleted under the same controls as the database.
- Full export scope: A full export can include users, roles, groups and clients, but the documentation for your version determines whether passwords, hashed credentials, OTP secrets and client secrets are included or masked.
- Configuration-only export: Realm settings, clients, roles and identity providers can be moved without users, which suits a clean target where users arrive later from the same database.
- Operational limits: Exports taken from a running server can be inconsistent with ongoing logins, so plan a write freeze or a quiet window.
- Multi-realm handling: Export each realm separately and record which realms are in scope for the parallel run.
- Secret handling: Any secret that is masked or omitted must be re-entered in the Kubernetes deployment from a secrets store, not from the export file.
Before relying on this path, confirm export behavior, secret handling and import options for your exact Keycloak version in the server administration guide.
The Keycloak Operator provides a KeycloakRealmImport custom resource that loads realm JSON into a Keycloak instance it manages. It fits teams that want realm definitions kept in version control and applied through the cluster, rather than run by hand. The resource is a declarative way to bring realm configuration in, but it is best treated as an import of configuration, not as a complete copy of a live system with its users and credentials.
- Declarative loading: The import is defined as a Kubernetes object, so the same realm definition can be reviewed, versioned and reapplied to rehearsal and production clusters.
- Source data: The JSON usually comes from an export of the VM instance, edited to remove environment-specific values such as hostnames and redirect URIs.
- Idempotency limits: Confirm how the Operator behaves when a realm already exists and whether re-applying the resource updates or skips existing data.
- Secret placeholders: Client secrets and SMTP passwords should not be committed in plain text. Reference them from Kubernetes Secrets or an external store.
- Version match: The realm JSON should come from an export made with the same major version family the Operator deploys.
Check the Operator's import behavior against the version you deploy, and test the import in a rehearsal namespace before any production run.
For application clients, the Operator can manage KeycloakOIDCClient and KeycloakSAMLClient custom resources. This path keeps each client definition as code, with redirect URIs, protocol settings and scopes stored beside the application deployment or in a platform repository. It is a good fit when the number of clients is manageable and each application team owns its client definition. It does not carry users, sessions or realm-wide settings, so it complements rather than replaces the realm path.
- Per-client ownership: Each application team can review changes to its own client, which reduces the risk of one large realm file becoming a bottleneck.
- Redirect URI changes: Production hostnames often change at cutover, so the resource values must match the new ingress and public frontend URL.
- Secret references: Client secrets should be generated or referenced from a Kubernetes Secret, and the team should confirm how the Operator reads and rotates them.
- Drift control: If a client is also edited in the admin console, the manifest and the live configuration can diverge. Pick one source of truth before the parallel run.
- Coverage check: Compare the list of clients on the VM instance with the resources in the cluster before any DNS change.
Confirm the exact fields and reconciliation behavior for your Operator version in the Keycloak Operator documentation.
Because this migration keeps the existing production database, the database is the most complete carrier of users, credentials, sessions, events and realm state. Pointing the Kubernetes deployment at the same database avoids export and import of user data altogether, but it means both the VM and cluster instances will read the same tables during the parallel run. That shared state needs careful control, because it affects cache behavior, login state and schema changes.
- Schema ownership: Decide which side runs schema migration at startup. Automatic migration on the first new node can change the database for the VM instance still in service.
- Connectivity: The cluster must reach the database over a network path and with TLS settings your database team has approved, and the connection pool sizing should match the replica count.
- Credentials: The database user and password should be supplied from a Kubernetes Secret and rotated under the same process as the VM deployment.
- Backup point: Take and verify a database backup immediately before the first cluster start, since this is the rollback point for the data.
- Cache and cluster state: Node discovery and cache coordination on Kubernetes differ from the VM cluster, so confirm how the cluster stack uses the database during the run.
Confirm the supported database version list and migration behavior for your release in the Keycloak database guide before choosing this path.
How the cluster discovery and database connection change on Kubernetes
On Kubernetes, the first thing to confirm is which cache stack the Keycloak pods will run. The default stack is jdbc-ping, which uses the database as the node registry, so pods find each other through the same database connection they already need. The VM configuration may have used the kubernetes, tcp, udp, ec2, azure or google stacks, and those are deprecated. Do not carry them over. Remove any cache or cache-stack settings that select them, let the pods join through jdbc-ping, and then check in the logs that every pod registers as a cluster member before you test sessions or failover.
Database connectivity is where the VM and cluster designs differ most. Pods reach the database over the cluster network, so the firewall rules, security groups or network policies that allowed the VM hosts to connect must be rewritten for the pod network or the node addresses your CNI uses. Confirm that your database is on the supported list, including PostgreSQL 14 to 18, and that its maximum connection count covers the pods running at peak plus a rolling update, since every pod opens its own pool. Keep TLS on for the database connection, and store the credentials in a Kubernetes Secret with access limited by RBAC. The database must be synchronously replicated for either supported high availability design, so verify that replication mode before you count the cluster as highly available.
Schema migration is the last change to plan. Keycloak migrates its schema automatically at startup by default, which is convenient for a small deployment but means a rolling update can run a migration from a new pod while older pods still serve traffic. For large deployments, the upgrading guide suggests manual migration, where you apply the SQL yourself during a planned window. Decide which approach you will use before the parallel run, and rehearse it against a restored copy of the production database. Confirm the exact steps for your target release in the Keycloak upgrading guide rather than relying on this summary.
How to sequence the move from inventory to decommission
The sequence turns a VM-based Keycloak into a Kubernetes deployment in a way that can be verified at each stage and rolled back until the old environment is retired. Each step closes with an exit criterion, so the cutover is a decision based on evidence rather than a date.
Inventory realms, clients, providers and certificates
The platform engineering team and the Keycloak administrators list every realm, client, identity provider, user federation link, custom SPI provider, theme, signing key, TLS certificate and scheduled job on the existing VMs. They also record the database engine, version and connection settings, the proxy and hostname configuration, and every application that depends on the current public URL. The step is complete when the list is reviewed by the application owners and nothing in the running configuration is undocumented. Ask whether any provider JAR was built against a Keycloak version that the target image will not load.
Pilot the move on a non-production realm copy
The team exports one non-production realm, imports it into a test Keycloak running in the Operator on a staging cluster, and rebuilds the realm configuration as KeycloakRealmImport and client custom resources. Custom providers and themes are rebuilt into the target image and tested against the imported realm. The step is complete when login, token issuance, logout and admin console access work for a representative client, and every difference between the VM and cluster behavior is written down and resolved or accepted by its owner.
Install the Operator through OLM in manual approval mode
The platform team installs the Keycloak Operator through Operator Lifecycle Manager, which the Keycloak Operator documentation recommends, and sets the update approval to manual so that no operator upgrade happens without a review. The team then deploys the Keycloak custom resource in a staging namespace with the chosen database connection, cache configuration and hostname settings. The step is complete when the operator and Keycloak pods are healthy, the approval setting is confirmed in the cluster, and the staging instance passes the same smoke tests as the pilot.
Run both environments in parallel
The VM Keycloak and the Kubernetes Keycloak run at the same time. They either share the production database, which requires that the cluster is configured for the same schema and migration state, or the cluster uses a verified copy of it. Administrators compare realm settings, client counts, login events and metrics from both sides, and the team confirms that the cluster can reach the database without the VMs being involved. The step is complete when the two environments show matching configuration for every realm and the owners of the database and network sign off on the shared data path.
Check ingress, proxy headers and path restrictions
Before DNS changes, the team validates the ingress controller against the reverse proxy guidance: Forwarded and X-Forwarded headers must be handled as intended, the public hostname must match the configured frontend URL, and only the realm, resource and well-known paths should be reachable from outside, with the admin console and administration API kept on an internal hostname or context path. Tests confirm that redirects and issuer values in tokens use the public address. The step is complete when external test requests to admin paths are blocked and token issuer checks pass for every client.
Cut DNS over to the cluster
The team lowers the record time-to-live ahead of the change, moves the public hostname to the cluster ingress, and watches authentication success rates, error logs and metrics exposed at the management interface. Application owners confirm sign-in on their own systems during the window. The team keeps the VM environment running and ready to receive traffic again. The step is complete when the agreed set of applications signs in through the new endpoint, the error rate matches the pre-cutover baseline, and the change record includes the reverse steps.
Decommission the VMs after the rollback window
Once the rollback window agreed in the plan has passed with no unresolved incidents, the team stops the VM Keycloak services, removes their access to the database and secrets, archives the final configuration export and logs according to the organization's retention policy, and revokes the certificates and service accounts that existed only for the VMs. The team confirms that backups of the Kubernetes deployment, including the database, are scheduled and restorable. The step is complete when the VMs are removed from monitoring and the decommission record is signed by the service owner and security team.
Ingress, proxy headers and the admin endpoint on Kubernetes
Keycloak reads proxy information from Forwarded and X-Forwarded headers by default, so the ingress chain decides which scheme, host and client address Keycloak believes it is serving. Before cutover, the team should confirm that the ingress controller overwrites these headers with values it sets itself, instead of passing through whatever a client sends. If a client can supply its own X-Forwarded-Proto or X-Forwarded-Host, Keycloak can build redirect URIs, issuer values and login links from attacker-chosen data. Review the ingress annotations, any load balancer in front of the cluster, and the reverse proxy settings in the Keycloak configuration together, because a header trusted at one hop is trusted for the whole chain. The Keycloak reverse proxy guide linked from this topic's sources describes the header handling to check against your chosen controller.
Keycloak should be reached publicly only through the paths that applications and browsers need: /realms/, /resources/ and /.well-known/. The Keycloak reverse proxy guide advises keeping /admin/ internal, so the ingress should either route the admin console and Administration REST API to a separate hostname reachable only from your administrative network, or deny that path at the public entry point. On the VM estate this was often a firewall rule or a proxy location block that someone wrote once. On Kubernetes, write the restriction as an explicit ingress rule or network policy and test it from outside the network. The management interface, which serves health and /metrics when started with --metrics-enabled=true, should also stay off the public ingress. Scrape it from inside the cluster with a Prometheus setup you control, and confirm the metrics port is not published by any Service or route.
TLS must cover every hop that carries credentials or tokens, including client-to-ingress, ingress-to-Keycloak and connections to the database. Decide whether certificates terminate at the ingress, at Keycloak, or both, and document the trust store each application uses to reach the issuer. During the parallel run, check the frontend URL, the hostname in OIDC discovery documents and the redirect behavior of the login and logout flows against the production names, because a mismatch often appears only after DNS moves. Ask the cluster team to confirm the TLS certificate lifecycle and who renews it, and record which host names the Keycloak frontend URL must advertise so that the cutover runbook can check them.
What drives the effort and cost of this migration
The quote for moving a VM-based Keycloak onto Kubernetes follows from the written scope, and six drivers shape that scope. Each one changes how much rebuilding, testing and parallel running the work needs, so ask for every driver to be itemized rather than accepting a single lump sum.
Custom providers and themes to rebuild
Every custom SPI provider, authenticator, event listener and theme has to be rebuilt into the container image and re-tested against the target version. Count them, note which depend on internal libraries, and check whether each one still compiles against the Keycloak release you plan to run. Each custom artifact is a separate rebuild and retest item. Ask the partner to list them individually in the quote.
Production configDatabase platform and size
The database is the most sensitive dependency in the move. Confirm whether the current database is on the supported list, whether it will stay in place or move to a managed service, and how large the existing data set is. Network path from the cluster, backup and restore testing, and the synchronous replication needed for a highly available design all add work. Ask for the database effort to be quoted separately.
Keycloak database docsIdentity federation and brokering links
Each LDAP, Active Directory, Kerberos or upstream OIDC and SAML identity provider that Keycloak reaches is a connection to re-verify from the new network location. Egress rules, certificate trust, bind accounts and attribute mappers may all change. Every federation link needs its own connectivity and login test before cutover. List them with their owners so that the test plan can be scoped.
Client count and redirect URI changes
Each client's redirect URIs, web origins, logout URLs and any hostname that changes with the new ingress must be updated and tested. Decide whether clients will be managed as KeycloakOIDCClient and KeycloakSAMLClient custom resources or kept as realm imports. The count drives the number of application owners who must sign off. Ask for a client inventory to be part of the written scope.
Existing Kubernetes platform and security baseline
A cluster that already has identity integration, admission controls, Pod Security Standards, etcd backups and encryption at rest in place shortens the work. A new or partly hardened cluster adds platform work that sits outside Keycloak itself. Secrets stored unencrypted in etcd by default need an explicit decision. Confirm which of these controls exist before the scope is written.
Kubernetes Secrets practicesOperator and Kubernetes team experience
Your team's familiarity with Operator Lifecycle Manager, custom resources and Kubernetes upgrade policy determines how much hands-on work a partner must carry and how much your staff must learn. Teams new to the Operator will need time to review its generated resources and to set manual approval for operator updates. Ask the partner what training, runbook and handover work is included and what remains with your team after go-live.
Questions buyers ask before moving Keycloak to Kubernetes
What drives the cost of moving Keycloak from virtual machines to Kubernetes?
The cost is driven by how much of the existing configuration must be rebuilt, how many realms, clients, identity providers and custom providers exist, and how many environments need the same treatment. Cost has two parts: the one-time migration work (inventory, rebuilding configuration as Keycloak, Keycloak Operator and Kubernetes resources, database and ingress changes, parallel run and cutover) and the recurring cost of running the cluster, database, load balancer and operator upgrades. Custom SPI providers and themes add build and retest work. Ask any partner for a written scope that lists each component, the environments covered, the testing included and who operates the cluster afterward, so the quote can be compared with your own team's estimate.
How long does a Keycloak move to Kubernetes take, and what sets that?
No fixed duration applies to every move, so ask for a timeline built from your environment. The main drivers are the number of realms and clients to rebuild, the complexity of federation and brokering, whether custom providers must be rebuilt, the readiness of the Kubernetes platform and its identity and storage integrations, the database access approvals, and the length of the parallel run you require. Change windows also set the pace, because the DNS cutover must fit a window you agree in advance. A written plan should name each phase and its exit criteria, so you can see where time is spent.
What does our team need to provide before the migration starts?
Plan to provide a realm and client inventory exported from the current server, database access for the migration and cutover, cluster access with the namespaces, service accounts and network policies the team agrees to, and the change windows your operations and security teams approve. You should also supply DNS and certificate ownership, the external secret store to be used for database credentials and admin bootstrap, and named owners for testing sign-in and logout for each application. Ask the partner to confirm this list in writing, including who approves production changes.
Can our internal team do this migration without a partner?
Yes, if your team has working knowledge of Keycloak administration, Kubernetes operations and the database that backs Keycloak. The work is mostly careful rebuilding and verification, so the questions to answer honestly are whether you have engineers who can own the Keycloak Operator and cluster after cutover, whether you have time for a parallel run with real application testing, and whether you can keep the old VM environment available for rollback. A partner adds value where those skills or hours are missing. Compare the two options by counting the people, skills and calendar time each requires, not only the build effort.
How does the parallel run avoid user impact before DNS cutover?
The parallel run keeps the VM-based Keycloak serving production while the Kubernetes deployment runs against a copy or a controlled test hostname. Your team checks sign-in, token issuance, logout, admin access and any federated or brokered logins on the new deployment before any DNS record changes. Keep the public hostname pointing to the VMs until those checks pass. Plan the cutover so that DNS changes, cache lifetimes and client redirect URIs are understood in advance, and keep a documented rollback that points the hostname back to the VMs. Confirm with your partner which tests run in each environment and who signs off.
What happens to sessions and tokens at cutover?
Sessions and tokens depend on how the old and new deployments share their database and signing keys. If the new cluster uses a copy of the database, users with active sessions may need to sign in again, and tokens already issued remain valid only while the signing keys and issuer URL stay the same. Changing the issuer URL or hostname forces every relying application to accept the new issuer, so plan that change with application owners. Confirm with your team whether a short forced sign-in is acceptable, and whether the cutover window will be used to invalidate sessions deliberately so the result is predictable.
Which Keycloak and Kubernetes versions to plan against
Start from the Keycloak version you intend to run, not from the one on the virtual machine. The current Keycloak release is 26.8.1, published October 13, 2026, but the version you deploy should be the one the Keycloak Operator you select supports. Install the Operator through Operator Lifecycle Manager, the recommended method, and check which Keycloak images and versions that Operator release targets before you fix the version in the Keycloak custom resource. Keep the Operator on manual approval mode, as the Operator documentation recommends, so that an Operator update never changes your Keycloak version without a planned change window. Also confirm the Keycloak version your current VMs run, because a jump across several minor releases needs the upgrading guide's review of each intermediate step.
Pick the Kubernetes minor version next, and treat it as a support decision as much as a compatibility one. As of September 2026, the Kubernetes project maintains 1.37 (end of life October 28, 2027), 1.36 (June 28, 2027) and 1.35 (February 28, 2027). Since releases arrive about three times per year, a cluster built on 1.35 will need an upgrade within months of go-live. Under the version skew policy, the control plane must be upgraded one minor version at a time, and kubelets may run up to three minor versions behind kube-apiserver. Confirm with your distribution vendor, and with the Operator's release notes, that the chosen Kubernetes version is supported by both the Operator and your cluster, then schedule the Keycloak cutover after the cluster is stable on that version.
How the parts fit during the parallel run and cutover
The diagram starts with users resolving the public hostname through DNS, which still points at the legacy VM Keycloak until the cutover decision. The ingress and reverse proxy routes only the public paths (/realms/, /resources/ and /.well-known/) to the Keycloak pods, and keeps /admin/ on an internal hostname. Both deployments must read from the same synchronously replicated PostgreSQL database, so check that schema versions, realms and clients match before any DNS change. If the new pods fail health or login checks, DNS points back to the VM and the rollback path stays open.
Traffic routing and shared database during the parallel run and DNS cutover.
How DeployOpen scopes and delivers this migration
DeployOpen plans and runs the move of an existing VM-based Keycloak onto Kubernetes inside your own infrastructure, using the Keycloak Operator. We start from a written scope that maps your current configuration, database, ingress and clients, then build and test the new deployment in parallel with the running server before any DNS cutover.
How we scope
- Inventory of the current VM Keycloak version, realms, clients, identity providers, themes and custom providers
- Decision on database connectivity, cache stack and whether the target needs a high availability architecture
- Written scope covering the Operator custom resources, ingress, proxy headers, parallel run and cutover steps
How we build
- Rebuild realms and clients as KeycloakRealmImport, KeycloakOIDCClient and KeycloakSAMLClient resources, kept in version control
- Configure the default jdbc-ping cache stack, reverse proxy headers and a split between public and admin hostnames
- Test logins, token issuance, logout and admin access against the parallel deployment before cutover
How we hand over
- Runbook for the parallel run, DNS cutover, rollback and decommissioning of the VM instances
- Documented Operator settings, including manual approval mode for operator updates and the database migration approach
- Walkthrough with your platform, security and identity teams, with findings and open items recorded in writing
How we support
- Fixed-scope engagements, with scope, deliverables and timelines agreed in writing before work starts
- Ongoing support, upgrades and continuous testing available as a retainer after handover
- Quote follows from the written scope, so ask for the components, assumptions and exclusions it covers

