deploy keycloak on kubernetes

7/2/2018

I am trying to run keycloak on kubernetes using Postgres as a database. The files I am referring to are on github.com.

I used kompose to generate the kubernetes yaml files, as a staring point, using the files that jboss published here.

I first start postgres with the command

./start-postgres.sh

Then I try to start keycloak:

kubectl create -f keycloak-deployment.yaml

The keycloak pod stops because it cannot connect to the database with the error:

10:00:40,652 SEVERE [org.postgresql.Driver] (ServerService Thread Pool -- 58) Error in url: jdbc:postgresql://172.17.0.4:tcp://10.101.187.192:5432/keycloak

The full log can be found on github. This is also the place to look at the yaml files that I use to create the deployment and the services.

Appreciate your help and suggestions.

Cheers

-- Peter Zandbergen
keycloak
kubernetes

1 Answer

7/2/2018

After some experimenting I found out that using the name postgres in the keycloak-deployment.yaml file

- env:
    - name: DB_ADDR
      value: postgres

messes things up and results in a strange expansion. After replacing this part of the yaml file with:

- env:
    - name: DB_ADDR
      value: postgres-keycloak

makes it work fine. This also requires changing the postgres-service.yaml file. The new versions of the files are in github.

-- Peter Zandbergen
Source: StackOverflow