Post

How to get Keycloak to connect to MSSQL

How to get Keycloak to connect to MSSQL

In order to get Keycloak working with MSSQL, you need to configure the Keycloak Helm chart to use the MSSQL database. Here’s an example of how to do it:

value.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
postgresql:
  enabled: false

image:
  registry: harbor.mylab.lol
  repository: chainguard-private/keycloak-iamguarded
  pullPolicy: IfNotPresent

externalDatabase:
  host: "HOSTNAME_OF_SQL_SERVER"
  port: 1433
  database: "<DB_NAME>"
  user: "<SQL_USER>"
  password: "<PASSWORD>"

extraEnvVars:
  - name: KC_DB
    value: "mssql"
  - name: KC_DB_URL
    value: "jdbc:sqlserver://<HOSTNAME_OF_SQL_SERVER>:1433;databaseName=keycloak;encrypt=true;trustServerCertificate=true"
  - name: KC_DB_SCHEMA
    value: "dbo"
  #not required
  - name: KC_DB_POOL_MIN_SIZE
    value: "10"
  - name: KC_DB_POOL_MAX_SIZE
    value: "50"

auth:
  adminUser: admin
  adminPassword: "admin"

replicaCount: 1

production: false
This post is licensed under CC BY 4.0 by the author.