Setting up realms in Keycloak during kubernetes helm install

时间:2018-06-04 17:32:09

标签: keycloak kubernetes-helm

I'm trying to get keycloak set up as a helm chart requirement to run some integration tests. I can get it to bring it up and run it, but I can't figure out how to set up the realm and client I need. I've switched over to the 1.0.0 stable release that came out today:

https://github.com/kubernetes/charts/tree/master/stable/keycloak

I wanted to use the keycloak.preStartScript defined in the chart and use the /opt/jboss/keycloak/bin/kcadm.sh admin script to do this, but apparently by "pre start" they mean before the server is brought up, so kcadm.sh can't authenticate. If I leave out the keycloak.preStartScript I can shell into the keycloak container and run the kcadm.sh scripts I want to use after it's up and running, but they fail as part of the pre start script.

Here's my requirements.yaml for my chart:

dependencies: - name: keycloak repository: https://kubernetes-charts.storage.googleapis.com/ version: 1.0.0

Here's my values.yaml file for my chart:

keycloak: keycloak: persistence: dbVendor: H2 deployPostgres: false username: 'admin' password: 'test' preStartScript: | /opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password 'test' /opt/jboss/keycloak/bin/kcadm.sh create realms -s realm=foo -s enabled=true -o CID=$(/opt/jboss/keycloak/bin/kcadm.sh create clients -r foo -s clientId=foo -s 'redirectUris=["http://localhost:8080/*"]' -i) /opt/jboss/keycloak/bin/kcadm.sh get clients/$CID/installation/providers/keycloak-oidc-keycloak-json persistence: dbVendor: H2 deployPostgres: false

Also a side annoyance is that I need to define the persistence settings in both places or it either fails or brings up postgresql in addition to keycloak

2 个答案:

答案 0 :(得分:1)

我也尝试了这个并且也遇到了这个问题所以raised an issue。我更喜欢将-Dimport与realm .json文件一起使用,但是你的观点建议postStartScript选项是有意义的,所以我在这个问题的公关中都包括了

答案 1 :(得分:1)