diff --git a/bitnami/keycloak/CHANGELOG.md b/bitnami/keycloak/CHANGELOG.md
index 250ee57859a4f9..f96a0b82040c44 100644
--- a/bitnami/keycloak/CHANGELOG.md
+++ b/bitnami/keycloak/CHANGELOG.md
@@ -1,8 +1,12 @@
# Changelog
-## 22.1.3 (2024-08-22)
+## 22.2.0 (2024-08-25)
-* [bitnami/keycloak] Release 22.1.3 ([#28984](https://github.com/bitnami/charts/pull/28984))
+* [bitnami/keycloak] Use database user secret key from PostgreSQL chart ([#29008](https://github.com/bitnami/charts/pull/29008))
+
+## 22.1.3 (2024-08-22)
+
+* [bitnami/keycloak] Release 22.1.3 (#28984) ([bb21c84](https://github.com/bitnami/charts/commit/bb21c84c422bdef42fad01db0252798d33e3499d)), closes [#28984](https://github.com/bitnami/charts/issues/28984)
## 22.1.2 (2024-08-19)
diff --git a/bitnami/keycloak/Chart.yaml b/bitnami/keycloak/Chart.yaml
index 7397b2ea0abd88..e8f1c8e04bd2f5 100644
--- a/bitnami/keycloak/Chart.yaml
+++ b/bitnami/keycloak/Chart.yaml
@@ -33,4 +33,4 @@ maintainers:
name: keycloak
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/keycloak
-version: 22.1.3
+version: 22.2.0
diff --git a/bitnami/keycloak/README.md b/bitnami/keycloak/README.md
index ce96b2eb2d7019..30046a0546bb03 100644
--- a/bitnami/keycloak/README.md
+++ b/bitnami/keycloak/README.md
@@ -622,6 +622,7 @@ As an alternative, you can use of the preset configurations for pod affinity, po
| `postgresql.auth.password` | Password for the custom user to create | `""` |
| `postgresql.auth.database` | Name for a custom database to create | `bitnami_keycloak` |
| `postgresql.auth.existingSecret` | Name of existing secret to use for PostgreSQL credentials | `""` |
+| `postgresql.auth.secretKeys.userPasswordKey` | Name of key in existing secret to use for PostgreSQL credentials. Only used when `auth.existingSecret` is set. | `password` |
| `postgresql.architecture` | PostgreSQL architecture (`standalone` or `replication`) | `standalone` |
| `externalDatabase.host` | Database host | `""` |
| `externalDatabase.port` | Database port number | `5432` |
diff --git a/bitnami/keycloak/templates/_helpers.tpl b/bitnami/keycloak/templates/_helpers.tpl
index 21ec078e31af4c..5f56e70530a92b 100644
--- a/bitnami/keycloak/templates/_helpers.tpl
+++ b/bitnami/keycloak/templates/_helpers.tpl
@@ -177,7 +177,7 @@ Add environment variables to configure database values
*/}}
{{- define "keycloak.databaseSecretPasswordKey" -}}
{{- if .Values.postgresql.enabled -}}
- {{- print "password" -}}
+ {{- printf "%s" (.Values.postgresql.auth.secretKeys.userPasswordKey | default "password") -}}
{{- else -}}
{{- if .Values.externalDatabase.existingSecret -}}
{{- if .Values.externalDatabase.existingSecretPasswordKey -}}
diff --git a/bitnami/keycloak/values.yaml b/bitnami/keycloak/values.yaml
index 369f1a28efed7d..3c643c5e3deaa9 100644
--- a/bitnami/keycloak/values.yaml
+++ b/bitnami/keycloak/values.yaml
@@ -1301,6 +1301,7 @@ keycloakConfigCli:
## @param postgresql.auth.password Password for the custom user to create
## @param postgresql.auth.database Name for a custom database to create
## @param postgresql.auth.existingSecret Name of existing secret to use for PostgreSQL credentials
+## @param postgresql.auth.secretKeys.userPasswordKey Name of key in existing secret to use for PostgreSQL credentials. Only used when `auth.existingSecret` is set.
## @param postgresql.architecture PostgreSQL architecture (`standalone` or `replication`)
##
postgresql:
@@ -1311,6 +1312,8 @@ postgresql:
password: ""
database: bitnami_keycloak
existingSecret: ""
+ secretKeys:
+ userPasswordKey: password
architecture: standalone
## External PostgreSQL configuration
## All of these values are only used when postgresql.enabled is set to false