Best practices of Export/Import Keycloak data in Kubernetes Best practices of Export/Import Keycloak data in Kubernetes kubernetes kubernetes

Best practices of Export/Import Keycloak data in Kubernetes


Basically, you just have to start the exporting Keycloak instance on ports that are different from your main instance. I used something like this just now:

bin/standalone.sh -Dkeycloak.migration.action=export -Dkeycloak.migration.provider=singleFile -Dkeycloak.migration.file=keycloak-export.json -Djboss.http.port=8888 -Djboss.https.port=9999 -Djboss.management.http.port=7777

The important part are all the ports. If you get more error messages, you might need to add more properties (grep port standalone/configuration/standalone.xml is your friend for finding out property names), but in the end, all error messages stop and you see this message instead:

09:15:26,550 INFO [org.keycloak.exportimport.singlefile.SingleFileExportProvider] (ServerService Thread Pool -- 52) Exporting model into file /opt/jboss/keycloak/keycloak-export.json[...]09:15:29,565 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: Keycloak 3.2.0.Final (WildFly Core 2.0.10.Final) started in 12156ms - Started 444 of 818 services (558 services are lazy, passive or on-demand)

Now you can stop the server with Ctrl-C, exit the container and copy the export file away with kubectl cp.