Question on how the --import-realm on start works

I’m in the middle of converting our keycloak 19 legacy setup over to quarkus. Currently we are using the upload_scripts feature to import realm data for local development. Since this feature is deprecated, I’m looking to move to something else.

My question is does this --import-realm command rely on the keycloak realm operator to import this data? Our current local dev setup doesn’t have the operators running. We’ve hoping to eventually be on a full local kubernetes setup for local dev where the operator will be running, but thats probably still a little ways off.

I still need to import the realm data in a way that will work for local dev. So does this function require the presence of the realm operator?

Thanks

The --import-realm cli option is not at all related to some operator stuff, this is natively supported by Keycloak itself. You can just power up a Keycloak container with e.g. start-dev --import-realm command and all realm JSON files in the /op/keycloak/data/import directory will be imported (if not already existing).

2 Likes

Awesome, thanks for the reply. I’ve got things working with --import realm and I’ll move forward with that

Is it possible to load a realm from custom location on startup with?:

./opt/keycloak/bin/kc.sh --import-realm=/path/to/realm1.json

No, with the --import-realm flag it’s only possible to import realms from the mentioned directory.

Thanks. It seems that this command can only be used when keycloak is already fully started, and NOT intended to be used on keycloak startup. Correct?

bin/kc.[sh|bat] import --file <file>

Importing and Exporting Realms - Keycloak

will --import-realm flag be described in All configuration - Keycloak

and how is it different to the options described there?