Keycloak Trying to connect to PostgreSQL server postgresql
Which chart: The keycloak-5.2.7 (and 5.2.7 ) of the affected chart The postgresql-ha-8.1.3 of the postgresql-ha chart
Describe the bug Keycloak is not able to resolve the potgresql pgpool service name
keycloak 17:30:33.11 INFO ==> ** Starting keycloak setup **
keycloak 17:30:33.13 INFO ==> Validating settings in KEYCLOAK_* env vars...
keycloak 17:30:33.15 INFO ==> Trying to connect to PostgreSQL server postgresql...
cannot resolve host "postgresql": lookup postgresql on 10.96.0.10:53: no such host
cannot resolve host "postgresql": lookup postgresql on 10.96.0.10:53: no such host
cannot resolve host "postgresql": lookup postgresql on 10.96.0.10:53: no such host
cannot resolve host "postgresql": lookup postgresql on 10.96.0.10:53: no such host
cannot resolve host "postgresql": lookup postgresql on 10.96.0.10:53: no such host
cannot resolve host "postgresql": lookup postgresql on 10.96.0.10:53: no such host
To Reproduce Steps to reproduce the behavior:
- Deploy the postgresql-ha chart with the provided values yaml file
- Deploy the keycloak chart with the provided values yaml file
Expected behavior Keycloak resolve the service name and connect to postgresql server via the pgpool
Version of Helm and Kubernetes:
Kube : Client Version: v1.21.1
Server Version: v1.22.4
Helm : v3.6.2+gee407bd
Additional context I checked the dns resolution in my kube cluster and it's was working fine
[xxxxxxx@xxxxx ]$ kubectl exec -it dnsutils -- nslookup xx-postgresql-pgpool.demo.svc.cluster.local
Server: 10.96.0.10
Address: 10.96.0.10#53
Name: xx-postgresql-pgpool.demo.svc.cluster.local
Address: 10.100.15.245
values yaml files keycloak:
global:
imageRegistry: ''
imagePullSecrets: []
storageClass: ''
kubeVersion: 1.22.4
nameOverride: ''
fullnameOverride: ''
hostAliases: []
commonLabels: {}
commonAnnotations: {}
clusterDomain: cluster.local
extraDeploy: []
image:
registry: docker.io
repository: bitnami/keycloak
tag: 15.0.2-debian-10-r19
pullPolicy: IfNotPresent
pullSecrets: []
debug: false
auth:
createAdminUser: true
adminUser: xxxxx-xxxx
adminPassword: ''
managementUser: manager
managementPassword: ''
existingSecret:
name: xx-keycloak
keyMapping:
admin-password: admin-passwd
management-password: management-passwd
existingSecretPerPassword: {}
tls:
enabled: false
autoGenerated: false
existingSecret: ''
truststoreFilename: ''
keystoreFilename: ''
jksSecret: ''
keystorePassword: ''
truststorePassword: ''
resources:
limits: {}
requests: {}
proxyAddressForwarding: true
serviceDiscovery:
enabled: false
protocol: kubernetes.KUBE_PING
properties: []
transportStack: tcp
cache:
ownersCount: 1
authOwnersCount: 1
configuration: ''
existingConfigmap: ''
extraStartupArgs: ''
initdbScripts: {}
initdbScriptsConfigMap: ''
command: []
args: []
extraEnvVars:
- name: TZ
value: Europe/Paris
extraEnvVarsCM: ''
extraEnvVarsSecret: ''
keycloakConfigCli:
enabled: false
image:
registry: docker.io
repository: bitnami/keycloak-config-cli
tag: 4.2.0-debian-10-r29
pullPolicy: IfNotPresent
pullSecrets: []
annotations:
helm.sh/hook: 'post-install,post-upgrade,post-rollback'
helm.sh/hook-delete-policy: 'hook-succeeded,before-hook-creation'
helm.sh/hook-weight: '5'
command: []
args: []
hostAliases: []
resources:
limits: {}
requests: {}
containerSecurityContext:
enabled: true
runAsUser: 1002
runAsNonRoot: true
podSecurityContext:
enabled: true
fsGroup: 1002
backoffLimit: 1
podLabels: {}
podAnnotations: {}
extraEnvVars:
- name: TZ
value: Europe/Paris
extraEnvVarsCM: ''
extraEnvVarsSecret: ''
extraVolumes: []
extraVolumeMounts: []
configuration: {}
existingConfigmap: ''
replicaCount: 1
containerPorts:
http: 8080
https: 8443
podSecurityContext:
enabled: true
fsGroup: 1002
containerSecurityContext:
enabled: true
runAsUser: 1002
runAsNonRoot: true
resources:
limits:
cpu: 1.5
memory: 1536Mi
requests:
cpu: 250m
memory: 256Mi
startupProbe:
enabled: false
httpGet:
path: /auth/
port: http
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 1
failureThreshold: 60
successThreshold: 1
livenessProbe:
enabled: true
httpGet:
path: /auth/
port: http
initialDelaySeconds: 300
periodSeconds: 1
timeoutSeconds: 5
failureThreshold: 3
successThreshold: 1
readinessProbe:
enabled: true
httpGet:
path: /auth/realms/master
port: http
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
successThreshold: 1
customStartupProbe: {}
customLivenessProbe: {}
customReadinessProbe: {}
updateStrategy:
type: RollingUpdate
podAffinityPreset: ''
podAntiAffinityPreset: soft
nodeAffinityPreset:
type: ''
key: ''
values: []
affinity: {}
nodeSelector: {}
tolerations: []
podLabels: {}
podAnnotations: {}
priorityClassName: ''
lifecycleHooks: {}
extraVolumes: []
extraVolumeMounts: []
initContainers: []
sidecars: []
service:
type: ClusterIP
port: 80
httpsPort: 443
nodePorts:
http: ''
https: ''
clusterIP: ''
loadBalancerIP: ''
loadBalancerSourceRanges: []
externalTrafficPolicy: Cluster
annotations: {}
ingress:
enabled: true
certManager: true
hostname: keycloak.demo.xxxxx.com
apiVersion: ''
ingressClassName: ''
path: /
pathType: ImplementationSpecific
annotations:
cert-manager.io/acme-challenge-type: http01
cert-manager.io/cluster-issuer: letsencrypt-prod
kubernetes.io/ingress.class: nginx
tls: true
extraHosts: []
extraTls: []
secrets: []
existingSecret: xx-keycloak-tls
servicePort: http
networkPolicy:
enabled: false
allowExternal: true
additionalRules: {}
serviceAccount:
create: true
name: keycloak-sa
rbac:
create: false
rules: []
pdb:
create: true
minAvailable: 1
maxUnavailable: ''
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 11
targetCPU: ''
targetMemory: ''
metrics:
enabled: true
service:
port: 9990
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '{{ .Values.metrics.service.port }}'
serviceMonitor:
enabled: true
namespace: demo
interval: 30s
scrapeTimeout: 10s
relabellings: []
honorLabels: false
additionalLabels: {}
postgresql:
enabled: false
postgresqlUsername: ''
postgresqlPassword: ''
postgresqlDatabase: ''
existingSecret: ''
securityContext:
enabled: true
fsGroup: 1002
containerSecurityContext:
enabled: true
runAsUser: 1002
resources:
limits:
cpu: 1.5
memory: 1536Mi
requests:
cpu: 250m
memory: 256Mi
audit:
logHostname: true
logConnections: false
logDisconnections: false
pgAuditLog: ''
pgAuditLogCatalog: 'off'
clientMinMessages: error
logLinePrefix: ''
logTimezone: Europe/Paris
persistence:
enabled: true
storageClass: local-path
mountPath: /opt/postgresql/demo
size: 5Gi
externalDatabase:
host: xx-postgresql-pgpool.demo.svc.cluster.local
port: 5432
user: keycloak
password: ''
database: keycloak
existingSecret: xx-keycloak
Postgresql-ha:
global:
imageRegistry: ''
imagePullSecrets: []
storageClass: ''
postgresql:
username: ''
password: ''
database: ''
repmgrUsername: ''
repmgrPassword: ''
repmgrDatabase: ''
existingSecret: ''
ldap:
bindpw: ''
existingSecret: ''
pgpool:
adminUsername: ''
adminPassword: ''
existingSecret: xx-postgresql
nameOverride: ''
fullnameOverride: xx-postgresql
clusterDomain: cluster.local
commonAnnotations: {}
commonLabels: {}
extraDeploy: []
serviceAccount:
enabled: false
name: ''
diagnosticMode:
enabled: false
command:
- sleep
args:
- infinity
postgresqlImage:
registry: docker.io
repository: bitnami/postgresql-repmgr
tag: 11.13.0-debian-10-r33
pullPolicy: IfNotPresent
pullSecrets: []
debug: false
postgresql:
labels: {}
podLabels: {}
replicaCount: 2
updateStrategyType: RollingUpdate
hostAliases: []
podAnnotations:
backup.velero.io/backup-volumes: data
priorityClassName: ''
podAffinityPreset: ''
podAntiAffinityPreset: soft
nodeAffinityPreset:
type: ''
key: ''
values: []
affinity: {}
nodeSelector: {}
tolerations: []
securityContext:
enabled: true
fsGroup: 1002
containerSecurityContext:
enabled: true
runAsUser: 1002
customLivenessProbe: {}
customReadinessProbe: {}
customStartupProbe: {}
command: []
args: []
lifecycleHooks: {}
extraEnvVars:
- name: TZ
value: Europe/Paris
extraEnvVarsCM: ''
extraEnvVarsSecret: ''
extraVolumes: []
extraVolumeMounts: []
initContainers: []
sidecars: []
resources:
limits:
cpu: 1.5
memory: 1536Mi
requests:
cpu: 250m
memory: 256Mi
livenessProbe:
enabled: true
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 6
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 6
startupProbe:
enabled: false
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 10
pdb:
create: true
minAvailable: 1
maxUnavailable: ''
username: postgres
password: ''
database: postgres
existingSecret: xx-postgresql
postgresPassword: ''
usePasswordFile: ''
repmgrUsePassfile: ''
repmgrPassfilePath: ''
upgradeRepmgrExtension: false
pgHbaTrustAll: false
syncReplication: false
repmgrUsername: repmgr
repmgrPassword: ''
repmgrDatabase: repmgr
repmgrLogLevel: NOTICE
repmgrConnectTimeout: 5
repmgrReconnectAttempts: 3
repmgrReconnectInterval: 5
audit:
logHostname: true
logConnections: false
logDisconnections: false
pgAuditLog: ''
pgAuditLogCatalog: 'off'
clientMinMessages: error
logLinePrefix: ''
logTimezone: Europe/Paris
sharedPreloadLibraries: 'pgaudit, repmgr'
maxConnections: ''
postgresConnectionLimit: ''
dbUserConnectionLimit: ''
tcpKeepalivesInterval: ''
tcpKeepalivesIdle: ''
tcpKeepalivesCount: ''
statementTimeout: ''
pghbaRemoveFilters: ''
extraInitContainers: []
repmgrConfiguration: ''
configuration: ''
pgHbaConfiguration: ''
configurationCM: ''
extendedConf: ''
extendedConfCM: ''
initdbScripts: {}
initdbScriptsCM: ''
initdbScriptsSecret: ''
tls:
enabled: false
preferServerCiphers: true
certificatesSecret: ''
certFilename: ''
certKeyFilename: ''
certCAFilename: ''
pgpoolImage:
registry: docker.io
repository: bitnami/pgpool
tag: 4.2.5-debian-10-r1
pullPolicy: IfNotPresent
pullSecrets: []
debug: false
pgpool:
customUsers: null
usernames: ''
passwords: ''
hostAliases: []
customUsersSecret: xx-postgresql
srCheckDatabase: keycloak
labels: {}
podLabels: {}
serviceLabels: {}
customLivenessProbe: {}
customReadinessProbe: {}
customStartupProbe: {}
command: []
args: []
lifecycleHooks: {}
extraEnvVars:
- name: TZ
value: Europe/Paris
extraEnvVarsCM: ''
extraEnvVarsSecret: ''
extraVolumes: []
extraVolumeMounts: []
initContainers: []
sidecars: []
replicaCount: 1
podAnnotations: {}
priorityClassName: ''
podAffinityPreset: ''
podAntiAffinityPreset: soft
nodeAffinityPreset:
type: ''
key: ''
values: []
affinity: {}
nodeSelector: {}
tolerations: []
securityContext:
enabled: true
fsGroup: 1002
containerSecurityContext:
enabled: true
runAsUser: 1002
resources:
limits:
cpu: 1.5
memory: 1536Mi
requests:
cpu: 250m
memory: 256Mi
livenessProbe:
enabled: true
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 5
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
startupProbe:
enabled: false
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 10
pdb:
create: false
minAvailable: 1
maxUnavailable: ''
updateStrategy: {}
minReadySeconds: ''
adminUsername: pgpool
adminPassword: ''
logConnections: false
logHostname: true
logPerNodeStatement: false
logLinePrefix: ''
clientMinMessages: error
numInitChildren: ''
maxPool: ''
childMaxConnections: ''
childLifeTime: ''
clientIdleLimit: ''
connectionLifeTime: ''
useLoadBalancing: true
loadBalancingOnWrite: transaction
configuration: {}
configurationCM: ''
initdbScripts: {}
initdbScriptsCM: ''
initdbScriptsSecret: ''
tls:
enabled: false
autoGenerated: false
preferServerCiphers: true
certificatesSecret: ''
certFilename: ''
certKeyFilename: ''
certCAFilename: ''
ldap:
enabled: false
existingSecret: ''
uri: ''
base: ''
binddn: ''
bindpw: ''
bslookup: ''
scope: ''
tlsReqcert: ''
nssInitgroupsIgnoreusers: 'root,nslcd'
metricsImage:
registry: docker.io
repository: bitnami/postgres-exporter
tag: 0.10.0-debian-10-r61
pullPolicy: IfNotPresent
pullSecrets: []
debug: false
metrics:
enabled: true
securityContext:
enabled: true
runAsUser: 1002
resources:
limits:
cpu: 250m
memory: 256Mi
requests:
cpu: 250m
memory: 256Mi
livenessProbe:
enabled: true
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 6
readinessProbe:
enabled: true
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 6
startupProbe:
enabled: false
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 10
annotations:
prometheus.io/scrape: 'true'
prometheus.io/port: '9187'
customMetrics:
- pg_database:
query: >-
SELECT d.datname AS name, CASE WHEN
pg_catalog.has_database_privilege(d.datname, 'CONNECT') THEN
pg_catalog.pg_database_size(d.datname) ELSE 0 END AS size_bytes FROM
pg_catalog.pg_database d where datname not in ('template0',
'template1', 'postgres')
metrics:
- name:
usage: LABEL
description: Name of the database
- size_bytes:
usage: GAUGE
description: Size of the database in bytes
- pg_replication:
query: >-
SELECT CASE WHEN NOT pg_is_in_recovery() THEN 0 ELSE GREATEST (0,
EXTRACT(EPOCH FROM (now() - pg_last_xact_replay_timestamp()))) END AS
lag
master: true
metrics:
- lag:
usage: GAUGE
description: Replication lag behind master in seconds
- pg_postmaster:
query: >-
SELECT pg_postmaster_start_time as start_time_seconds from
pg_postmaster_start_time()
master: true
metrics:
- start_time_seconds:
usage: GAUGE
description: Time at which postmaster started
extraEnvVars: {}
serviceMonitor:
enabled: true
namespace: demo
interval: 15s
scrapeTimeout: 15s
selector:
prometheus: kube-prometheus
relabelings: []
metricRelabelings: []
volumePermissionsImage:
registry: docker.io
repository: bitnami/bitnami-shell
tag: 10-debian-10-r193
pullPolicy: Always
pullSecrets: []
volumePermissions:
enabled: true
securityContext:
runAsUser: 0
resources:
limits:
cpu: 100m
memory: 128Mi
requests:
cpu: 100m
memory: 128Mi
persistence:
enabled: true
existingClaim: ''
storageClass: local-storage
mountPath: /opt/postgresql/demo
accessModes:
- ReadWriteOnce
size: 5Gi
annotations: {}
selector: {}
service:
type: ClusterIP
port: 5432
nodePort: ''
loadBalancerIP: ''
loadBalancerSourceRanges: []
clusterIP: ''
externalTrafficPolicy: Cluster
sessionAffinity: None
annotations: {}
serviceLabels: {}
networkPolicy:
enabled: false
allowExternal: true
Hi,
Could you show the PostgreSQL env vars that Keycloak is configured with (you can get them with kubectl get pods -o yaml? It seems to me that it is trying to access an incorrect service name.
Hi @javsalgar
Thanks for your response, sorry it was my bad, I used externalDatabase.existingSecret which did not contain the values for KEYCLOAK_DATABASE_* variables, but I am not sur if the if condition below should be set
configmap-env-vars.yaml:
{{- if (not .Values.externalDatabase.existingSecret) }}
KEYCLOAK_DATABASE_HOST: {{ include "keycloak.databaseHost" . | quote }}
KEYCLOAK_DATABASE_PORT: {{ include "keycloak.databasePort" . }}
KEYCLOAK_DATABASE_NAME: {{ include "keycloak.databaseName" . | quote }}
KEYCLOAK_DATABASE_USER: {{ include "keycloak.databaseUser" . | quote }}
{{- end }}
Hi @fayssaldarif.
I am not sure if the if condition below should be set
Could you explain this a little more?
Hi @Mauraza
I don't realy understand why there's a condition if here, I think even if the externalDatabase.existingSecret is set, these variables should be added to the configmap.
Sorry, I am not good with go template language used in helm charts, maybe need to learn that first, do not hesitate if you have a links resources for this, please.
Feel free to close the issue if you want.
Thanks.
Hi @fayssaldarif,
I don't really understand why there's a condition if here, I think even if the externalDatabase.existingSecret is set, these variables should be added to the configmap.
The only set if not exist externalDatabase.existingSecret
Closing this out now, do not hesitate to write us back if you have any other questions.
Hello @Mauraza . I am stuck with the same issue as witnessed by @fayssaldarif . The externalDatabase.existingSecret refers to the secret containing postgresql credentials (e.g. with keys like postgresql-password, postgresql-postgres-password), not any other keys like host, post, user, database etc.
In the following template, the KEYCLOAK_DATABASE_* env vars are filled from the keycloak.* templates, defined in _helpers.tpl
configmap-env-vars.yaml:
{{- if (not .Values.externalDatabase.existingSecret) }}
KEYCLOAK_DATABASE_HOST: {{ include "keycloak.databaseHost" . | quote }}
KEYCLOAK_DATABASE_PORT: {{ include "keycloak.databasePort" . }}
KEYCLOAK_DATABASE_NAME: {{ include "keycloak.databaseName" . | quote }}
KEYCLOAK_DATABASE_USER: {{ include "keycloak.databaseUser" . | quote }}
{{- end }}
These are the corresponding template definitions in _helpers.tpl. None of them depends on the .Values.externalDatbase.existingSecret, meaning it does not expect any such fields in the secret. Still, the configmap-env-vars.yaml snapshot pasted above has a condition where the existence of secret prevents the env vars from being created.
_helpers.tpl:
{{/*
Return the Database hostname
*/}}
{{- define "keycloak.databaseHost" -}}
{{- if .Values.postgresql.enabled }}
{{- printf "%s" (include "keycloak.postgresql.fullname" .) -}}
{{- else -}}
{{- printf "%s" .Values.externalDatabase.host -}}
{{- end -}}
{{- end -}}
{{/*
Return the Database port
*/}}
{{- define "keycloak.databasePort" -}}
{{- if .Values.postgresql.enabled }}
{{- printf "5432" | quote -}}
{{- else -}}
{{- .Values.externalDatabase.port | quote -}}
{{- end -}}
{{- end -}}
{{/*
Return the Database database name
*/}}
{{- define "keycloak.databaseName" -}}
{{- if .Values.postgresql.enabled }}
{{- printf "%s" .Values.postgresql.postgresqlDatabase -}}
{{- else -}}
{{- printf "%s" .Values.externalDatabase.database -}}
{{- end -}}
{{- end -}}
{{/*
Return the Database user
*/}}
{{- define "keycloak.databaseUser" -}}
{{- if .Values.postgresql.enabled }}
{{- printf "%s" .Values.postgresql.postgresqlUsername -}}
{{- else -}}
{{- printf "%s" .Values.externalDatabase.user -}}
{{- end -}}
{{- end -}}
Hi @tapanhalani,
if you use an externalDatabase with an externalDatabase.existingSecret the values of the host, port, user are given in values
https://github.com/bitnami/charts/tree/master/bitnami/keycloak#database-parameters
Here you can see that appear in values.yaml
https://github.com/bitnami/charts/blob/c2de8c8b9a1e1bb4acd3217d200f78be1daf9f36/bitnami/keycloak/values.yaml#L923-L941
@Mauraza This is the expected result. However, with keycloak helm chart (v6.0.0), it's not happening like this. Please see the following files and snapshots:
(1.) Here is the excerpt of my values.yaml :
externalDatabase:
database: bitnami_keycloak
existingSecret: keycloak-pg-postgresql-credentials
host: keycloak-pg-postgresql.data-stores.svc.cluster.local
password: ""
port: 5432
user: bn_keycloak
(2.) Here is the relevant section of keycloak pod's live yaml that helm installed (found using kubectl get pod keycloak-0 -o=yaml) :
ports:
- name: http
containerPort: 8080
protocol: TCP
- name: https
containerPort: 8443
protocol: TCP
- name: http-management
containerPort: 9990
protocol: TCP
envFrom:
- configMapRef:
name: keycloak-env-vars
- secretRef:
name: keycloak-pg-postgresql-credentials
env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: BITNAMI_DEBUG
value: 'false'
- name: KEYCLOAK_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-credentials
key: admin-password
- name: KEYCLOAK_MANAGEMENT_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-credentials
key: management-password
- name: KEYCLOAK_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-pg-postgresql-credentials
key: postgresql-password
- name: KEYCLOAK_EXTRA_ARGS
value: >-
-Dkeycloak.frontendUrl=https://admin.keycloak-test-02.myorg.com/auth
-Dkeycloak.profile.feature.scripts=enabled
-Dkeycloak.profile.feature.upload_scripts=enabled
(3.) This is the data from the keycloack-env-vars configmap generated from the chart:
kind: ConfigMap
apiVersion: v1
metadata:
name: keycloak-env-vars
labels:
app.kubernetes.io/component: keycloak
app.kubernetes.io/instance: keycloak
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak
helm.sh/chart: keycloak-6.0.0
annotations:
meta.helm.sh/release-name: keycloak
meta.helm.sh/release-namespace: data-stores
data:
KEYCLOAK_ADMIN_USER: admin
KEYCLOAK_AUTH_CACHE_OWNERS_COUNT: '1'
KEYCLOAK_CACHE_OWNERS_COUNT: '1'
KEYCLOAK_CREATE_ADMIN_USER: 'true'
KEYCLOAK_ENABLE_STATISTICS: 'false'
KEYCLOAK_ENABLE_TLS: 'true'
KEYCLOAK_HTTPS_PORT: '8443'
KEYCLOAK_HTTP_PORT: '8080'
KEYCLOAK_MANAGEMENT_USER: manager
KEYCLOAK_PROXY_ADDRESS_FORWARDING: 'true'
KEYCLOAK_TLS_CA_CERT_FILE: /opt/bitnami/keycloak/certs/ca.crt
KEYCLOAK_TLS_CREATE_KEYSTORE: 'true'
KEYCLOAK_TLS_KEYSTORE_FILE: /opt/bitnami/keycloak/certs/keycloak.keystore.jks
KEYCLOAK_TLS_NODE_CERT_FILE: /opt/bitnami/keycloak/certs/keycloak.crt
KEYCLOAK_TLS_NODE_KEY_FILE: /opt/bitnami/keycloak/certs/keycloak.key
KEYCLOAK_TLS_TRUSTSTORE_FILE: /opt/bitnami/keycloak/certs/keycloak.truststore.jks
As you can see, having externalDatabase.existingSecret removes the KEYCLOAK_DATABASE_{HOST, PORT, NAME, USER} from the configmap, and hence from the pod spec.
Contrary to this, if I remove externalDatabase.existingSecret, and provide the DB password with externalDatabase.password as follows, then the following are the outputs:
(1.) Excerpt of my new values.yaml:
externalDatabase:
database: bitnami_keycloak
host: keycloak-pg-postgresql.data-stores.svc.cluster.local
password: BB4OnrSMAC0e73ZK
port: 5432
user: bn_keycloak
(2.) Live keycloak pod's yaml:
ports:
- name: http
containerPort: 8080
protocol: TCP
- name: https
containerPort: 8443
protocol: TCP
- name: http-management
containerPort: 9990
protocol: TCP
envFrom:
- configMapRef:
name: keycloak-env-vars
env:
- name: KUBERNETES_NAMESPACE
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
- name: BITNAMI_DEBUG
value: 'false'
- name: KEYCLOAK_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-credentials
key: admin-password
- name: KEYCLOAK_MANAGEMENT_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-credentials
key: management-password
- name: KEYCLOAK_DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: keycloak-credentials
key: postgresql-password
- name: KEYCLOAK_EXTRA_ARGS
value: >-
-Dkeycloak.frontendUrl=https://admin.keycloak-test-02.myorg.com/auth
-Dkeycloak.profile.feature.scripts=enabled
-Dkeycloak.profile.feature.upload_scripts=enabled
(3.) Data from keycloak-env-vars configmap generated from the chart:
kind: ConfigMap
apiVersion: v1
metadata:
name: keycloak-env-vars
labels:
app.kubernetes.io/component: keycloak
app.kubernetes.io/instance: keycloak
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: keycloak
helm.sh/chart: keycloak-6.0.0
annotations:
meta.helm.sh/release-name: keycloak
meta.helm.sh/release-namespace: data-stores
data:
KEYCLOAK_ADMIN_USER: admin
KEYCLOAK_AUTH_CACHE_OWNERS_COUNT: '1'
KEYCLOAK_CACHE_OWNERS_COUNT: '1'
KEYCLOAK_CREATE_ADMIN_USER: 'true'
KEYCLOAK_DATABASE_HOST: keycloak-pg-postgresql.data-stores.svc.cluster.local
KEYCLOAK_DATABASE_NAME: bitnami_keycloak
KEYCLOAK_DATABASE_PORT: '5432'
KEYCLOAK_DATABASE_USER: bn_keycloak
KEYCLOAK_ENABLE_STATISTICS: 'false'
KEYCLOAK_ENABLE_TLS: 'true'
KEYCLOAK_HTTPS_PORT: '8443'
KEYCLOAK_HTTP_PORT: '8080'
KEYCLOAK_MANAGEMENT_USER: manager
KEYCLOAK_PROXY_ADDRESS_FORWARDING: 'true'
KEYCLOAK_TLS_CA_CERT_FILE: /opt/bitnami/keycloak/certs/ca.crt
KEYCLOAK_TLS_CREATE_KEYSTORE: 'true'
KEYCLOAK_TLS_KEYSTORE_FILE: /opt/bitnami/keycloak/certs/keycloak.keystore.jks
KEYCLOAK_TLS_NODE_CERT_FILE: /opt/bitnami/keycloak/certs/keycloak.crt
KEYCLOAK_TLS_NODE_KEY_FILE: /opt/bitnami/keycloak/certs/keycloak.key
KEYCLOAK_TLS_TRUSTSTORE_FILE: /opt/bitnami/keycloak/certs/keycloak.truststore.jks
Hi @tapanhalani,
if you check this PR https://github.com/bitnami/charts/pull/5844 where the externalDatabase was added it was implemented that way. I see that it does not appear in the configMap but I do not see the problem.