Repository navigation
Cloud Foundry: KeyCloak ENV Variable KC_BOOTSTRAP_ADMIN_USERNAME #36661
Replies: 3 comments 1 reply
These values have no effect after the master realm is initialized in the database.
Note that build time options such as KC_DB=postgres must be set prior to calling build. You'll need to double check the env of the image you are creating, have you used "docker inspect"? You can yry just a local podman or docker run as shown in https://www.keycloak.org/getting-started/getting- 8000 started-docker - to confirm that environment variables are used as expected by the keycloak image. |
|
Hello shawkins, thanks for the fast reply,
With cf push command i can only start directly the production mode. During the start KeyCloak creates automatically directly the tables in the PostGreSQL Database in CloudFoundry. I deleted the PostGreSQL database (is available form a further try) andcreated a new emtpy one. I got an 302 error when I am trying to open KeyCloak in the browser. If i try to open following link in CF "https://keycloak.cfapps.e.........com/admin/master/console" I got an HTTP 200 but an error in the application. |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
I create a docker image based on following dockerfile.
FROM quay.io/keycloak/keycloak:latest AS builder
Enable health and metrics support
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
Configure a database vendor
ENV KC_DB=postgres
WORKDIR /opt/keycloak
for demonstration purposes only, please make sure to use proper certificates in production instead
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 -dname "CN=server" -alias server -ext "SAN:c=DNS:localhost,IP:127.0.0.1" -keystore conf/server.keystore
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/
change these values to point to a running postgres instance
ENV KC_BOOTSTRAP_ADMIN_USERNAME=.....
ENV KC_BOOTSTRAP_ADMIN_PASSWORD=.....
ENV KC_DB=postgres
ENV KC_DB_URL=jdbc:postgresql://....../b....
ENV KC_DB_USERNAME=......
ENV KC_DB_PASSWORD=.....
ENV KC_HOSTNAME=.......
ENV KC_HTTP_PORT=8080
ENV KC_HTTP_ENABLED=true
ENTRYPOINT ["/opt/keycloak/bin/kc.sh"]
CMD ["start"]
If I run the docker image directly in docker desktop the inital login based on the configured env variables KC_BOOTSTRAP_ADMIN_USERNAME and KC_BOOTSTRAP_ADMIN_PASSWORD
If I push the image to my nexus repo and push it from there to Cloud Foundry I got following information if I open KeyCloak.
Local access required
You will need local access to create the temporary administrative user.
To create the temporary administrative user open http://localhost/, or set the environment variables KC_BOOTSTRAP_ADMIN_USERNAME and KC_BOOTSTRAP_ADMIN_PASSWORD when starting the server.
If I try to set the variable before i start the application in CF via
cf set-env KeyCloak KC_BOOTSTRAP_ADMIN_PASSWORD
cf set-env KeyCloak KC_BOOTSTRAP_ADMIN_USERNAME
this does also not solve the issue.
If I call cf env I got the information that I provided both information
User-Provided:
KC_BOOTSTRAP_ADMIN_PASSWORD: .....
KC_BOOTSTRAP_ADMIN_USERNAME: .....
All other variable for the database connection and the PORT and http activation worked fine in both ways.
Can you please explain me what I am doing incorrect?
Is there another way to specify the initial admin password? Opening localhost is not possible in Cloud Foundry (CF).
Thanks for your help.
All reactions