diff --git a/.charts.yml b/.charts.yml index 6f811b33..26458487 100644 --- a/.charts.yml +++ b/.charts.yml @@ -111,7 +111,7 @@ charts: - 925931 - 955851 - name: keycloak - version: 21.4.1 + version: 22.2.3 repository: url: https://charts.bitnami.com/bitnami - name: keystone diff --git a/charts/keycloak/Chart.lock b/charts/keycloak/Chart.lock index 0956d9dd..364f76f7 100644 --- a/charts/keycloak/Chart.lock +++ b/charts/keycloak/Chart.lock @@ -1,9 +1,9 @@ dependencies: - name: postgresql repository: oci://registry-1.docker.io/bitnamicharts - version: 15.5.2 + version: 15.5.28 - name: common repository: oci://registry-1.docker.io/bitnamicharts - version: 2.20.0 -digest: sha256:8a4794e558a871e8959eb06c8563f52a74a8c6d2f712087934129b114f4cae7e -generated: "2024-06-06T15:08:05.746226451Z" + version: 2.22.0 +digest: sha256:02cd6a7741417e5dba22e6c4254f1b6fe57d6602ee33846152a0420db376a245 +generated: "2024-09-10T07:48:14.621920026Z" diff --git a/charts/keycloak/Chart.yaml b/charts/keycloak/Chart.yaml index ee9c4580..fd78cf77 100644 --- a/charts/keycloak/Chart.yaml +++ b/charts/keycloak/Chart.yaml @@ -2,12 +2,12 @@ annotations: category: DeveloperTools images: | - name: keycloak - image: docker.io/bitnami/keycloak:24.0.5-debian-12-r0 + image: docker.io/bitnami/keycloak:25.0.5-debian-12-r0 - name: keycloak-config-cli - image: docker.io/bitnami/keycloak-config-cli:5.12.0-debian-12-r5 + image: docker.io/bitnami/keycloak-config-cli:6.1.6-debian-12-r3 licenses: Apache-2.0 apiVersion: v2 -appVersion: 24.0.5 +appVersion: 25.0.5 dependencies: - condition: postgresql.enabled name: postgresql @@ -32,4 +32,4 @@ maintainers: name: keycloak sources: - https://github.com/bitnami/charts/tree/main/bitnami/keycloak -version: 21.4.1 +version: 22.2.3 diff --git a/charts/keycloak/README.md b/charts/keycloak/README.md index 50f57fcf..30046a05 100644 --- a/charts/keycloak/README.md +++ b/charts/keycloak/README.md @@ -14,7 +14,7 @@ Trademarks: This software listing is packaged by Bitnami. The respective tradema helm install my-release oci://registry-1.docker.io/bitnamicharts/keycloak ``` -Looking to use Keycloak in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the enterprise edition of Bitnami Application Catalog. +Looking to use Keycloak in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the commercial edition of the Bitnami catalog. ## Introduction @@ -122,7 +122,7 @@ keycloak: Then open a terminal in the running keycloak container and run: ```bash -kc.sh export --dir /export/ --users realm_file +kc.sh export --dir /export/ --users realm_file ```` This will export the all the realms with users to the `/export` folder. @@ -143,7 +143,7 @@ Adding the TLS parameter (where available) will cause the chart to generate HTTP ### Configure admin Ingress -In addition to the Ingress resource described above, this chart also provides the ability to define an Ingress for the admin area of Keycloak, for example the `master` realm. +In addition to the Ingress resource described above, this chart also provides the ability to define an Ingress for the admin area of Keycloak, for example the `master` realm. For this scenario, you can use the Keycloak Config CLI integration with the following values, where `keycloak-admin.example.com` is to be replaced by the actual hostname: @@ -298,7 +298,8 @@ As an alternative, you can use of the preset configurations for pod affinity, po | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | | `global.imageRegistry` | Global Docker image registry | `""` | | `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` | -| `global.storageClass` | Global StorageClass for Persistent Volume(s) | `""` | +| `global.defaultStorageClass` | Global default StorageClass for Persistent Volume(s) | `""` | +| `global.storageClass` | DEPRECATED: use global.defaultStorageClass instead | `""` | | `global.compatibility.openshift.adaptSecurityContext` | Adapt the securityContext sections of the deployment to make them compatible with Openshift restricted-v2 SCC: remove runAsUser, runAsGroup and fsGroup and let the platform use their allowed default IDs. Possible values: auto (apply if the detected running cluster is Openshift), force (perform the adaptation always), disabled (do not perform adaptation) | `auto` | ### Common parameters @@ -322,47 +323,50 @@ As an alternative, you can use of the preset configurations for pod affinity, po ### Keycloak parameters -| Name | Description | Value | -| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | -| `image.registry` | Keycloak image registry | `REGISTRY_NAME` | -| `image.repository` | Keycloak image repository | `REPOSITORY_NAME/keycloak` | -| `image.digest` | Keycloak image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag | `""` | -| `image.pullPolicy` | Keycloak image pull policy | `IfNotPresent` | -| `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` | -| `image.debug` | Specify if debug logs should be enabled | `false` | -| `auth.adminUser` | Keycloak administrator user | `user` | -| `auth.adminPassword` | Keycloak administrator password for the new user | `""` | -| `auth.existingSecret` | Existing secret containing Keycloak admin password | `""` | -| `auth.passwordSecretKey` | Key where the Keycloak admin password is being stored inside the existing secret. | `""` | -| `auth.annotations` | Additional custom annotations for Keycloak auth secret object | `{}` | -| `tls.enabled` | Enable TLS encryption. Required for HTTPs traffic. | `false` | -| `tls.autoGenerated` | Generate automatically self-signed TLS certificates. Currently only supports PEM certificates | `false` | -| `tls.existingSecret` | Existing secret containing the TLS certificates per Keycloak replica | `""` | -| `tls.usePem` | Use PEM certificates as input instead of PKS12/JKS stores | `false` | -| `tls.truststoreFilename` | Truststore filename inside the existing secret | `keycloak.truststore.jks` | -| `tls.keystoreFilename` | Keystore filename inside the existing secret | `keycloak.keystore.jks` | -| `tls.keystorePassword` | Password to access the keystore when it's password-protected | `""` | -| `tls.truststorePassword` | Password to access the truststore when it's password-protected | `""` | -| `tls.passwordsSecret` | Secret containing the Keystore and Truststore passwords. | `""` | -| `spi.existingSecret` | Existing secret containing the Keycloak truststore for SPI connection over HTTPS/TLS | `""` | -| `spi.truststorePassword` | Password to access the truststore when it's password-protected | `""` | -| `spi.truststoreFilename` | Truststore filename inside the existing secret | `keycloak-spi.truststore.jks` | -| `spi.passwordsSecret` | Secret containing the SPI Truststore passwords. | `""` | -| `spi.hostnameVerificationPolicy` | Verify the hostname of the server's certificate. Allowed values: "ANY", "WILDCARD", "STRICT". | `""` | -| `production` | Run Keycloak in production mode. TLS configuration is required except when using proxy=edge. | `false` | -| `proxy` | reverse Proxy mode edge, reencrypt, passthrough or none | `passthrough` | -| `httpRelativePath` | Set the path relative to '/' for serving resources. Useful if you are migrating from older version which were using '/auth/' | `/` | -| `configuration` | Keycloak Configuration. Auto-generated based on other parameters when not specified | `""` | -| `existingConfigmap` | Name of existing ConfigMap with Keycloak configuration | `""` | -| `extraStartupArgs` | Extra default startup args | `""` | -| `enableDefaultInitContainers` | Deploy default init containers | `true` | -| `initdbScripts` | Dictionary of initdb scripts | `{}` | -| `initdbScriptsConfigMap` | ConfigMap with the initdb scripts (Note: Overrides `initdbScripts`) | `""` | -| `command` | Override default container command (useful when using custom images) | `[]` | -| `args` | Override default container args (useful when using custom images) | `[]` | -| `extraEnvVars` | Extra environment variables to be set on Keycloak container | `[]` | -| `extraEnvVarsCM` | Name of existing ConfigMap containing extra env vars | `""` | -| `extraEnvVarsSecret` | Name of existing Secret containing extra env vars | `""` | +| Name | Description | Value | +| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------- | +| `image.registry` | Keycloak image registry | `REGISTRY_NAME` | +| `image.repository` | Keycloak image repository | `REPOSITORY_NAME/keycloak` | +| `image.digest` | Keycloak image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag | `""` | +| `image.pullPolicy` | Keycloak image pull policy | `IfNotPresent` | +| `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` | +| `image.debug` | Specify if debug logs should be enabled | `false` | +| `auth.adminUser` | Keycloak administrator user | `user` | +| `auth.adminPassword` | Keycloak administrator password for the new user | `""` | +| `auth.existingSecret` | Existing secret containing Keycloak admin password | `""` | +| `auth.passwordSecretKey` | Key where the Keycloak admin password is being stored inside the existing secret. | `""` | +| `auth.annotations` | Additional custom annotations for Keycloak auth secret object | `{}` | +| `customCaExistingSecret` | Name of the secret containing the Keycloak custom CA certificates. The secret will be mounted as a directory and configured using KC_TRUSTSTORE_PATHS. | `""` | +| `tls.enabled` | Enable TLS encryption. Required for HTTPs traffic. | `false` | +| `tls.autoGenerated` | Generate automatically self-signed TLS certificates. Currently only supports PEM certificates | `false` | +| `tls.existingSecret` | Existing secret containing the TLS certificates per Keycloak replica | `""` | +| `tls.usePem` | Use PEM certificates as input instead of PKS12/JKS stores | `false` | +| `tls.truststoreFilename` | Truststore filename inside the existing secret | `keycloak.truststore.jks` | +| `tls.keystoreFilename` | Keystore filename inside the existing secret | `keycloak.keystore.jks` | +| `tls.keystorePassword` | Password to access the keystore when it's password-protected | `""` | +| `tls.truststorePassword` | Password to access the truststore when it's password-protected | `""` | +| `tls.passwordsSecret` | Secret containing the Keystore and Truststore passwords. | `""` | +| `spi.existingSecret` | Existing secret containing the Keycloak truststore for SPI connection over HTTPS/TLS | `""` | +| `spi.truststorePassword` | Password to access the truststore when it's password-protected | `""` | +| `spi.truststoreFilename` | Truststore filename inside the existing secret | `keycloak-spi.truststore.jks` | +| `spi.passwordsSecret` | Secret containing the SPI Truststore passwords. | `""` | +| `spi.hostnameVerificationPolicy` | Verify the hostname of the server's certificate. Allowed values: "ANY", "WILDCARD", "STRICT". | `""` | +| `adminRealm` | Name of the admin realm | `master` | +| `production` | Run Keycloak in production mode. TLS configuration is required except when using proxy=edge. | `false` | +| `proxyHeaders` | Set Keycloak proxy headers | `""` | +| `proxy` | reverse Proxy mode edge, reencrypt, passthrough or none | `""` | +| `httpRelativePath` | Set the path relative to '/' for serving resources. Useful if you are migrating from older version which were using '/auth/' | `/` | +| `configuration` | Keycloak Configuration. Auto-generated based on other parameters when not specified | `""` | +| `existingConfigmap` | Name of existing ConfigMap with Keycloak configuration | `""` | +| `extraStartupArgs` | Extra default startup args | `""` | +| `enableDefaultInitContainers` | Deploy default init containers | `true` | +| `initdbScripts` | Dictionary of initdb scripts | `{}` | +| `initdbScriptsConfigMap` | ConfigMap with the initdb scripts (Note: Overrides `initdbScripts`) | `""` | +| `command` | Override default container command (useful when using custom images) | `[]` | +| `args` | Override default container args (useful when using custom images) | `[]` | +| `extraEnvVars` | Extra environment variables to be set on Keycloak container | `[]` | +| `extraEnvVarsCM` | Name of existing ConfigMap containing extra env vars | `""` | +| `extraEnvVarsSecret` | Name of existing Secret containing extra env vars | `""` | ### Keycloak statefulset parameters @@ -432,6 +436,7 @@ As an alternative, you can use of the preset configurations for pod affinity, po | `terminationGracePeriodSeconds` | Seconds Keycloak pod needs to terminate gracefully | `""` | | `updateStrategy.type` | Keycloak statefulset strategy type | `RollingUpdate` | | `updateStrategy.rollingUpdate` | Keycloak statefulset rolling update configuration parameters | `{}` | +| `minReadySeconds` | How many seconds a pod needs to be ready before killing the next, during update | `0` | | `extraVolumes` | Optionally specify extra list of additional volumes for Keycloak pods | `[]` | | `extraVolumeMounts` | Optionally specify extra list of additional volumeMounts for Keycloak container(s) | `[]` | | `initContainers` | Add additional init containers to the Keycloak pods | `[]` | @@ -461,7 +466,9 @@ As an alternative, you can use of the preset configurations for pod affinity, po | `ingress.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | | `ingress.pathType` | Ingress path type | `ImplementationSpecific` | | `ingress.apiVersion` | Force Ingress API version (automatically detected if not set) | `""` | +| `ingress.controller` | The ingress controller type. Currently supports `default` and `gce` | `default` | | `ingress.hostname` | Default host for the ingress record (evaluated as template) | `keycloak.local` | +| `ingress.hostnameStrict` | Disables dynamically resolving the hostname from request headers. | `false` | | `ingress.path` | Default path for the ingress record (evaluated as template) | `""` | | `ingress.servicePort` | Backend service port to use | `http` | | `ingress.annotations` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. | `{}` | @@ -477,6 +484,7 @@ As an alternative, you can use of the preset configurations for pod affinity, po | `adminIngress.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | | `adminIngress.pathType` | Ingress path type | `ImplementationSpecific` | | `adminIngress.apiVersion` | Force Ingress API version (automatically detected if not set) | `""` | +| `adminIngress.controller` | The ingress controller type. Currently supports `default` and `gce` | `default` | | `adminIngress.hostname` | Default host for the admin ingress record (evaluated as template) | `keycloak.local` | | `adminIngress.path` | Default path for the admin ingress record (evaluated as template) | `""` | | `adminIngress.servicePort` | Backend service port to use | `http` | @@ -614,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/charts/keycloak/charts/common/Chart.yaml b/charts/keycloak/charts/common/Chart.yaml index 53ef33a0..0c8fdb52 100644 --- a/charts/keycloak/charts/common/Chart.yaml +++ b/charts/keycloak/charts/common/Chart.yaml @@ -2,7 +2,7 @@ annotations: category: Infrastructure licenses: Apache-2.0 apiVersion: v2 -appVersion: 2.20.0 +appVersion: 2.22.0 description: A Library Helm Chart for grouping common logic between bitnami charts. This chart is not deployable by itself. home: https://bitnami.com @@ -20,4 +20,4 @@ name: common sources: - https://github.com/bitnami/charts/tree/main/bitnami/common type: library -version: 2.20.0 +version: 2.22.0 diff --git a/charts/keycloak/charts/common/README.md b/charts/keycloak/charts/common/README.md index 82d78a38..fee26c99 100644 --- a/charts/keycloak/charts/common/README.md +++ b/charts/keycloak/charts/common/README.md @@ -24,7 +24,7 @@ data: myvalue: "Hello World" ``` -Looking to use our applications in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the enterprise edition of Bitnami Application Catalog. +Looking to use our applications in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the commercial edition of the Bitnami catalog. ## Introduction diff --git a/charts/keycloak/charts/common/templates/_compatibility.tpl b/charts/keycloak/charts/common/templates/_compatibility.tpl index 538b3a3c..eb4061d7 100644 --- a/charts/keycloak/charts/common/templates/_compatibility.tpl +++ b/charts/keycloak/charts/common/templates/_compatibility.tpl @@ -34,5 +34,9 @@ Usage: {{- end -}} {{- end -}} {{- end -}} +{{/* Remove fields that are disregarded when running the container in privileged mode */}} +{{- if $adaptedContext.privileged -}} + {{- $adaptedContext = omit $adaptedContext "capabilities" "seLinuxOptions" -}} +{{- end -}} {{- omit $adaptedContext "enabled" | toYaml -}} {{- end -}} diff --git a/charts/keycloak/charts/common/templates/_images.tpl b/charts/keycloak/charts/common/templates/_images.tpl index 67df9236..76bb7ce4 100644 --- a/charts/keycloak/charts/common/templates/_images.tpl +++ b/charts/keycloak/charts/common/templates/_images.tpl @@ -5,8 +5,9 @@ SPDX-License-Identifier: APACHE-2.0 {{/* vim: set filetype=mustache: */}} {{/* -Return the proper image name -{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }} +Return the proper image name. +If image tag and digest are not defined, termination fallbacks to chart appVersion. +{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global "chart" .Chart ) }} */}} {{- define "common.images.image" -}} {{- $registryName := default .imageRoot.registry ((.global).imageRegistry) -}} @@ -14,6 +15,11 @@ Return the proper image name {{- $separator := ":" -}} {{- $termination := .imageRoot.tag | toString -}} +{{- if not .imageRoot.tag }} + {{- if .chart }} + {{- $termination = .chart.AppVersion | toString -}} + {{- end -}} +{{- end -}} {{- if .imageRoot.digest }} {{- $separator = "@" -}} {{- $termination = .imageRoot.digest | toString -}} @@ -50,7 +56,7 @@ Return the proper Docker Image Registry Secret Names (deprecated: use common.ima {{- end -}} {{- end -}} - {{- if (not (empty $pullSecrets)) }} + {{- if (not (empty $pullSecrets)) -}} imagePullSecrets: {{- range $pullSecrets | uniq }} - name: {{ . }} @@ -84,7 +90,7 @@ Return the proper Docker Image Registry Secret Names evaluating values as templa {{- end -}} {{- end -}} - {{- if (not (empty $pullSecrets)) }} + {{- if (not (empty $pullSecrets)) -}} imagePullSecrets: {{- range $pullSecrets | uniq }} - name: {{ . }} diff --git a/charts/keycloak/charts/common/templates/_resources.tpl b/charts/keycloak/charts/common/templates/_resources.tpl index a4f53c2e..d8a43e1c 100644 --- a/charts/keycloak/charts/common/templates/_resources.tpl +++ b/charts/keycloak/charts/common/templates/_resources.tpl @@ -15,31 +15,31 @@ These presets are for basic testing and not meant to be used in production {{- $presets := dict "nano" (dict "requests" (dict "cpu" "100m" "memory" "128Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "150m" "memory" "192Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "150m" "memory" "192Mi" "ephemeral-storage" "2Gi") ) "micro" (dict "requests" (dict "cpu" "250m" "memory" "256Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "375m" "memory" "384Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "375m" "memory" "384Mi" "ephemeral-storage" "2Gi") ) "small" (dict "requests" (dict "cpu" "500m" "memory" "512Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "750m" "memory" "768Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "750m" "memory" "768Mi" "ephemeral-storage" "2Gi") ) "medium" (dict "requests" (dict "cpu" "500m" "memory" "1024Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "750m" "memory" "1536Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "750m" "memory" "1536Mi" "ephemeral-storage" "2Gi") ) "large" (dict "requests" (dict "cpu" "1.0" "memory" "2048Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "1.5" "memory" "3072Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "1.5" "memory" "3072Mi" "ephemeral-storage" "2Gi") ) "xlarge" (dict - "requests" (dict "cpu" "1.5" "memory" "4096Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "3.0" "memory" "6144Mi" "ephemeral-storage" "1024Mi") + "requests" (dict "cpu" "1.0" "memory" "3072Mi" "ephemeral-storage" "50Mi") + "limits" (dict "cpu" "3.0" "memory" "6144Mi" "ephemeral-storage" "2Gi") ) "2xlarge" (dict - "requests" (dict "cpu" "1.5" "memory" "4096Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "6.0" "memory" "12288Mi" "ephemeral-storage" "1024Mi") + "requests" (dict "cpu" "1.0" "memory" "3072Mi" "ephemeral-storage" "50Mi") + "limits" (dict "cpu" "6.0" "memory" "12288Mi" "ephemeral-storage" "2Gi") ) }} {{- if hasKey $presets .type -}} diff --git a/charts/keycloak/charts/common/templates/_secrets.tpl b/charts/keycloak/charts/common/templates/_secrets.tpl index e87575a8..801918ce 100644 --- a/charts/keycloak/charts/common/templates/_secrets.tpl +++ b/charts/keycloak/charts/common/templates/_secrets.tpl @@ -103,30 +103,33 @@ The order in which this function returns a secret password: {{- $password = index $secretData .key | b64dec }} {{- else if not (eq .failOnNew false) }} {{- printf "\nPASSWORDS ERROR: The secret \"%s\" does not contain the key \"%s\"\n" .secret .key | fail -}} - {{- else if $providedPasswordValue }} + {{- end -}} +{{- end }} + +{{- if not $password }} + {{- if $providedPasswordValue }} {{- $password = $providedPasswordValue | toString }} - {{- end -}} -{{- else if $providedPasswordValue }} - {{- $password = $providedPasswordValue | toString }} -{{- else }} - - {{- if .context.Values.enabled }} - {{- $subchart = $chartName }} - {{- end -}} - - {{- $requiredPassword := dict "valueKey" $providedPasswordKey "secret" .secret "field" .key "subchart" $subchart "context" $.context -}} - {{- $requiredPasswordError := include "common.validations.values.single.empty" $requiredPassword -}} - {{- $passwordValidationErrors := list $requiredPasswordError -}} - {{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $.context) -}} - - {{- if .strong }} - {{- $subStr := list (lower (randAlpha 1)) (randNumeric 1) (upper (randAlpha 1)) | join "_" }} - {{- $password = randAscii $passwordLength }} - {{- $password = regexReplaceAllLiteral "\\W" $password "@" | substr 5 $passwordLength }} - {{- $password = printf "%s%s" $subStr $password | toString | shuffle }} {{- else }} - {{- $password = randAlphaNum $passwordLength }} - {{- end }} + {{- if .context.Values.enabled }} + {{- $subchart = $chartName }} + {{- end -}} + + {{- if not (eq .failOnNew false) }} + {{- $requiredPassword := dict "valueKey" $providedPasswordKey "secret" .secret "field" .key "subchart" $subchart "context" $.context -}} + {{- $requiredPasswordError := include "common.validations.values.single.empty" $requiredPassword -}} + {{- $passwordValidationErrors := list $requiredPasswordError -}} + {{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $.context) -}} + {{- end }} + + {{- if .strong }} + {{- $subStr := list (lower (randAlpha 1)) (randNumeric 1) (upper (randAlpha 1)) | join "_" }} + {{- $password = randAscii $passwordLength }} + {{- $password = regexReplaceAllLiteral "\\W" $password "@" | substr 5 $passwordLength }} + {{- $password = printf "%s%s" $subStr $password | toString | shuffle }} + {{- else }} + {{- $password = randAlphaNum $passwordLength }} + {{- end }} + {{- end -}} {{- end -}} {{- if not .skipB64enc }} {{- $password = $password | b64enc }} diff --git a/charts/keycloak/charts/common/templates/_storage.tpl b/charts/keycloak/charts/common/templates/_storage.tpl index 7780da18..aa75856c 100644 --- a/charts/keycloak/charts/common/templates/_storage.tpl +++ b/charts/keycloak/charts/common/templates/_storage.tpl @@ -4,19 +4,18 @@ SPDX-License-Identifier: APACHE-2.0 */}} {{/* vim: set filetype=mustache: */}} + {{/* Return the proper Storage Class {{ include "common.storage.class" ( dict "persistence" .Values.path.to.the.persistence "global" $) }} */}} {{- define "common.storage.class" -}} - -{{- $storageClass := default .persistence.storageClass ((.global).storageClass) -}} +{{- $storageClass := (.global).storageClass | default .persistence.storageClass | default (.global).defaultStorageClass | default "" -}} {{- if $storageClass -}} {{- if (eq "-" $storageClass) -}} {{- printf "storageClassName: \"\"" -}} - {{- else }} + {{- else -}} {{- printf "storageClassName: %s" $storageClass -}} {{- end -}} {{- end -}} - {{- end -}} diff --git a/charts/keycloak/charts/postgresql/Chart.lock b/charts/keycloak/charts/postgresql/Chart.lock index 6dc51dfc..c47b15b6 100644 --- a/charts/keycloak/charts/postgresql/Chart.lock +++ b/charts/keycloak/charts/postgresql/Chart.lock @@ -1,6 +1,6 @@ dependencies: - name: common repository: oci://registry-1.docker.io/bitnamicharts - version: 2.19.3 -digest: sha256:de997835d9ce9a9deefc2d70d8c62b11aa1d1a76ece9e86a83736ab9f930bf4d -generated: "2024-05-20T18:49:08.980707571Z" + version: 2.22.0 +digest: sha256:a8fb2fc887ead658a89598a48acde5324196fbc0509503a3eaed50a710fbfe74 +generated: "2024-08-16T13:43:46.077600896Z" diff --git a/charts/keycloak/charts/postgresql/Chart.yaml b/charts/keycloak/charts/postgresql/Chart.yaml index d38ec715..f3079493 100644 --- a/charts/keycloak/charts/postgresql/Chart.yaml +++ b/charts/keycloak/charts/postgresql/Chart.yaml @@ -2,14 +2,14 @@ annotations: category: Database images: | - name: os-shell - image: docker.io/bitnami/os-shell:12-debian-12-r22 + image: docker.io/bitnami/os-shell:12-debian-12-r29 - name: postgres-exporter - image: docker.io/bitnami/postgres-exporter:0.15.0-debian-12-r32 + image: docker.io/bitnami/postgres-exporter:0.15.0-debian-12-r41 - name: postgresql - image: docker.io/bitnami/postgresql:16.3.0-debian-12-r12 + image: docker.io/bitnami/postgresql:16.4.0-debian-12-r7 licenses: Apache-2.0 apiVersion: v2 -appVersion: 16.3.0 +appVersion: 16.4.0 dependencies: - name: common repository: oci://registry-1.docker.io/bitnamicharts @@ -34,4 +34,4 @@ maintainers: name: postgresql sources: - https://github.com/bitnami/charts/tree/main/bitnami/postgresql -version: 15.5.2 +version: 15.5.28 diff --git a/charts/keycloak/charts/postgresql/README.md b/charts/keycloak/charts/postgresql/README.md index 2581b0ff..56352af4 100644 --- a/charts/keycloak/charts/postgresql/README.md +++ b/charts/keycloak/charts/postgresql/README.md @@ -14,7 +14,7 @@ Trademarks: This software listing is packaged by Bitnami. The respective tradema helm install my-release oci://registry-1.docker.io/bitnamicharts/postgresql ``` -Looking to use PostgreSQL in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the enterprise edition of Bitnami Application Catalog. +Looking to use PostgreSQL in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the commercial edition of the Bitnami catalog. ## Introduction @@ -279,7 +279,8 @@ If you already have data in it, you will fail to sync to standby nodes for all c | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | | `global.imageRegistry` | Global Docker image registry | `""` | | `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` | -| `global.storageClass` | Global StorageClass for Persistent Volume(s) | `""` | +| `global.defaultStorageClass` | Global default StorageClass for Persistent Volume(s) | `""` | +| `global.storageClass` | DEPRECATED: use global.defaultStorageClass instead | `""` | | `global.postgresql.auth.postgresPassword` | Password for the "postgres" admin user (overrides `auth.postgresPassword`) | `""` | | `global.postgresql.auth.username` | Name for a custom user to create (overrides `auth.username`) | `""` | | `global.postgresql.auth.password` | Password for the custom user to create (overrides `auth.password`) | `""` | @@ -384,6 +385,9 @@ If you already have data in it, you will fail to sync to standby nodes for all c | `primary.initdb.scriptsSecret` | Secret with scripts to be run at first boot (in case it contains sensitive information) | `""` | | `primary.initdb.user` | Specify the PostgreSQL username to execute the initdb scripts | `""` | | `primary.initdb.password` | Specify the PostgreSQL password to execute the initdb scripts | `""` | +| `primary.preInitDb.scripts` | Dictionary of pre-init scripts | `{}` | +| `primary.preInitDb.scriptsConfigMap` | ConfigMap with pre-init scripts to be run | `""` | +| `primary.preInitDb.scriptsSecret` | Secret with pre-init scripts to be run | `""` | | `primary.standby.enabled` | Whether to enable current cluster's primary as standby server of another cluster or not | `false` | | `primary.standby.primaryHost` | The Host of replication primary in the other cluster | `""` | | `primary.standby.primaryPort` | The Port of replication primary in the other cluster | `""` | diff --git a/charts/keycloak/charts/postgresql/charts/common/.helmignore b/charts/keycloak/charts/postgresql/charts/common/.helmignore index 7c7c21d6..d0e10845 100644 --- a/charts/keycloak/charts/postgresql/charts/common/.helmignore +++ b/charts/keycloak/charts/postgresql/charts/common/.helmignore @@ -22,3 +22,5 @@ .vscode/ # img folder img/ +# Changelog +CHANGELOG.md diff --git a/charts/keycloak/charts/postgresql/charts/common/Chart.yaml b/charts/keycloak/charts/postgresql/charts/common/Chart.yaml index bffd8df4..0c8fdb52 100644 --- a/charts/keycloak/charts/postgresql/charts/common/Chart.yaml +++ b/charts/keycloak/charts/postgresql/charts/common/Chart.yaml @@ -2,7 +2,7 @@ annotations: category: Infrastructure licenses: Apache-2.0 apiVersion: v2 -appVersion: 2.19.3 +appVersion: 2.22.0 description: A Library Helm Chart for grouping common logic between bitnami charts. This chart is not deployable by itself. home: https://bitnami.com @@ -18,6 +18,6 @@ maintainers: url: https://github.com/bitnami/charts name: common sources: -- https://github.com/bitnami/charts +- https://github.com/bitnami/charts/tree/main/bitnami/common type: library -version: 2.19.3 +version: 2.22.0 diff --git a/charts/keycloak/charts/postgresql/charts/common/README.md b/charts/keycloak/charts/postgresql/charts/common/README.md index 82d78a38..fee26c99 100644 --- a/charts/keycloak/charts/postgresql/charts/common/README.md +++ b/charts/keycloak/charts/postgresql/charts/common/README.md @@ -24,7 +24,7 @@ data: myvalue: "Hello World" ``` -Looking to use our applications in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the enterprise edition of Bitnami Application Catalog. +Looking to use our applications in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the commercial edition of the Bitnami catalog. ## Introduction diff --git a/charts/keycloak/charts/postgresql/charts/common/templates/_capabilities.tpl b/charts/keycloak/charts/postgresql/charts/common/templates/_capabilities.tpl index 002a517c..2fe81d32 100644 --- a/charts/keycloak/charts/postgresql/charts/common/templates/_capabilities.tpl +++ b/charts/keycloak/charts/postgresql/charts/common/templates/_capabilities.tpl @@ -16,7 +16,8 @@ Return the target Kubernetes version Return the appropriate apiVersion for poddisruptionbudget. */}} {{- define "common.capabilities.policy.apiVersion" -}} -{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.21-0" $kubeVersion) -}} {{- print "policy/v1beta1" -}} {{- else -}} {{- print "policy/v1" -}} @@ -27,7 +28,8 @@ Return the appropriate apiVersion for poddisruptionbudget. Return the appropriate apiVersion for networkpolicy. */}} {{- define "common.capabilities.networkPolicy.apiVersion" -}} -{{- if semverCompare "<1.7-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.7-0" $kubeVersion) -}} {{- print "extensions/v1beta1" -}} {{- else -}} {{- print "networking.k8s.io/v1" -}} @@ -38,7 +40,8 @@ Return the appropriate apiVersion for networkpolicy. Return the appropriate apiVersion for cronjob. */}} {{- define "common.capabilities.cronjob.apiVersion" -}} -{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.21-0" $kubeVersion) -}} {{- print "batch/v1beta1" -}} {{- else -}} {{- print "batch/v1" -}} @@ -49,7 +52,8 @@ Return the appropriate apiVersion for cronjob. Return the appropriate apiVersion for daemonset. */}} {{- define "common.capabilities.daemonset.apiVersion" -}} -{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.14-0" $kubeVersion) -}} {{- print "extensions/v1beta1" -}} {{- else -}} {{- print "apps/v1" -}} @@ -60,7 +64,8 @@ Return the appropriate apiVersion for daemonset. Return the appropriate apiVersion for deployment. */}} {{- define "common.capabilities.deployment.apiVersion" -}} -{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.14-0" $kubeVersion) -}} {{- print "extensions/v1beta1" -}} {{- else -}} {{- print "apps/v1" -}} @@ -71,7 +76,8 @@ Return the appropriate apiVersion for deployment. Return the appropriate apiVersion for statefulset. */}} {{- define "common.capabilities.statefulset.apiVersion" -}} -{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.14-0" $kubeVersion) -}} {{- print "apps/v1beta1" -}} {{- else -}} {{- print "apps/v1" -}} @@ -82,30 +88,24 @@ Return the appropriate apiVersion for statefulset. Return the appropriate apiVersion for ingress. */}} {{- define "common.capabilities.ingress.apiVersion" -}} -{{- if .Values.ingress -}} -{{- if .Values.ingress.apiVersion -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if (.Values.ingress).apiVersion -}} {{- .Values.ingress.apiVersion -}} -{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} +{{- else if and (not (empty $kubeVersion)) (semverCompare "<1.14-0" $kubeVersion) -}} {{- print "extensions/v1beta1" -}} -{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} +{{- else if and (not (empty $kubeVersion)) (semverCompare "<1.19-0" $kubeVersion) -}} {{- print "networking.k8s.io/v1beta1" -}} {{- else -}} {{- print "networking.k8s.io/v1" -}} {{- end }} -{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "extensions/v1beta1" -}} -{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} -{{- print "networking.k8s.io/v1beta1" -}} -{{- else -}} -{{- print "networking.k8s.io/v1" -}} -{{- end -}} {{- end -}} {{/* Return the appropriate apiVersion for RBAC resources. */}} {{- define "common.capabilities.rbac.apiVersion" -}} -{{- if semverCompare "<1.17-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.17-0" $kubeVersion) -}} {{- print "rbac.authorization.k8s.io/v1beta1" -}} {{- else -}} {{- print "rbac.authorization.k8s.io/v1" -}} @@ -116,7 +116,8 @@ Return the appropriate apiVersion for RBAC resources. Return the appropriate apiVersion for CRDs. */}} {{- define "common.capabilities.crd.apiVersion" -}} -{{- if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.19-0" $kubeVersion) -}} {{- print "apiextensions.k8s.io/v1beta1" -}} {{- else -}} {{- print "apiextensions.k8s.io/v1" -}} @@ -127,7 +128,8 @@ Return the appropriate apiVersion for CRDs. Return the appropriate apiVersion for APIService. */}} {{- define "common.capabilities.apiService.apiVersion" -}} -{{- if semverCompare "<1.10-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.10-0" $kubeVersion) -}} {{- print "apiregistration.k8s.io/v1beta1" -}} {{- else -}} {{- print "apiregistration.k8s.io/v1" -}} @@ -138,7 +140,8 @@ Return the appropriate apiVersion for APIService. Return the appropriate apiVersion for Horizontal Pod Autoscaler. */}} {{- define "common.capabilities.hpa.apiVersion" -}} -{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" .context -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.23-0" $kubeVersion) -}} {{- if .beta2 -}} {{- print "autoscaling/v2beta2" -}} {{- else -}} @@ -153,7 +156,8 @@ Return the appropriate apiVersion for Horizontal Pod Autoscaler. Return the appropriate apiVersion for Vertical Pod Autoscaler. */}} {{- define "common.capabilities.vpa.apiVersion" -}} -{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" .context -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.23-0" $kubeVersion) -}} {{- if .beta2 -}} {{- print "autoscaling/v2beta2" -}} {{- else -}} @@ -168,7 +172,8 @@ Return the appropriate apiVersion for Vertical Pod Autoscaler. Returns true if PodSecurityPolicy is supported */}} {{- define "common.capabilities.psp.supported" -}} -{{- if semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if or (empty $kubeVersion) (semverCompare "<1.25-0" $kubeVersion) -}} {{- true -}} {{- end -}} {{- end -}} @@ -177,7 +182,8 @@ Returns true if PodSecurityPolicy is supported Returns true if AdmissionConfiguration is supported */}} {{- define "common.capabilities.admissionConfiguration.supported" -}} -{{- if semverCompare ">=1.23-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if or (empty $kubeVersion) (not (semverCompare "<1.23-0" $kubeVersion)) -}} {{- true -}} {{- end -}} {{- end -}} @@ -186,9 +192,10 @@ Returns true if AdmissionConfiguration is supported Return the appropriate apiVersion for AdmissionConfiguration. */}} {{- define "common.capabilities.admissionConfiguration.apiVersion" -}} -{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.23-0" $kubeVersion) -}} {{- print "apiserver.config.k8s.io/v1alpha1" -}} -{{- else if semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .) -}} +{{- else if and (not (empty $kubeVersion)) (semverCompare "<1.25-0" $kubeVersion) -}} {{- print "apiserver.config.k8s.io/v1beta1" -}} {{- else -}} {{- print "apiserver.config.k8s.io/v1" -}} @@ -199,9 +206,10 @@ Return the appropriate apiVersion for AdmissionConfiguration. Return the appropriate apiVersion for PodSecurityConfiguration. */}} {{- define "common.capabilities.podSecurityConfiguration.apiVersion" -}} -{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) -}} +{{- $kubeVersion := include "common.capabilities.kubeVersion" . -}} +{{- if and (not (empty $kubeVersion)) (semverCompare "<1.23-0" $kubeVersion) -}} {{- print "pod-security.admission.config.k8s.io/v1alpha1" -}} -{{- else if semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .) -}} +{{- else if and (not (empty $kubeVersion)) (semverCompare "<1.25-0" $kubeVersion) -}} {{- print "pod-security.admission.config.k8s.io/v1beta1" -}} {{- else -}} {{- print "pod-security.admission.config.k8s.io/v1" -}} diff --git a/charts/keycloak/charts/postgresql/charts/common/templates/_compatibility.tpl b/charts/keycloak/charts/postgresql/charts/common/templates/_compatibility.tpl index 538b3a3c..eb4061d7 100644 --- a/charts/keycloak/charts/postgresql/charts/common/templates/_compatibility.tpl +++ b/charts/keycloak/charts/postgresql/charts/common/templates/_compatibility.tpl @@ -34,5 +34,9 @@ Usage: {{- end -}} {{- end -}} {{- end -}} +{{/* Remove fields that are disregarded when running the container in privileged mode */}} +{{- if $adaptedContext.privileged -}} + {{- $adaptedContext = omit $adaptedContext "capabilities" "seLinuxOptions" -}} +{{- end -}} {{- omit $adaptedContext "enabled" | toYaml -}} {{- end -}} diff --git a/charts/keycloak/charts/postgresql/charts/common/templates/_images.tpl b/charts/keycloak/charts/postgresql/charts/common/templates/_images.tpl index 67df9236..76bb7ce4 100644 --- a/charts/keycloak/charts/postgresql/charts/common/templates/_images.tpl +++ b/charts/keycloak/charts/postgresql/charts/common/templates/_images.tpl @@ -5,8 +5,9 @@ SPDX-License-Identifier: APACHE-2.0 {{/* vim: set filetype=mustache: */}} {{/* -Return the proper image name -{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }} +Return the proper image name. +If image tag and digest are not defined, termination fallbacks to chart appVersion. +{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global "chart" .Chart ) }} */}} {{- define "common.images.image" -}} {{- $registryName := default .imageRoot.registry ((.global).imageRegistry) -}} @@ -14,6 +15,11 @@ Return the proper image name {{- $separator := ":" -}} {{- $termination := .imageRoot.tag | toString -}} +{{- if not .imageRoot.tag }} + {{- if .chart }} + {{- $termination = .chart.AppVersion | toString -}} + {{- end -}} +{{- end -}} {{- if .imageRoot.digest }} {{- $separator = "@" -}} {{- $termination = .imageRoot.digest | toString -}} @@ -50,7 +56,7 @@ Return the proper Docker Image Registry Secret Names (deprecated: use common.ima {{- end -}} {{- end -}} - {{- if (not (empty $pullSecrets)) }} + {{- if (not (empty $pullSecrets)) -}} imagePullSecrets: {{- range $pullSecrets | uniq }} - name: {{ . }} @@ -84,7 +90,7 @@ Return the proper Docker Image Registry Secret Names evaluating values as templa {{- end -}} {{- end -}} - {{- if (not (empty $pullSecrets)) }} + {{- if (not (empty $pullSecrets)) -}} imagePullSecrets: {{- range $pullSecrets | uniq }} - name: {{ . }} diff --git a/charts/keycloak/charts/postgresql/charts/common/templates/_resources.tpl b/charts/keycloak/charts/postgresql/charts/common/templates/_resources.tpl index a4f53c2e..d8a43e1c 100644 --- a/charts/keycloak/charts/postgresql/charts/common/templates/_resources.tpl +++ b/charts/keycloak/charts/postgresql/charts/common/templates/_resources.tpl @@ -15,31 +15,31 @@ These presets are for basic testing and not meant to be used in production {{- $presets := dict "nano" (dict "requests" (dict "cpu" "100m" "memory" "128Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "150m" "memory" "192Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "150m" "memory" "192Mi" "ephemeral-storage" "2Gi") ) "micro" (dict "requests" (dict "cpu" "250m" "memory" "256Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "375m" "memory" "384Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "375m" "memory" "384Mi" "ephemeral-storage" "2Gi") ) "small" (dict "requests" (dict "cpu" "500m" "memory" "512Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "750m" "memory" "768Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "750m" "memory" "768Mi" "ephemeral-storage" "2Gi") ) "medium" (dict "requests" (dict "cpu" "500m" "memory" "1024Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "750m" "memory" "1536Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "750m" "memory" "1536Mi" "ephemeral-storage" "2Gi") ) "large" (dict "requests" (dict "cpu" "1.0" "memory" "2048Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "1.5" "memory" "3072Mi" "ephemeral-storage" "1024Mi") + "limits" (dict "cpu" "1.5" "memory" "3072Mi" "ephemeral-storage" "2Gi") ) "xlarge" (dict - "requests" (dict "cpu" "1.5" "memory" "4096Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "3.0" "memory" "6144Mi" "ephemeral-storage" "1024Mi") + "requests" (dict "cpu" "1.0" "memory" "3072Mi" "ephemeral-storage" "50Mi") + "limits" (dict "cpu" "3.0" "memory" "6144Mi" "ephemeral-storage" "2Gi") ) "2xlarge" (dict - "requests" (dict "cpu" "1.5" "memory" "4096Mi" "ephemeral-storage" "50Mi") - "limits" (dict "cpu" "6.0" "memory" "12288Mi" "ephemeral-storage" "1024Mi") + "requests" (dict "cpu" "1.0" "memory" "3072Mi" "ephemeral-storage" "50Mi") + "limits" (dict "cpu" "6.0" "memory" "12288Mi" "ephemeral-storage" "2Gi") ) }} {{- if hasKey $presets .type -}} diff --git a/charts/keycloak/charts/postgresql/charts/common/templates/_secrets.tpl b/charts/keycloak/charts/postgresql/charts/common/templates/_secrets.tpl index e87575a8..801918ce 100644 --- a/charts/keycloak/charts/postgresql/charts/common/templates/_secrets.tpl +++ b/charts/keycloak/charts/postgresql/charts/common/templates/_secrets.tpl @@ -103,30 +103,33 @@ The order in which this function returns a secret password: {{- $password = index $secretData .key | b64dec }} {{- else if not (eq .failOnNew false) }} {{- printf "\nPASSWORDS ERROR: The secret \"%s\" does not contain the key \"%s\"\n" .secret .key | fail -}} - {{- else if $providedPasswordValue }} + {{- end -}} +{{- end }} + +{{- if not $password }} + {{- if $providedPasswordValue }} {{- $password = $providedPasswordValue | toString }} - {{- end -}} -{{- else if $providedPasswordValue }} - {{- $password = $providedPasswordValue | toString }} -{{- else }} - - {{- if .context.Values.enabled }} - {{- $subchart = $chartName }} - {{- end -}} - - {{- $requiredPassword := dict "valueKey" $providedPasswordKey "secret" .secret "field" .key "subchart" $subchart "context" $.context -}} - {{- $requiredPasswordError := include "common.validations.values.single.empty" $requiredPassword -}} - {{- $passwordValidationErrors := list $requiredPasswordError -}} - {{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $.context) -}} - - {{- if .strong }} - {{- $subStr := list (lower (randAlpha 1)) (randNumeric 1) (upper (randAlpha 1)) | join "_" }} - {{- $password = randAscii $passwordLength }} - {{- $password = regexReplaceAllLiteral "\\W" $password "@" | substr 5 $passwordLength }} - {{- $password = printf "%s%s" $subStr $password | toString | shuffle }} {{- else }} - {{- $password = randAlphaNum $passwordLength }} - {{- end }} + {{- if .context.Values.enabled }} + {{- $subchart = $chartName }} + {{- end -}} + + {{- if not (eq .failOnNew false) }} + {{- $requiredPassword := dict "valueKey" $providedPasswordKey "secret" .secret "field" .key "subchart" $subchart "context" $.context -}} + {{- $requiredPasswordError := include "common.validations.values.single.empty" $requiredPassword -}} + {{- $passwordValidationErrors := list $requiredPasswordError -}} + {{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $.context) -}} + {{- end }} + + {{- if .strong }} + {{- $subStr := list (lower (randAlpha 1)) (randNumeric 1) (upper (randAlpha 1)) | join "_" }} + {{- $password = randAscii $passwordLength }} + {{- $password = regexReplaceAllLiteral "\\W" $password "@" | substr 5 $passwordLength }} + {{- $password = printf "%s%s" $subStr $password | toString | shuffle }} + {{- else }} + {{- $password = randAlphaNum $passwordLength }} + {{- end }} + {{- end -}} {{- end -}} {{- if not .skipB64enc }} {{- $password = $password | b64enc }} diff --git a/charts/keycloak/charts/postgresql/charts/common/templates/_storage.tpl b/charts/keycloak/charts/postgresql/charts/common/templates/_storage.tpl index 7780da18..aa75856c 100644 --- a/charts/keycloak/charts/postgresql/charts/common/templates/_storage.tpl +++ b/charts/keycloak/charts/postgresql/charts/common/templates/_storage.tpl @@ -4,19 +4,18 @@ SPDX-License-Identifier: APACHE-2.0 */}} {{/* vim: set filetype=mustache: */}} + {{/* Return the proper Storage Class {{ include "common.storage.class" ( dict "persistence" .Values.path.to.the.persistence "global" $) }} */}} {{- define "common.storage.class" -}} - -{{- $storageClass := default .persistence.storageClass ((.global).storageClass) -}} +{{- $storageClass := (.global).storageClass | default .persistence.storageClass | default (.global).defaultStorageClass | default "" -}} {{- if $storageClass -}} {{- if (eq "-" $storageClass) -}} {{- printf "storageClassName: \"\"" -}} - {{- else }} + {{- else -}} {{- printf "storageClassName: %s" $storageClass -}} {{- end -}} {{- end -}} - {{- end -}} diff --git a/charts/keycloak/charts/postgresql/templates/_helpers.tpl b/charts/keycloak/charts/postgresql/templates/_helpers.tpl index 94a086a2..7c00c477 100644 --- a/charts/keycloak/charts/postgresql/templates/_helpers.tpl +++ b/charts/keycloak/charts/postgresql/templates/_helpers.tpl @@ -267,6 +267,17 @@ Return true if a configmap should be mounted with PostgreSQL configuration {{- end -}} {{- end -}} +{{/* +Get the pre-initialization scripts ConfigMap name. +*/}} +{{- define "postgresql.v1.preInitDb.scriptsCM" -}} +{{- if .Values.primary.preInitDb.scriptsConfigMap -}} + {{- printf "%s" (tpl .Values.primary.preInitDb.scriptsConfigMap $) -}} +{{- else -}} + {{- printf "%s-preinit-scripts" (include "postgresql.v1.primary.fullname" .) -}} +{{- end -}} +{{- end -}} + {{/* Get the initialization scripts ConfigMap name. */}} @@ -401,6 +412,6 @@ Return the path to the CA cert file. {{- if .Values.tls.autoGenerated -}} {{- printf "%s-crt" (include "common.names.fullname" .) -}} {{- else -}} - {{ required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret }} + {{ tpl (required "A secret containing TLS certificates is required when TLS is enabled" .Values.tls.certificatesSecret) . }} {{- end -}} {{- end -}} diff --git a/charts/keycloak/charts/postgresql/templates/primary/preinitialization-configmap.yaml b/charts/keycloak/charts/postgresql/templates/primary/preinitialization-configmap.yaml new file mode 100644 index 00000000..65606a4e --- /dev/null +++ b/charts/keycloak/charts/postgresql/templates/primary/preinitialization-configmap.yaml @@ -0,0 +1,17 @@ +{{- /* +Copyright Broadcom, Inc. All Rights Reserved. +SPDX-License-Identifier: APACHE-2.0 +*/}} + +{{- if and .Values.primary.preInitDb.scripts (not .Values.primary.preInitDb.scriptsConfigMap) }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ printf "%s-preinit-scripts" (include "postgresql.v1.primary.fullname" .) }} + namespace: {{ .Release.Namespace | quote }} + labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} + {{- if .Values.commonAnnotations }} + annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} + {{- end }} +data: {{- include "common.tplvalues.render" (dict "value" .Values.primary.preInitDb.scripts "context" .) | nindent 2 }} +{{- end }} diff --git a/charts/keycloak/charts/postgresql/templates/primary/statefulset.yaml b/charts/keycloak/charts/postgresql/templates/primary/statefulset.yaml index b5f98e8e..c110f91b 100644 --- a/charts/keycloak/charts/postgresql/templates/primary/statefulset.yaml +++ b/charts/keycloak/charts/postgresql/templates/primary/statefulset.yaml @@ -257,8 +257,8 @@ spec: - name: POSTGRES_DATABASE value: {{ (include "postgresql.v1.database" .) | quote }} {{- end }} - # Replication {{- if or (eq .Values.architecture "replication") .Values.primary.standby.enabled }} + # Replication - name: POSTGRES_REPLICATION_MODE value: {{ ternary "slave" "master" .Values.primary.standby.enabled | quote }} - name: POSTGRES_REPLICATION_USER @@ -282,8 +282,8 @@ spec: - name: POSTGRES_CLUSTER_APP_NAME value: {{ .Values.replication.applicationName }} {{- end }} - # Initdb {{- if .Values.primary.initdb.args }} + # Initdb - name: POSTGRES_INITDB_ARGS value: {{ .Values.primary.initdb.args | quote }} {{- end }} @@ -299,8 +299,8 @@ spec: - name: POSTGRES_INITSCRIPTS_PASSWORD value: {{ .Values.primary.initdb.password | quote }} {{- end }} - # Standby {{- if .Values.primary.standby.enabled }} + # Standby - name: POSTGRES_MASTER_HOST value: {{ .Values.primary.standby.primaryHost }} - name: POSTGRES_MASTER_PORT_NUMBER @@ -466,6 +466,14 @@ spec: - name: empty-dir mountPath: /opt/bitnami/postgresql/tmp subPath: app-tmp-dir + {{- if or .Values.primary.preInitDb.scriptsConfigMap .Values.primary.preInitDb.scripts }} + - name: custom-preinit-scripts + mountPath: /docker-entrypoint-preinitdb.d/ + {{- end }} + {{- if .Values.primary.preInitDb.scriptsSecret }} + - name: custom-preinit-scripts-secret + mountPath: /docker-entrypoint-preinitdb.d/secret + {{- end }} {{- if or .Values.primary.initdb.scriptsConfigMap .Values.primary.initdb.scripts }} - name: custom-init-scripts mountPath: /docker-entrypoint-initdb.d/ @@ -524,9 +532,8 @@ spec: {{- end }} {{- end }} env: - {{- $database := required "In order to enable metrics you need to specify a database (.Values.auth.database or .Values.global.postgresql.auth.database)" (include "postgresql.v1.database" .) }} - name: DATA_SOURCE_URI - value: {{ printf "127.0.0.1:%d/%s?sslmode=disable" (int (include "postgresql.v1.service.port" .)) $database }} + value: {{ printf "127.0.0.1:%d/postgres?sslmode=disable" (int (include "postgresql.v1.service.port" .)) }} {{- $pwdKey := ternary (include "postgresql.v1.adminPasswordKey" .) (include "postgresql.v1.userPasswordKey" .) (or (eq $customUser "postgres") (empty $customUser)) }} {{- if .Values.auth.usePasswordFiles }} - name: DATA_SOURCE_PASS_FILE @@ -611,6 +618,16 @@ spec: secret: secretName: {{ include "postgresql.v1.secretName" . }} {{- end }} + {{- if or .Values.primary.preInitDb.scriptsConfigMap .Values.primary.preInitDb.scripts }} + - name: custom-preinit-scripts + configMap: + name: {{ include "postgresql.v1.preInitDb.scriptsCM" . }} + {{- end }} + {{- if .Values.primary.preInitDb.scriptsSecret }} + - name: custom-preinit-scripts-secret + secret: + secretName: {{ tpl .Values.primary.preInitDb.scriptsSecret $ }} + {{- end }} {{- if or .Values.primary.initdb.scriptsConfigMap .Values.primary.initdb.scripts }} - name: custom-init-scripts configMap: diff --git a/charts/keycloak/charts/postgresql/templates/primary/svc-headless.yaml b/charts/keycloak/charts/postgresql/templates/primary/svc-headless.yaml index 03b3573c..ba918f4f 100644 --- a/charts/keycloak/charts/postgresql/templates/primary/svc-headless.yaml +++ b/charts/keycloak/charts/postgresql/templates/primary/svc-headless.yaml @@ -15,11 +15,6 @@ metadata: {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.primary.service.headless.annotations .Values.commonAnnotations ) "context" . ) }} {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }} {{- end }} - # Use this annotation in addition to the actual publishNotReadyAddresses - # field below because the annotation will stop being respected soon but the - # field is broken in some versions of Kubernetes: - # https://github.com/kubernetes/kubernetes/issues/58662 - service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" spec: type: ClusterIP clusterIP: None diff --git a/charts/keycloak/charts/postgresql/templates/read/statefulset.yaml b/charts/keycloak/charts/postgresql/templates/read/statefulset.yaml index 4a696390..4f537e60 100644 --- a/charts/keycloak/charts/postgresql/templates/read/statefulset.yaml +++ b/charts/keycloak/charts/postgresql/templates/read/statefulset.yaml @@ -432,9 +432,8 @@ spec: args: [ "--extend.query-path", "/conf/custom-metrics.yaml" ] {{- end }} env: - {{- $database := required "In order to enable metrics you need to specify a database (.Values.auth.database or .Values.global.postgresql.auth.database)" (include "postgresql.v1.database" .) }} - name: DATA_SOURCE_URI - value: {{ printf "127.0.0.1:%d/%s?sslmode=disable" (int (include "postgresql.v1.service.port" .)) $database }} + value: {{ printf "127.0.0.1:%d/postgres?sslmode=disable" (int (include "postgresql.v1.service.port" .)) }} {{- if .Values.auth.usePasswordFiles }} - name: DATA_SOURCE_PASS_FILE value: {{ printf "/opt/bitnami/postgresql/secrets/%s" (include "postgresql.v1.userPasswordKey" .) }} diff --git a/charts/keycloak/charts/postgresql/templates/read/svc-headless.yaml b/charts/keycloak/charts/postgresql/templates/read/svc-headless.yaml index fa29131e..ef44601e 100644 --- a/charts/keycloak/charts/postgresql/templates/read/svc-headless.yaml +++ b/charts/keycloak/charts/postgresql/templates/read/svc-headless.yaml @@ -16,11 +16,6 @@ metadata: {{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.readReplicas.service.headless.annotations .Values.commonAnnotations ) "context" . ) }} {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }} {{- end }} - # Use this annotation in addition to the actual publishNotReadyAddresses - # field below because the annotation will stop being respected soon but the - # field is broken in some versions of Kubernetes: - # https://github.com/kubernetes/kubernetes/issues/58662 - service.alpha.kubernetes.io/tolerate-unready-endpoints: "true" spec: type: ClusterIP clusterIP: None diff --git a/charts/keycloak/charts/postgresql/values.yaml b/charts/keycloak/charts/postgresql/values.yaml index 7245fd04..b762a020 100644 --- a/charts/keycloak/charts/postgresql/values.yaml +++ b/charts/keycloak/charts/postgresql/values.yaml @@ -14,8 +14,10 @@ global: ## - myRegistryKeySecretName ## imagePullSecrets: [] - ## @param global.storageClass Global StorageClass for Persistent Volume(s) + ## @param global.defaultStorageClass Global default StorageClass for Persistent Volume(s) +## @param global.storageClass DEPRECATED: use global.defaultStorageClass instead ## + defaultStorageClass: "" storageClass: "" postgresql: ## @param global.postgresql.auth.postgresPassword Password for the "postgres" admin user (overrides `auth.postgresPassword`) @@ -105,7 +107,7 @@ diagnosticMode: image: registry: docker.io repository: bitnami/postgresql - tag: 16.3.0-debian-12-r12 + tag: 16.4.0-debian-12-r7 digest: "" ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' @@ -357,6 +359,23 @@ primary: ## @param primary.initdb.password Specify the PostgreSQL password to execute the initdb scripts ## password: "" + ## Pre-init configuration + ## ref: https://github.com/bitnami/containers/tree/main/bitnami/postgresql/#on-container-start + preInitDb: + ## @param primary.preInitDb.scripts Dictionary of pre-init scripts + ## Specify dictionary of shell scripts to be run before db boot + ## e.g: + ## scripts: + ## my_pre_init_script.sh: | + ## #!/bin/sh + ## echo "Do something." + scripts: {} + ## @param primary.preInitDb.scriptsConfigMap ConfigMap with pre-init scripts to be run + ## NOTE: This will override `primary.preInitDb.scripts` + scriptsConfigMap: "" + ## @param primary.preInitDb.scriptsSecret Secret with pre-init scripts to be run + ## NOTE: This can work along `primary.preInitDb.scripts` or `primary.preInitDb.scriptsConfigMap` + scriptsSecret: "" ## Configure current cluster's primary server to be the standby server in other cluster. ## This will allow cross cluster replication and provide cross cluster high availability. ## You will need to configure pgHbaConfiguration if you want to enable this feature with local cluster replication enabled. @@ -1427,7 +1446,7 @@ volumePermissions: image: registry: docker.io repository: bitnami/os-shell - tag: 12-debian-12-r22 + tag: 12-debian-12-r29 digest: "" pullPolicy: IfNotPresent ## Optionally specify an array of imagePullSecrets. @@ -1536,7 +1555,7 @@ metrics: image: registry: docker.io repository: bitnami/postgres-exporter - tag: 0.15.0-debian-12-r32 + tag: 0.15.0-debian-12-r41 digest: "" pullPolicy: IfNotPresent ## Optionally specify an array of imagePullSecrets. diff --git a/charts/keycloak/templates/NOTES.txt b/charts/keycloak/templates/NOTES.txt index 647c5430..a5ac3603 100644 --- a/charts/keycloak/templates/NOTES.txt +++ b/charts/keycloak/templates/NOTES.txt @@ -19,7 +19,7 @@ To access Keycloak from outside the cluster execute the following commands: echo "$CLUSTER_IP {{ (tpl .Values.ingress.hostname .) }}" | sudo tee -a /etc/hosts {{- if .Values.adminIngress.enabled }} -The admin area of Keycloak has been configured to point to a different domain ({{ .Values.adminIngress.hostname }}). Please remember to update the `frontendUrl` property of the `master` (or any other) realm for it to work properly (see README for an example) : +The admin area of Keycloak has been configured to point to a different domain ({{ .Values.adminIngress.hostname }}). Please remember to update the `frontendUrl` property of the `{{ .Values.adminRealm | default "master" }}` (or any other) realm for it to work properly (see README for an example) : echo "Keycloak admin URL: http{{ if .Values.adminIngress.tls }}s{{ end }}://{{ (tpl .Values.adminIngress.hostname .) }}/" echo "$CLUSTER_IP {{ (tpl .Values.adminIngress.hostname .) }}" | sudo tee -a /etc/hosts diff --git a/charts/keycloak/templates/_helpers.tpl b/charts/keycloak/templates/_helpers.tpl index da2a443c..5f56e705 100644 --- a/charts/keycloak/templates/_helpers.tpl +++ b/charts/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 -}} @@ -340,7 +340,7 @@ keycloak: tls.enabled {{/* Validate values of Keycloak - Production mode enabled */}} {{- define "keycloak.validateValues.production" -}} -{{- if and .Values.production (not .Values.tls.enabled) (not (eq .Values.proxy "edge")) -}} +{{- if and .Values.production (not .Values.tls.enabled) (not (eq .Values.proxy "edge")) (empty .Values.proxyHeaders) -}} keycloak: production In order to enable Production mode, you also need to enable HTTPS/TLS using the value 'tls.enabled' and providing an existing secret containing the Keystore and Trustore. diff --git a/charts/keycloak/templates/configmap-env-vars.yaml b/charts/keycloak/templates/configmap-env-vars.yaml index 4706cb6f..31a58658 100644 --- a/charts/keycloak/templates/configmap-env-vars.yaml +++ b/charts/keycloak/templates/configmap-env-vars.yaml @@ -16,7 +16,42 @@ metadata: data: KEYCLOAK_ADMIN: {{ .Values.auth.adminUser | quote }} KEYCLOAK_HTTP_PORT: {{ .Values.containerPorts.http | quote }} - KEYCLOAK_PROXY: {{ .Values.proxy | quote }} + {{- if and .Values.proxy (empty .Values.proxyHeaders) }} + KEYCLOAK_PROXY_HEADERS: {{ ternary "" "xforwarded" (eq .Values.proxy "passthrough") }} + {{- else }} + KEYCLOAK_PROXY_HEADERS: {{ .Values.proxyHeaders | quote }} + {{- end }} + {{- if and .Values.adminIngress.enabled .Values.adminIngress.hostname }} + KEYCLOAK_HOSTNAME_ADMIN: |- + {{ ternary "https://" "http://" ( or .Values.adminIngress.tls (eq .Values.proxy "edge") (not (empty .Values.proxyHeaders)) ) -}} + {{- include "common.tplvalues.render" (dict "value" .Values.adminIngress.hostname "context" $) -}} + {{- if eq .Values.adminIngress.controller "default" }} + {{- include "common.tplvalues.render" (dict "value" .Values.adminIngress.path "context" $) }} + {{- else if eq .Values.adminIngress.controller "gce" }} + {{- $path := .Values.adminIngress.path -}} + {{- if hasSuffix "*" $path -}} + {{- $path = trimSuffix "*" $path -}} + {{- end -}} + {{- include "common.tplvalues.render" (dict "value" $path "context" $) }} + {{- end }} + {{- end }} + {{- if and .Values.ingress.enabled .Values.ingress.hostname }} + KEYCLOAK_HOSTNAME: |- + {{ ternary "https://" "http://" ( or .Values.ingress.tls (eq .Values.proxy "edge") (not (empty .Values.proxyHeaders)) ) -}} + {{- include "common.tplvalues.render" (dict "value" .Values.ingress.hostname "context" $) -}} + {{- if eq .Values.ingress.controller "default" }} + {{- include "common.tplvalues.render" (dict "value" .Values.ingress.path "context" $) }} + {{- else if eq .Values.ingress.controller "gce" }} + {{- $path := .Values.ingress.path -}} + {{- if hasSuffix "*" $path -}} + {{- $path = trimSuffix "*" $path -}} + {{- end -}} + {{- include "common.tplvalues.render" (dict "value" $path "context" $) }} + {{- end }} + {{- end }} + {{- if .Values.ingress.enabled }} + KEYCLOAK_HOSTNAME_STRICT: {{ ternary "true" "false" .Values.ingress.hostnameStrict | quote }} + {{- end }} KEYCLOAK_ENABLE_STATISTICS: {{ ternary "true" "false" .Values.metrics.enabled | quote }} {{- if not .Values.externalDatabase.existingSecretHostKey }} KEYCLOAK_DATABASE_HOST: {{ include "keycloak.databaseHost" . | quote }} @@ -30,8 +65,11 @@ data: {{- if not .Values.externalDatabase.existingSecretUserKey }} KEYCLOAK_DATABASE_USER: {{ include "keycloak.databaseUser" . | quote }} {{- end }} - KEYCLOAK_PRODUCTION: {{ ternary "true" "false" .Values.production | quote }} + KEYCLOAK_PRODUCTION: {{ ternary "true" "false" .Values.production | quote }} KEYCLOAK_ENABLE_HTTPS: {{ ternary "true" "false" .Values.tls.enabled | quote }} + {{- if .Values.customCaExistingSecret }} + KC_TRUSTSTORE_PATHS: "/opt/bitnami/keycloak/custom-ca" + {{- end }} {{- if .Values.tls.enabled }} KEYCLOAK_HTTPS_PORT: {{ .Values.containerPorts.https | quote }} KEYCLOAK_HTTPS_USE_PEM: {{ ternary "true" "false" (or .Values.tls.usePem .Values.tls.autoGenerated) | quote }} @@ -52,10 +90,10 @@ data: {{- if .Values.cache.enabled }} KEYCLOAK_CACHE_TYPE: "ispn" {{- if .Values.cache.stackName }} - KEYCLOAK_CACHE_STACK: {{ .Values.cache.stackName | quote }} + KEYCLOAK_CACHE_STACK: {{ .Values.cache.stackName | quote }} {{- end }} {{- if .Values.cache.stackFile }} - KEYCLOAK_CACHE_CONFIG_FILE: {{ .Values.cache.stackFile | quote }} + KEYCLOAK_CACHE_CONFIG_FILE: {{ .Values.cache.stackFile | quote }} {{- end }} JAVA_OPTS_APPEND: {{ printf "-Djgroups.dns.query=%s-headless.%s.svc.%s" (include "common.names.fullname" .) (include "common.names.namespace" .) .Values.clusterDomain | quote }} {{- else }} diff --git a/charts/keycloak/templates/statefulset.yaml b/charts/keycloak/templates/statefulset.yaml index 93857b60..21ce876e 100644 --- a/charts/keycloak/templates/statefulset.yaml +++ b/charts/keycloak/templates/statefulset.yaml @@ -22,6 +22,9 @@ spec: serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) | trunc 63 | trimSuffix "-" }} updateStrategy: {{- include "common.tplvalues.render" (dict "value" .Values.updateStrategy "context" $ ) | nindent 4 }} + {{- if .Values.minReadySeconds }} + minReadySeconds: {{ .Values.minReadySeconds }} + {{- end }} {{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.podLabels .Values.commonLabels ) "context" . ) }} selector: matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }} @@ -89,7 +92,7 @@ spec: {{- if or .Values.enableDefaultInitContainers .Values.initContainers }} initContainers: {{- if .Values.enableDefaultInitContainers }} - - name: init-quarkus-directory + - name: prepare-write-dirs image: {{ template "keycloak.image" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} command: @@ -97,8 +100,14 @@ spec: args: - -ec - | - #!/bin/bash - cp -r /opt/bitnami/keycloak/lib/quarkus/* /quarkus + . /opt/bitnami/scripts/liblog.sh + + info "Copying writable dirs to empty dir" + # In order to not break the application functionality we need to make some + # directories writable, so we need to copy it to an empty dir volume + cp -r --preserve=mode /opt/bitnami/keycloak/lib/quarkus /emptydir/app-quarkus-dir + cp -r --preserve=mode /opt/bitnami/keycloak/data /emptydir/app-data-dir + info "Copy operation completed" {{- if .Values.containerSecurityContext.enabled }} securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.containerSecurityContext "context" $) | nindent 12 }} {{- end }} @@ -108,12 +117,8 @@ spec: resources: {{- include "common.resources.preset" (dict "type" .Values.resourcesPreset) | nindent 12 }} {{- end }} volumeMounts: - - name: empty-dir - mountPath: /tmp - subPath: tmp-dir - - name: empty-dir - mountPath: /quarkus - subPath: app-quarkus-dir + - name: empty-dir + mountPath: /emptydir {{- end }} {{- if .Values.initContainers }} {{- include "common.tplvalues.render" (dict "value" .Values.initContainers "context" $) | nindent 8 }} @@ -212,13 +217,9 @@ spec: - name: KEYCLOAK_EXTRA_ARGS value: {{ .Values.extraStartupArgs | quote }} {{- end }} - {{- if .Values.adminIngress.enabled }} - - name: KC_HOSTNAME_ADMIN_URL - value: "http{{ if .Values.adminIngress.tls }}s{{ end }}://{{ include "common.tplvalues.render" (dict "value" .Values.adminIngress.hostname "context" $) }}" - {{- end }} - {{- if and .Values.adminIngress.enabled (not .Values.ingress.enabled) }} - - name: KC_HOSTNAME_URL - value: "http{{ if .Values.adminIngress.tls }}s{{ end }}://{{ include "common.tplvalues.render" (dict "value" .Values.adminIngress.hostname "context" $) }}" + {{- if .Values.adminRealm }} + - name: KC_SPI_ADMIN_REALM + value: "{{ .Values.adminRealm }}" {{- end }} {{- if .Values.extraEnvVars }} {{- include "common.tplvalues.render" (dict "value" .Values.extraEnvVars "context" $) | nindent 12 }} @@ -275,7 +276,7 @@ spec: {{- else if .Values.readinessProbe.enabled }} readinessProbe: {{- omit .Values.readinessProbe "enabled" | toYaml | nindent 12 }} httpGet: - path: {{ .Values.httpRelativePath }}realms/master + path: {{ .Values.httpRelativePath }}realms/{{ .Values.adminRealm | default "master" }} port: http {{- end }} {{- end }} @@ -283,6 +284,9 @@ spec: - name: empty-dir mountPath: /tmp subPath: tmp-dir + - name: empty-dir + mountPath: /bitnami + subPath: app-volume-dir - name: empty-dir mountPath: /opt/bitnami/keycloak/conf subPath: app-conf-dir @@ -302,6 +306,11 @@ spec: mountPath: /opt/bitnami/keycloak/certs readOnly: true {{- end }} + {{- if .Values.customCaExistingSecret }} + - name: custom-ca + mountPath: /opt/bitnami/keycloak/custom-ca + readOnly: true + {{- end }} {{- if .Values.spi.existingSecret }} - name: spi-certificates mountPath: /opt/bitnami/keycloak/spi-certs @@ -331,6 +340,12 @@ spec: secretName: {{ include "keycloak.tlsSecretName" . }} defaultMode: 420 {{- end }} + {{- if .Values.customCaExistingSecret }} + - name: custom-ca + secret: + secretName: {{ .Values.customCaExistingSecret }} + defaultMode: 420 + {{- end }} {{- if .Values.spi.existingSecret }} - name: spi-certificates secret: diff --git a/charts/keycloak/values.yaml b/charts/keycloak/values.yaml index 8028069e..abe71381 100644 --- a/charts/keycloak/values.yaml +++ b/charts/keycloak/values.yaml @@ -9,7 +9,8 @@ ## @param global.imageRegistry Global Docker image registry ## @param global.imagePullSecrets Global Docker registry secret names as an array -## @param global.storageClass Global StorageClass for Persistent Volume(s) +## @param global.defaultStorageClass Global default StorageClass for Persistent Volume(s) +## @param global.storageClass DEPRECATED: use global.defaultStorageClass instead ## global: imageRegistry: "" @@ -18,6 +19,7 @@ global: ## - myRegistryKeySecretName ## imagePullSecrets: [] + defaultStorageClass: "" storageClass: "" ## Compatibility adaptations for Kubernetes platforms ## @@ -101,7 +103,7 @@ diagnosticMode: image: registry: docker.io repository: bitnami/keycloak - tag: 24.0.5-debian-12-r0 + tag: 25.0.5-debian-12-r0 digest: "" ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' @@ -138,6 +140,11 @@ auth: ## @param auth.annotations Additional custom annotations for Keycloak auth secret object ## annotations: {} +## Custom Certificates +## @param customCaExistingSecret Name of the secret containing the Keycloak custom CA certificates. The secret will be mounted as a directory and configured using KC_TRUSTSTORE_PATHS. +## https://www.keycloak.org/server/keycloak-truststore +## Could be created like this: kubectl create secret generic secretName --from-file=./certificateToMerge.pem +customCaExistingSecret: "" ## HTTPS settings ## ref: https://github.com/bitnami/containers/tree/main/bitnami/keycloak#tls-encryption ## @@ -159,7 +166,7 @@ tls: ## existingSecret: "" ## @param tls.usePem Use PEM certificates as input instead of PKS12/JKS stores - ## If "true", the Keycloak chart will look for the files keycloak.key and keycloak.crt inside the secret provided with 'existingSecret'. + ## If "true", the Keycloak chart will look for the files tls.key and tls.crt inside the secret provided with 'existingSecret'. ## usePem: false ## @param tls.truststoreFilename Truststore filename inside the existing secret @@ -175,6 +182,7 @@ tls: ## truststorePassword: "" ## @param tls.passwordsSecret Secret containing the Keystore and Truststore passwords. + ## The secret must have "tls-keystore-password" and "tls-truststore-password" keys for the keystore and truststore respectively. ## passwordsSecret: "" ## SPI TLS settings @@ -195,18 +203,26 @@ spi: ## truststoreFilename: "keycloak-spi.truststore.jks" ## @param spi.passwordsSecret Secret containing the SPI Truststore passwords. + ## The secret must have "spi-truststore-password" key. ## passwordsSecret: "" ## @param spi.hostnameVerificationPolicy Verify the hostname of the server's certificate. Allowed values: "ANY", "WILDCARD", "STRICT". ## hostnameVerificationPolicy: "" +## @param adminRealm Name of the admin realm +## +adminRealm: "master" ## @param production Run Keycloak in production mode. TLS configuration is required except when using proxy=edge. ## production: false +## @param proxyHeaders Set Keycloak proxy headers +## +proxyHeaders: "" ## @param proxy reverse Proxy mode edge, reencrypt, passthrough or none +## DEPRECATED: use proxyHeaders instead ## ref: https://www.keycloak.org/server/reverseproxy ## -proxy: passthrough +proxy: "" ## @param httpRelativePath Set the path relative to '/' for serving resources. Useful if you are migrating from older version which were using '/auth/' ## ref: https://www.keycloak.org/migration/migrating-to-quarkus#_default_context_path_changed ## @@ -482,6 +498,9 @@ terminationGracePeriodSeconds: "" updateStrategy: type: RollingUpdate rollingUpdate: {} +## @param minReadySeconds How many seconds a pod needs to be ready before killing the next, during update +## +minReadySeconds: 0 ## @param extraVolumes Optionally specify extra list of additional volumes for Keycloak pods ## extraVolumes: [] @@ -603,9 +622,19 @@ ingress: ## @param ingress.apiVersion Force Ingress API version (automatically detected if not set) ## apiVersion: "" + ## @param ingress.controller The ingress controller type. Currently supports `default` and `gce` + ## leave as `default` for most ingress controllers. + ## set to `gce` if using the GCE ingress controller + ## + controller: default ## @param ingress.hostname Default host for the ingress record (evaluated as template) ## hostname: keycloak.local + ## @param ingress.hostnameStrict Disables dynamically resolving the hostname from request headers. + ## Should always be set to true in production, unless your reverse proxy overwrites the Host header. + ## If enabled, the hostname option needs to be specified. + ## + hostnameStrict: false ## @param ingress.path [string] Default path for the ingress record (evaluated as template) ## path: "{{ .Values.httpRelativePath }}" @@ -710,6 +739,11 @@ adminIngress: ## @param adminIngress.apiVersion Force Ingress API version (automatically detected if not set) ## apiVersion: "" + ## @param adminIngress.controller The ingress controller type. Currently supports `default` and `gce` + ## leave as `default` for most ingress controllers. + ## set to `gce` if using the GCE ingress controller + ## + controller: default ## @param adminIngress.hostname Default host for the admin ingress record (evaluated as template) ## hostname: keycloak.local @@ -998,7 +1032,7 @@ metrics: ## endpoints: - path: '{{ include "keycloak.httpPath" . }}metrics' - - path: '{{ include "keycloak.httpPath" . }}realms/master/metrics' + - path: '{{ include "keycloak.httpPath" . }}realms/{{ .Values.adminRealm }}/metrics' ## @param metrics.serviceMonitor.path Metrics service HTTP path. Deprecated: Use @param metrics.serviceMonitor.endpoints instead ## path: "" @@ -1079,7 +1113,7 @@ keycloakConfigCli: image: registry: docker.io repository: bitnami/keycloak-config-cli - tag: 5.12.0-debian-12-r5 + tag: 6.1.6-debian-12-r3 digest: "" ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' @@ -1269,6 +1303,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: @@ -1279,6 +1314,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 diff --git a/doc/source/user/auth.rst b/doc/source/user/auth.rst index 3afd6fdd..abd3e97f 100644 --- a/doc/source/user/auth.rst +++ b/doc/source/user/auth.rst @@ -6,13 +6,22 @@ Authentication Using external token from identity provider ******************************************* -Since OpenStack is configured to trust Keycloak as an identity provider, you will -need to generate a token from Keycloak and use it to authenticate with the OpenStack -API. +OpenStack trusts Keycloak as its identity provider, so the OpenStack API only +accepts tokens issued by Keycloak. If a workload or a user already has a token +from another OpenID Connect (OIDC) identity provider, Keycloak can accept that +token and issue its own token in return, which then authenticates with the +OpenStack API. -If you are using Keycloak with an OpenID Connect (OIDC) identity provider, you -may want to exchange a token generated from your identity provider for a token -from Keycloak, which can then be used to authenticate with the OpenStack API. +Keycloak supports two ways to do this, depending on who the token represents: + +- **Federated client authentication** is for workloads, such as services, CI + pipelines or Kubernetes service accounts, that get tokens from their own + identity provider with the client credentials grant. Keycloak authenticates + the workload as a Keycloak client without a client secret, and issues a token + for that client's service account. +- **JWT authorization grant** is for users who already have an account in the + Keycloak realm that is linked to the external identity provider, for example + because they signed in through it before. .. mermaid:: :align: center @@ -25,56 +34,138 @@ from Keycloak, which can then be used to authenticate with the OpenStack API. participant Keystone participant OpenStack - Client->>OIDC Provider: Request Token (Client Credentials) - OIDC Provider-->>Client: Returns OIDC Token + Client->>OIDC Provider: Request token + OIDC Provider-->>Client: Returns OIDC token - Client->>Keycloak: Exchange OIDC Token - Keycloak-->>Client: Returns Keycloak OIDC Token + Client->>Keycloak: Send OIDC token as an assertion + Keycloak-->>Client: Returns Keycloak token - Client->>Keystone: Authenticate with Keycloak Token - Keystone-->>Client: Returns Keystone Token + Client->>Keystone: Authenticate with Keycloak token + Keystone-->>Client: Returns Keystone token - Client->>OpenStack: Use Keystone Token - OpenStack-->>Client: OpenStack API Access Granted + Client->>OpenStack: Use Keystone token + OpenStack-->>Client: OpenStack API access granted -In order to get started with this process, you'll need a OpenID connect token -issued by an identity provider which exists in the Keycloak realm. +The examples below use the following placeholders: -1. **Exchange the OpenID connect (OIDC) Token with Keycloak** +- ````: The URL of your Keycloak instance. +- ````: The Keycloak realm for your Keystone domain, which is + ``atmosphere`` by default. +- ````: The token issued by your identity provider. - Use the *OpenID connect token* from your identity provider and exchange it for - a *Keycloak-issued token*. The following ``curl`` command is provided as an - example but you can use any tool that can make HTTP requests. +Configure the identity provider +=============================== - You will need to replace the following placeholders in the example code: +Both methods need the external identity provider registered in the Keycloak +realm, so that Keycloak can validate its tokens. - - ````: The URL of your Keycloak instance. - - ````: The client ID of the Keycloak client. - - ````: The client secret of the Keycloak client. +1. In the Keycloak admin console, open the realm and go to **Identity + providers**, then add an **OpenID Connect v1.0** provider. + +2. Set **Issuer** to the ``iss`` claim of the tokens issued by the provider, + enable **Use JWKS URL** and set **JWKS URL** to the provider's signing keys + endpoint. + +3. Make sure the provider issues tokens with a single ``aud`` claim set to + ``https:///realms/``. If the provider can't do + that, enable **Allows Client ID as audience for assertions** in the advanced + settings and set **Client ID** to the audience that the provider issues. + +4. Enable the option for the method that you use: + + - For federated client authentication, enable **Supports client + assertions**. Keycloak accepts each token only once by default. If the + workload can't get a new token for every request, also enable **Allows + client assertions to be re-used**. + - For the JWT authorization grant, enable **JWT Authorization Grant** in the + **Authorization Grant Settings** section. Keycloak rejects tokens that are + valid for longer than **Max allowed assertion expiration**, which is 5 + minutes by default. + +Federated client authentication +=============================== + +1. **Create a client for the workload** + + In **Clients**, create an OpenID Connect client with **Client + authentication** and **Service account roles** enabled. In the + **Credentials** tab, set **Client Authenticator** to **Signed JWT - + Federated**, set **Identity provider** to the alias of the provider that you + configured, and set **Federated subject** to the ``sub`` claim of the + workload's tokens. + + Realms created before Keycloak 26.6 don't include this authenticator in the + client authentication flow. In **Authentication**, duplicate the **clients** + flow, add the **Signed JWT - Federated** step as **Alternative**, and bind + the copy as the **Client authentication flow**. + +2. **Get a token from Keycloak** + + Send the token from your identity provider as the client assertion. Keycloak + finds the client from the token, so no client ID or secret is needed. .. code-block:: sh - curl -X POST "https:///realms/atmosphere/protocol/openid-connect/token" \ + curl -X POST "https:///realms//protocol/openid-connect/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ - -d "grant_type=urn:ietf:params:oauth:grant-type:token-exchange" \ - -d "client_id=" \ - -d "client_secret=" \ - -d "subject_token=" \ - -d "subject_token_type=urn:ietf:params:oauth:token-type:access_token" + -d "grant_type=client_credentials" \ + -d "client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer" \ + -d "client_assertion=" - The response will return a token that is issued by Keycloak which you can use - to authenticate with the OpenStack API. + The response contains a token for the client's service account, which + Keycloak names ``service-account-``. Assign OpenStack roles to + that user before you use the token with Keystone. .. code-block:: json { "access_token" : ".....", - "refresh_token" : ".....", "expires_in" : "...." } +JWT authorization grant +======================= -2. **Authenticate with Keystone Using the Keycloak Token** +1. **Create a client and link the users** + + In **Clients**, create an OpenID Connect client with **Client + authentication** enabled. In the **Capability config** section, enable + **JWT Authorization Grant**, then select the provider that you configured in + **Allowed Identity Providers for JWT Authorization Grant**. + + Keycloak looks up the user from the ``sub`` claim of the token, so each user + must already be linked to the provider. Keycloak links a user automatically + when they sign in through the provider, and you can check the link in the + user's **Identity provider links** tab. + +2. **Get a token from Keycloak** + + Replace ```` and ```` with the + credentials of the client that you created. + + .. code-block:: sh + + curl -X POST "https:///realms//protocol/openid-connect/token" \ + -H "Content-Type: application/x-www-form-urlencoded" \ + -d "grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer" \ + -d "client_id=" \ + -d "client_secret=" \ + -d "assertion=" + + The response contains an access token for the linked user. This grant never + returns a refresh token, so request a new token when it expires. + + .. code-block:: json + + { + "access_token" : ".....", + "expires_in" : "...." + } + +Use the Keycloak token with OpenStack +===================================== + +1. **Authenticate with Keystone Using the Keycloak Token** With the token issued by Keycloak, you can now authenticate with Keystone in order to obtain a fernet token which can be used to talk to all of the OpenStack APIs. @@ -97,7 +188,7 @@ issued by an identity provider which exists in the Keycloak realm. HTTP/1.1 201 Created X-Subject-Token: -3. **List projects using the Keystone Token** (optional, if you already know the project ID) +2. **List projects using the Keystone Token** (optional, if you already know the project ID) At this point, you have an unscoped token issued by Keystone which is not bound to any project. You will need to exchange that token for a project-scoped token @@ -130,7 +221,7 @@ issued by an identity provider which exists in the Keycloak realm. ] } -4. **Exchange the unscoped token for a project-scoped token** +3. **Exchange the unscoped token for a project-scoped token** Once you have identified the project that you want to interact with, you can exchange the unscoped token for a project-scoped token. diff --git a/galaxy.yml b/galaxy.yml index 01350be7..cfa0c34c 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -12,7 +12,7 @@ dependencies: ansible.posix: 1.6.0 ansible.utils: ">=2.9.0" community.crypto: 2.2.3 - community.general: 7.3.0 + community.general: 11.4.9 community.mysql: 3.6.0 kubernetes.core: 2.4.0 openstack.cloud: ">=2.0.0" diff --git a/pyproject.toml b/pyproject.toml index 52f16c47..07dc271e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ classifiers = [ "Programming Language :: Python :: Implementation :: CPython", ] dependencies = [ - "ansible-core>=2.15.9", + "ansible-core>=2.16.0", "docker-image-py>=0.1.12", "jmespath>=1.0.1", "netaddr>=0.8.0", diff --git a/releasenotes/notes/bump-keycloak-26-8-1-5f2f9b0f1df40c9f.yaml b/releasenotes/notes/bump-keycloak-26-8-1-5f2f9b0f1df40c9f.yaml new file mode 100644 index 00000000..39fbe938 --- /dev/null +++ b/releasenotes/notes/bump-keycloak-26-8-1-5f2f9b0f1df40c9f.yaml @@ -0,0 +1,32 @@ +--- +security: + - | + Keycloak is upgraded from ``24.0.5`` to ``26.8.1``, which includes all + upstream security fixes released since the previous version. +upgrade: + - | + The Keycloak database schema is migrated automatically when the new + version starts, and the migration can't be reversed. Take a backup of the + Keycloak database before upgrading so that you can roll back if needed. + Users need to sign in again after the upgrade. + - | + Keycloak metrics are now scraped from the management interface on port + ``9000``. + - | + Tokens from an external identity provider are now exchanged with + federated client authentication or the JWT authorization grant, which + replace the deprecated legacy token exchange. The authentication guide + describes how to set up both. + - | + The ``community.general`` collection is upgraded to ``11.4.9``, which + requires ``ansible-core`` 2.16 or later. +fixes: + - | + Strict mode on the database cluster is now relaxed and restored on every + node while Keycloak is deployed, instead of only on the node that serves + the connection. A mismatch between nodes could evict a database node from + the cluster during a Keycloak schema migration. + - | + The Keycloak clients for Alertmanager, Grafana and Prometheus are now + created as confidential clients. They were previously public clients, so + Keycloak ignored the client secrets that these services already use. diff --git a/requirements.txt b/requirements.txt index 038719c4..6a971a55 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -ansible-core>=2.15.9 +ansible-core>=2.16.0 jmespath>=1.0.1 openstacksdk>1 docker-image-py>=0.1.12 diff --git a/roles/defaults/vars/main.yml b/roles/defaults/vars/main.yml index 8cca2417..008917b0 100644 --- a/roles/defaults/vars/main.yml +++ b/roles/defaults/vars/main.yml @@ -115,7 +115,7 @@ _atmosphere_images: ironic_retrive_cleaning_network: "{{ atmosphere_image_prefix }}ghcr.io/vexxhost/heat:main@sha256:68f571a345c8b9dfb194fc50fbafb84335d5231eaa4420b1826fb3eef3c915cd" ironic_retrive_swift_config: "{{ atmosphere_image_prefix }}ghcr.io/vexxhost/heat:main@sha256:68f571a345c8b9dfb194fc50fbafb84335d5231eaa4420b1826fb3eef3c915cd" keepalived: "{{ atmosphere_image_prefix }}ghcr.io/vexxhost/keepalived:latest@sha256:74b5d510c9efcc4e073b3b8a1c46727571565e739fe5f7f710095072258912f1" - keycloak: "{{ atmosphere_image_prefix }}quay.io/keycloak/keycloak:24.0.5-0" + keycloak: "{{ atmosphere_image_prefix }}quay.io/keycloak/keycloak:26.8.1-1@sha256:a78d6b79572168cb25886b80a8b5b8d4ed4390743e3eecb810538683e209dd6b" keystone_api: "{{ atmosphere_image_prefix }}ghcr.io/vexxhost/keystone:main@sha256:cc47ed828419329971fbebd84b766b721821616ccc9f543cb5b603dc85ecf7f1" keystone_credential_cleanup: "{{ atmosphere_image_prefix }}ghcr.io/vexxhost/heat:main@sha256:68f571a345c8b9dfb194fc50fbafb84335d5231eaa4420b1826fb3eef3c915cd" keystone_credential_rotate: "{{ atmosphere_image_prefix }}ghcr.io/vexxhost/keystone:main@sha256:cc47ed828419329971fbebd84b766b721821616ccc9f543cb5b603dc85ecf7f1" diff --git a/roles/keycloak/tasks/main.yml b/roles/keycloak/tasks/main.yml index 66a5a64a..03615f5d 100644 --- a/roles/keycloak/tasks/main.yml +++ b/roles/keycloak/tasks/main.yml @@ -77,37 +77,68 @@ host: "%" priv: "{{ keycloak_database_name }}.*:ALL" -- name: Disable pxc strict mode +# NOTE(mnaser): Keycloak schema migrations write to tables without a primary +# key, which strict mode rejects. The mode must match on every +# node, otherwise a statement replicated to the cluster can +# succeed on one node and fail on the others, which evicts the +# node that ran it from the cluster. +- name: Get the Percona XtraDB Cluster pods run_once: true - community.mysql.mysql_query: - login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" - login_user: root - login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" - query: "set global pxc_strict_mode='PERMISSIVE'" - -- name: Deploy Helm chart - run_once: true - kubernetes.core.helm: - name: "{{ keycloak_helm_release_name }}" - chart_ref: "{{ keycloak_helm_chart_ref }}" - release_namespace: "{{ keycloak_helm_release_namespace }}" - create_namespace: true - kubeconfig: "{{ keycloak_helm_kubeconfig }}" - wait: true - timeout: "{{ keycloak_helm_timeout }}" - values: "{{ _keycloak_helm_values | combine(keycloak_helm_values, recursive=True) }}" - -- name: Wait until keycloak ready kubernetes.core.k8s_info: - api_version: apps/v1 - kind: StatefulSet - name: "{{ keycloak_helm_release_name }}" - namespace: "{{ keycloak_helm_release_namespace }}" - register: _keycloak_sts - retries: 120 - delay: 5 - until: - - _keycloak_sts.resources[0].status.replicas == _keycloak_sts.resources[0].status.readyReplicas + kind: Pod + namespace: openstack + label_selectors: + - app.kubernetes.io/component=pxc + - app.kubernetes.io/instance=percona-xtradb + register: _pxc_pods + +- name: Deploy Keycloak with relaxed strict mode + block: + - name: Disable pxc strict mode + run_once: true + community.mysql.mysql_query: + login_host: "{{ item.status.podIP }}" + login_user: root + login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" + query: "set global pxc_strict_mode='PERMISSIVE'" + loop: "{{ _pxc_pods.resources }}" + loop_control: + label: "{{ item.metadata.name }}" + + - name: Deploy Helm chart + run_once: true + kubernetes.core.helm: + name: "{{ keycloak_helm_release_name }}" + chart_ref: "{{ keycloak_helm_chart_ref }}" + release_namespace: "{{ keycloak_helm_release_namespace }}" + create_namespace: true + kubeconfig: "{{ keycloak_helm_kubeconfig }}" + wait: true + timeout: "{{ keycloak_helm_timeout }}" + values: "{{ _keycloak_helm_values | combine(keycloak_helm_values, recursive=True) }}" + + - name: Wait until keycloak ready + kubernetes.core.k8s_info: + api_version: apps/v1 + kind: StatefulSet + name: "{{ keycloak_helm_release_name }}" + namespace: "{{ keycloak_helm_release_namespace }}" + register: _keycloak_sts + retries: 120 + delay: 5 + until: + - _keycloak_sts.resources[0].status.replicas == _keycloak_sts.resources[0].status.readyReplicas + always: + - name: Enable pxc strict mode + run_once: true + community.mysql.mysql_query: + login_host: "{{ item.status.podIP }}" + login_user: root + login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" + query: "set global pxc_strict_mode='MASTER'" + loop: "{{ _pxc_pods.resources }}" + loop_control: + label: "{{ item.metadata.name }}" - name: Create Keycloak Ingress ansible.builtin.include_role: @@ -121,11 +152,3 @@ ingress_service_port: 80 ingress_secret_name: "{{ keycloak_host_tls_secret_name }}" ingress_annotations: "{{ _keycloak_ingress_annotations | combine(keycloak_ingress_annotations, recursive=True) }}" - -- name: Enable pxc strict mode - run_once: true - community.mysql.mysql_query: - login_host: "{{ _pxc_service.resources[0].spec.clusterIP }}" - login_user: root - login_password: "{{ openstack_helm_endpoints.oslo_db.auth.admin.password }}" - query: "set global pxc_strict_mode='MASTER'" diff --git a/roles/keycloak/vars/main.yml b/roles/keycloak/vars/main.yml index ead80fbb..106375cb 100644 --- a/roles/keycloak/vars/main.yml +++ b/roles/keycloak/vars/main.yml @@ -26,10 +26,15 @@ _keycloak_helm_values: # we have to define jdbc connection string explicitly along side # `externalDatabase` helm values. extraEnvVars: - - name: KC_FEATURES - value: "token-exchange,admin-fine-grained-authz" - - name: KC_PROXY - value: edge + - name: KC_BOOTSTRAP_ADMIN_USERNAME + value: "{{ keycloak_admin_username }}" + - name: KC_BOOTSTRAP_ADMIN_PASSWORD + valueFrom: + secretKeyRef: + key: admin-password + name: "{{ keycloak_helm_release_name }}" + - name: KC_PROXY_HEADERS + value: xforwarded - name: KC_DB value: mysql - name: KC_DB_URL @@ -48,9 +53,10 @@ _keycloak_helm_values: - --health-enabled=true - --http-enabled=true - --http-port=8080 + - --proxy-headers=xforwarded - --hostname-strict=false - - --spi-events-listener-jboss-logging-success-level=info - - --spi-events-listener-jboss-logging-error-level=warn + - --spi-events-listener--jboss-logging--success-level=info + - --spi-events-listener--jboss-logging--error-level=warn - --transaction-xa-enabled=false - --metrics-enabled=true auth: @@ -66,15 +72,35 @@ _keycloak_helm_values: registry: "{{ atmosphere_images['keycloak'] | vexxhost.kubernetes.docker_image('domain') }}" repository: "{{ atmosphere_images['keycloak'] | vexxhost.kubernetes.docker_image('path') }}" tag: "{{ atmosphere_images['keycloak'] | vexxhost.kubernetes.docker_image('tag') }}" + digest: "{{ atmosphere_images['keycloak'] | vexxhost.kubernetes.docker_image('digest') }}" postgresql: enabled: false production: true - proxy: edge + proxyHeaders: xforwarded + extraContainerPorts: + - name: management + containerPort: 9000 + protocol: TCP startupProbe: enabled: true initialDelaySeconds: 5 failureThreshold: 120 nodeSelector: openstack-control-plane: enabled + networkPolicy: + extraIngress: + - ports: + - port: 9000 + protocol: TCP metrics: enabled: true + service: + annotations: + prometheus.io/scrape: "false" + extraPorts: + - name: http-management + port: 9000 + protocol: TCP + targetPort: management + serviceMonitor: + enabled: false diff --git a/roles/keystone/tasks/main.yml b/roles/keystone/tasks/main.yml index eef34564..a168333e 100644 --- a/roles/keystone/tasks/main.yml +++ b/roles/keystone/tasks/main.yml @@ -15,7 +15,6 @@ - name: Create Keycloak realms no_log: true run_once: true - changed_when: false community.general.keycloak_realm: # Keycloak settings auth_keycloak_url: "{{ item.keycloak_server_url }}" diff --git a/roles/kube_prometheus_stack/tasks/main.yml b/roles/kube_prometheus_stack/tasks/main.yml index 4a286211..6838766c 100644 --- a/roles/kube_prometheus_stack/tasks/main.yml +++ b/roles/kube_prometheus_stack/tasks/main.yml @@ -25,7 +25,6 @@ - name: Create Keycloak realm no_log: true run_once: true - changed_when: false community.general.keycloak_realm: # Keycloak settings auth_keycloak_url: "{{ kube_prometheus_stack_keycloak_server_url }}" @@ -43,7 +42,6 @@ - name: Add client roles in "id_token" no_log: true run_once: true - changed_when: false community.general.keycloak_clientscope: # Keycloak settings auth_keycloak_url: "{{ kube_prometheus_stack_keycloak_server_url }}" @@ -55,15 +53,39 @@ # Client scope settings name: roles realm: "{{ kube_prometheus_stack_keycloak_realm }}" + # NOTE(mnaser): This is the built-in "roles" client scope, and the module + # compares the full list of protocol mappers, so all of the + # built-in mappers are listed with their default settings. + # Only "id.token.claim" on "client roles" is changed. Values + # are strings since that is how Keycloak returns them. protocol_mappers: + - name: realm roles + protocol: openid-connect + protocolMapper: oidc-usermodel-realm-role-mapper + config: + access.token.claim: "true" + claim.name: realm_access.roles + introspection.token.claim: "true" + jsonType.label: String + multivalued: "true" + user.attribute: foo + - name: audience resolve + protocol: openid-connect + protocolMapper: oidc-audience-resolve-mapper + config: + access.token.claim: "true" + introspection.token.claim: "true" - name: client roles protocol: openid-connect protocolMapper: oidc-usermodel-client-role-mapper config: + access.token.claim: "true" claim.name: "resource_access.${client_id}.roles" - access.token.claim: true - id.token.claim: true - multivalued: true + id.token.claim: "true" + introspection.token.claim: "true" + jsonType.label: String + multivalued: "true" + user.attribute: foo - name: Retrieve "etcd" CA certificate run_once: true @@ -151,6 +173,8 @@ # Realm settings realm: "{{ kube_prometheus_stack_keycloak_realm }}" client_id: "{{ secret.password.item.id }}" + client_authenticator_type: client-secret + public_client: false secret: "{{ secret.resources[0].data.password | b64decode }}" redirect_uris: "{{ secret.password.item.redirect_uris }}" protocol_mappers: diff --git a/roles/kube_prometheus_stack/vars/main.yml b/roles/kube_prometheus_stack/vars/main.yml index 9c3559fc..c5eca82c 100644 --- a/roles/kube_prometheus_stack/vars/main.yml +++ b/roles/kube_prometheus_stack/vars/main.yml @@ -532,7 +532,8 @@ _kube_prometheus_stack_helm_values: app.kubernetes.io/component: metrics app.kubernetes.io/name: keycloak endpoints: - - port: http + - port: http-management + path: /metrics relabelings: *relabelings_instance_to_pod_name - name: memcached jobLabel: application diff --git a/uv.lock b/uv.lock index 8c6c8032..e092315d 100644 --- a/uv.lock +++ b/uv.lock @@ -103,7 +103,7 @@ manila = [ [package.metadata] requires-dist = [ - { name = "ansible-core", specifier = ">=2.15.9" }, + { name = "ansible-core", specifier = ">=2.16.0" }, { name = "docker-image-py", specifier = ">=0.1.12" }, { name = "jmespath", specifier = ">=1.0.1" }, { name = "netaddr", specifier = ">=0.8.0" },