Bitnami package for Keycloak

Keycloak is a high performance Java-based identity and access management solution. It lets developers add an authentication layer to their applications with minimum effort.

Overview of Keycloak

Trademarks: This software listing is packaged by Bitnami. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.

TL;DR

helm install my-release oci://registry-1.docker.io/bitnamicharts/keycloak

Looking to use Keycloak in production? Try VMware Tanzu Application Catalog, the enterprise edition of Bitnami Application Catalog.

Introduction

Bitnami charts for Helm are carefully engineered, actively maintained and are the quickest and easiest way to deploy containers on a Kubernetes cluster that are ready to handle production workloads.

This chart bootstraps a Keycloak deployment on a Kubernetes cluster using the Helm package manager.

Bitnami charts can be used with Kubeapps for deployment and management of Helm Charts in clusters.

Prerequisites

  • Kubernetes 1.23+
  • Helm 3.8.0+

Installing the Chart

To install the chart with the release name my-release:

helm install my-release oci://REGISTRY_NAME/REPOSITORY_NAME/keycloak

Note: You need to substitute the placeholders REGISTRY_NAME and REPOSITORY_NAME with a reference to your Helm chart registry and repository. For example, in the case of Bitnami, you need to use REGISTRY_NAME=registry-1.docker.io and REPOSITORY_NAME=bitnamicharts.

These commands deploy a Keycloak application on the Kubernetes cluster in the default configuration.

Tip: List all releases using helm list

Configuration and installation details

Resource requests and limits

Bitnami charts allow setting resource requests and limits for all containers inside the chart deployment. These are inside the resources value (check parameter table). Setting requests is essential for production workloads and these should be adapted to your specific use case.

To make this process easier, the chart contains the resourcesPreset values, which automatically sets the resources section according to different presets. Check these presets in the bitnami/common chart. However, in production workloads using resourcePreset is discouraged as it may not fully adapt to your specific needs. Find more information on container resource management in the official Kubernetes documentation.

Rolling vs Immutable tags

It is strongly recommended to use immutable tags in a production environment. This ensures your deployment does not change automatically if the same tag is updated with a different image.

Bitnami will release a new chart updating its containers if a new version of the main container, significant changes, or critical vulnerabilities exist.

Use an external database

Sometimes, you may want to have Keycloak connect to an external PostgreSQL database rather than a database within your cluster - for example, when using a managed database service, or when running a single database server for all your applications. To do this, set the postgresql.enabled parameter to false and specify the credentials for the external database using the externalDatabase.* parameters. Here is an example:

postgresql.enabled=false
externalDatabase.host=myexternalhost
externalDatabase.user=myuser
externalDatabase.password=mypassword
externalDatabase.database=mydatabase
externalDatabase.port=5432

NOTE: Only PostgreSQL database server is supported as external database

It is not supported but possible to run Keycloak with an external MSSQL database with the following settings:

externalDatabase:
  host: "mssql.example.com"
  port: 1433
  user: keycloak
  database: keycloak
  existingSecret: passwords
extraEnvVars:
  - name: KC_DB # override values from the conf file
    value: 'mssql'
  - name: KC_DB_URL
    value: 'jdbc:sqlserver://mssql.example.com:1433;databaseName=keycloak;'

Importing and exporting a realm

Importing a realm

You can import a realm by setting the KEYCLOAK_EXTRA_ARGS to contain the --import-realm argument.

This will import all *.json under /opt/bitnami/keycloak/data/import files as a realm into keycloak as per the official documentation here. You can supply the files by mounting a volume e.g. with docker compose as follows:

keycloak:
  image: bitnami/keycloak:latest
  volumes:
    - /local/path/to/realms/folder:/opt/bitnami/keycloak/data/import

Exporting a realm

You can export a realm through the GUI but it will not export users even the option is set, this is a known keycloak bug.

By using the kc.sh script you can export a realm with users. Be sure to mount the export folder to a local folder:

keycloak:
  image: bitnami/keycloak:latest
  volumes:
    - /local/path/to/export/folder:/export

Then open a terminal in the running keycloak container and run:

kc.sh export --dir /export/ --users realm_file 

This will export the all the realms with users to the /export folder.

Configure Ingress

This chart provides support for Ingress resources. If you have an ingress controller installed on your cluster, such as nginx-ingress-controller or contour you can utilize the ingress controller to serve your application.To enable Ingress integration, set ingress.enabled to true.

The most common scenario is to have one host name mapped to the deployment. In this case, the ingress.hostname property can be used to set the host name. The ingress.tls parameter can be used to add the TLS configuration for this host.

However, it is also possible to have more than one host. To facilitate this, the ingress.extraHosts parameter (if available) can be set with the host names specified as an array. The ingress.extraTLS parameter (if available) can also be used to add the TLS configuration for extra hosts.

NOTE: For each host specified in the ingress.extraHosts parameter, it is necessary to set a name, path, and any annotations that the Ingress controller should know about. Not all annotations are supported by all Ingress controllers, but this annotation reference document lists the annotations supported by many popular Ingress controllers.

Adding the TLS parameter (where available) will cause the chart to generate HTTPS URLs, and the application will be available on port 443. The actual TLS secrets do not have to be generated by this chart. However, if TLS is enabled, the Ingress record will not work until the TLS secret exists.

Learn more about Ingress controllers.

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.

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:

adminIngress:
  enabled: true
  hostname: keycloak-admin.example.com
keycloakConfigCli:
  enabled: true
  configuration:
    master.json: |
      {
        "realm" : "master",
        "attributes": {
          "frontendUrl": "https://keycloak-admin.example.com"
        }
      }

Configure TLS Secrets for use with Ingress

This chart facilitates the creation of TLS secrets for use with the Ingress controller (although this is not mandatory). There are several common use cases:

  • Generate certificate secrets based on chart parameters.
  • Enable externally generated certificates.
  • Manage application certificates via an external service (like cert-manager).
  • Create self-signed certificates within the chart (if supported).

In the first two cases, a certificate and a key are needed. Files are expected in .pem format.

Here is an example of a certificate file:

NOTE: There may be more than one certificate if there is a certificate chain.

-----BEGIN CERTIFICATE-----
MIID6TCCAtGgAwIBAgIJAIaCwivkeB5EMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
...
jScrvkiBO65F46KioCL9h5tDvomdU1aqpI/CBzhvZn1c0ZTf87tGQR8NK7v7
-----END CERTIFICATE-----

Here is an example of a certificate key:

-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAvLYcyu8f3skuRyUgeeNpeDvYBCDcgq+LsWap6zbX5f8oLqp4
...
wrj2wDbCDCFmfqnSJ+dKI3vFLlEz44sAV8jX/kd4Y6ZTQhlLbYc=
-----END RSA PRIVATE KEY-----
  • If using Helm to manage the certificates based on the parameters, copy these values into the certificate and key values for a given *.ingress.secrets entry.
  • If managing TLS secrets separately, it is necessary to create a TLS secret with name INGRESS_HOSTNAME-tls (where INGRESS_HOSTNAME is a placeholder to be replaced with the hostname you set using the *.ingress.hostname parameter).
  • If your cluster has a cert-manager add-on to automate the management and issuance of TLS certificates, add to *.ingress.annotations the corresponding ones for cert-manager.
  • If using self-signed certificates created by Helm, set both *.ingress.tls and *.ingress.selfSigned to true.

Use with ingress offloading SSL

If your ingress controller has the SSL Termination, you should set proxy to edge.

Manage secrets and passwords

This chart provides several ways to manage passwords:

  • Values passed to the chart: In this scenario, a new secret including all the passwords will be created during the chart installation. When upgrading, it is necessary to provide the secrets to the chart as shown below. Replace the KEYCLOAK_ADMIN_PASSWORD, POSTGRESQL_PASSWORD and POSTGRESQL_PVC placeholders with the correct passwords and PVC name.
helm upgrade keycloak bitnami/keycloak \
  --set auth.adminPassword=KEYCLOAK_ADMIN_PASSWORD \
  --set postgresql.postgresqlPassword=POSTGRESQL_PASSWORD \
  --set postgresql.persistence.existingClaim=POSTGRESQL_PVC
  • An existing secret with all the passwords via the existingSecret parameter.

Add extra environment variables

In case you want to add extra environment variables (useful for advanced operations like custom init scripts), you can use the extraEnvVars property.

extraEnvVars:
  - name: KEYCLOAK_LOG_LEVEL
    value: DEBUG

Alternatively, you can use a ConfigMap or a Secret with the environment variables. To do so, use the extraEnvVarsCM or the extraEnvVarsSecret values.

Use Sidecars and Init Containers

If additional containers are needed in the same pod (such as additional metrics or logging exporters), they can be defined using the sidecars config parameter.

sidecars:
- name: your-image-name
  image: your-image
  imagePullPolicy: Always
  ports:
  - name: portname
    containerPort: 1234

If these sidecars export extra ports, extra port definitions can be added using the service.extraPorts parameter (where available), as shown in the example below:

service:
  extraPorts:
  - name: extraPort
    port: 11311
    targetPort: 11311

NOTE: This Helm chart already includes sidecar containers for the Prometheus exporters (where applicable). These can be activated by adding the --enable-metrics=true parameter at deployment time. The sidecars parameter should therefore only be used for any extra sidecar containers.

If additional init containers are needed in the same pod, they can be defined using the initContainers parameter. Here is an example:

initContainers:
  - name: your-image-name
    image: your-image
    imagePullPolicy: Always
    ports:
      - name: portname
        containerPort: 1234

Learn more about sidecar containers and init containers.

Initialize a fresh instance

The Bitnami Keycloak image allows you to use your custom scripts to initialize a fresh instance. In order to execute the scripts, you can specify custom scripts using the initdbScripts parameter as dict.

In addition to this option, you can also set an external ConfigMap with all the initialization scripts. This is done by setting the initdbScriptsConfigMap parameter. Note that this will override the previous option.

The allowed extensions is .sh.

Deploy extra resources

There are cases where you may want to deploy extra objects, such a ConfigMap containing your app's configuration or some extra deployment with a micro service used by your app. For covering this case, the chart allows adding the full specification of other objects using the extraDeploy parameter.

Set Pod affinity

This chart allows you to set your custom affinity using the affinity parameter. Find more information about Pod's affinity in the kubernetes documentation.

As an alternative, you can use of the preset configurations for pod affinity, pod anti-affinity, and node affinity available at the bitnami/common chart. To do so, set the podAffinityPreset, podAntiAffinityPreset, or nodeAffinityPreset parameters.

Parameters

Global parameters

NameDescriptionValue
global.imageRegistryGlobal Docker image registry""
global.imagePullSecretsGlobal Docker registry secret names as an array[]
global.storageClassGlobal StorageClass for Persistent Volume(s)""
global.compatibility.openshift.adaptSecurityContextAdapt 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

NameDescriptionValue
kubeVersionForce target Kubernetes version (using Helm capabilities if not set)""
nameOverrideString to partially override common.names.fullname""
fullnameOverrideString to fully override common.names.fullname""
namespaceOverrideString to fully override common.names.namespace""
commonLabelsLabels to add to all deployed objects{}
enableServiceLinksIf set to false, disable Kubernetes service links in the pod spectrue
commonAnnotationsAnnotations to add to all deployed objects{}
dnsPolicyDNS Policy for pod""
dnsConfigDNS Configuration pod{}
clusterDomainDefault Kubernetes cluster domaincluster.local
extraDeployArray of extra objects to deploy with the release[]
diagnosticMode.enabledEnable diagnostic mode (all probes will be disabled and the command will be overridden)false
diagnosticMode.commandCommand to override all containers in the the statefulset["sleep"]
diagnosticMode.argsArgs to override all containers in the the statefulset["infinity"]

Keycloak parameters

NameDescriptionValue
image.registryKeycloak image registryREGISTRY_NAME
image.repositoryKeycloak image repositoryREPOSITORY_NAME/keycloak
image.digestKeycloak image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag""
image.pullPolicyKeycloak image pull policyIfNotPresent
image.pullSecretsSpecify docker-registry secret names as an array[]
image.debugSpecify if debug logs should be enabledfalse
auth.adminUserKeycloak administrator useruser
auth.adminPasswordKeycloak administrator password for the new user""
auth.existingSecretExisting secret containing Keycloak admin password""
auth.passwordSecretKeyKey where the Keycloak admin password is being stored inside the existing secret.""
auth.annotationsAdditional custom annotations for Keycloak auth secret object{}
tls.enabledEnable TLS encryption. Required for HTTPs traffic.false
tls.autoGeneratedGenerate automatically self-signed TLS certificates. Currently only supports PEM certificatesfalse
tls.existingSecretExisting secret containing the TLS certificates per Keycloak replica""
tls.usePemUse PEM certificates as input instead of PKS12/JKS storesfalse
tls.truststoreFilenameTruststore filename inside the existing secretkeycloak.truststore.jks
tls.keystoreFilenameKeystore filename inside the existing secretkeycloak.keystore.jks
tls.keystorePasswordPassword to access the keystore when it's password-protected""
tls.truststorePasswordPassword to access the truststore when it's password-protected""
tls.passwordsSecretSecret containing the Keystore and Truststore passwords.""
spi.existingSecretExisting secret containing the Keycloak truststore for SPI connection over HTTPS/TLS""
spi.truststorePasswordPassword to access the truststore when it's password-protected""
spi.truststoreFilenameTruststore filename inside the existing secretkeycloak-spi.truststore.jks
spi.passwordsSecretSecret containing the SPI Truststore passwords.""
spi.hostnameVerificationPolicyVerify the hostname of the server's certificate. Allowed values: "ANY", "WILDCARD", "STRICT".""
productionRun Keycloak in production mode. TLS configuration is required except when using proxy=edge.false
proxyreverse Proxy mode edge, reencrypt, passthrough or nonepassthrough
httpRelativePathSet the path relative to '/' for serving resources. Useful if you are migrating from older version which were using '/auth/'/
configurationKeycloak Configuration. Auto-generated based on other parameters when not specified""
existingConfigmapName of existing ConfigMap with Keycloak configuration""
extraStartupArgsExtra default startup args""
enableDefaultInitContainersDeploy default init containerstrue
initdbScriptsDictionary of initdb scripts{}
initdbScriptsConfigMapConfigMap with the initdb scripts (Note: Overrides initdbScripts)""
commandOverride default container command (useful when using custom images)[]
argsOverride default container args (useful when using custom images)[]
extraEnvVarsExtra environment variables to be set on Keycloak container[]
extraEnvVarsCMName of existing ConfigMap containing extra env vars""
extraEnvVarsSecretName of existing Secret containing extra env vars""

Keycloak statefulset parameters

NameDescriptionValue
replicaCountNumber of Keycloak replicas to deploy1
revisionHistoryLimitCountNumber of controller revisions to keep10
containerPorts.httpKeycloak HTTP container port8080
containerPorts.httpsKeycloak HTTPS container port8443
extraContainerPortsOptionally specify extra list of additional port-mappings for Keycloak container[]
statefulsetAnnotationsOptionally add extra annotations on the statefulset resource{}
podSecurityContext.enabledEnabled Keycloak pods' Security Contexttrue
podSecurityContext.fsGroupChangePolicySet filesystem group change policyAlways
podSecurityContext.sysctlsSet kernel settings using the sysctl interface[]
podSecurityContext.supplementalGroupsSet filesystem extra groups[]
podSecurityContext.fsGroupSet Keycloak pod's Security Context fsGroup1001
containerSecurityContext.enabledEnabled containers' Security Contexttrue
containerSecurityContext.seLinuxOptionsSet SELinux options in container{}
containerSecurityContext.runAsUserSet containers' Security Context runAsUser1001
containerSecurityContext.runAsGroupSet containers' Security Context runAsGroup1001
containerSecurityContext.runAsNonRootSet container's Security Context runAsNonRoottrue
containerSecurityContext.privilegedSet container's Security Context privilegedfalse
containerSecurityContext.readOnlyRootFilesystemSet container's Security Context readOnlyRootFilesystemtrue
containerSecurityContext.allowPrivilegeEscalationSet container's Security Context allowPrivilegeEscalationfalse
containerSecurityContext.capabilities.dropList of capabilities to be dropped["ALL"]
containerSecurityContext.seccompProfile.typeSet container's Security Context seccomp profileRuntimeDefault
resourcesPresetSet container resources according to one common preset (allowed values: none, nano, micro, small, medium, large, xlarge, 2xlarge). This is ignored if resources is set (resources is recommended for production).small
resourcesSet container requests and limits for different resources like CPU or memory (essential for production workloads){}
livenessProbe.enabledEnable livenessProbe on Keycloak containerstrue
livenessProbe.initialDelaySecondsInitial delay seconds for livenessProbe300
livenessProbe.periodSecondsPeriod seconds for livenessProbe1
livenessProbe.timeoutSecondsTimeout seconds for livenessProbe5
livenessProbe.failureThresholdFailure threshold for livenessProbe3
livenessProbe.successThresholdSuccess threshold for livenessProbe1
readinessProbe.enabledEnable readinessProbe on Keycloak containerstrue
readinessProbe.initialDelaySecondsInitial delay seconds for readinessProbe30
readinessProbe.periodSecondsPeriod seconds for readinessProbe10
readinessProbe.timeoutSecondsTimeout seconds for readinessProbe1
readinessProbe.failureThresholdFailure threshold for readinessProbe3
readinessProbe.successThresholdSuccess threshold for readinessProbe1
startupProbe.enabledEnable startupProbe on Keycloak containersfalse
startupProbe.initialDelaySecondsInitial delay seconds for startupProbe30
startupProbe.periodSecondsPeriod seconds for startupProbe5
startupProbe.timeoutSecondsTimeout seconds for startupProbe1
startupProbe.failureThresholdFailure threshold for startupProbe60
startupProbe.successThresholdSuccess threshold for startupProbe1
customLivenessProbeCustom Liveness probes for Keycloak{}
customReadinessProbeCustom Rediness probes Keycloak{}
customStartupProbeCustom Startup probes for Keycloak{}
lifecycleHooksLifecycleHooks to set additional configuration at startup{}
automountServiceAccountTokenMount Service Account token in podtrue
hostAliasesDeployment pod host aliases[]
podLabelsExtra labels for Keycloak pods{}
podAnnotationsAnnotations for Keycloak pods{}
podAffinityPresetPod affinity preset. Ignored if affinity is set. Allowed values: soft or hard""
podAntiAffinityPresetPod anti-affinity preset. Ignored if affinity is set. Allowed values: soft or hardsoft
nodeAffinityPreset.typeNode affinity preset type. Ignored if affinity is set. Allowed values: soft or hard""
nodeAffinityPreset.keyNode label key to match. Ignored if affinity is set.""
nodeAffinityPreset.valuesNode label values to match. Ignored if affinity is set.[]
affinityAffinity for pod assignment{}
nodeSelectorNode labels for pod assignment{}
tolerationsTolerations for pod assignment[]
topologySpreadConstraintsTopology Spread Constraints for pod assignment spread across your cluster among failure-domains. Evaluated as a template[]
podManagementPolicyPod management policy for the Keycloak statefulsetParallel
priorityClassNameKeycloak pods' Priority Class Name""
schedulerNameUse an alternate scheduler, e.g. "stork".""
terminationGracePeriodSecondsSeconds Keycloak pod needs to terminate gracefully""
updateStrategy.typeKeycloak statefulset strategy typeRollingUpdate
updateStrategy.rollingUpdateKeycloak statefulset rolling update configuration parameters{}
extraVolumesOptionally specify extra list of additional volumes for Keycloak pods[]
extraVolumeMountsOptionally specify extra list of additional volumeMounts for Keycloak container(s)[]
initContainersAdd additional init containers to the Keycloak pods[]
sidecarsAdd additional sidecar containers to the Keycloak pods[]

Exposure parameters

NameDescriptionValue
service.typeKubernetes service typeClusterIP
service.http.enabledEnable http port on servicetrue
service.ports.httpKeycloak service HTTP port80
service.ports.httpsKeycloak service HTTPS port443
service.nodePortsSpecify the nodePort values for the LoadBalancer and NodePort service types.{}
service.sessionAffinityControl where client requests go, to the same pod or round-robinNone
service.sessionAffinityConfigAdditional settings for the sessionAffinity{}
service.clusterIPKeycloak service clusterIP IP""
service.loadBalancerIPloadBalancerIP for the SuiteCRM Service (optional, cloud specific)""
service.loadBalancerSourceRangesAddress that are allowed when service is LoadBalancer[]
service.externalTrafficPolicyEnable client source IP preservationCluster
service.annotationsAdditional custom annotations for Keycloak service{}
service.extraPortsExtra port to expose on Keycloak service[]
service.extraHeadlessPortsExtra ports to expose on Keycloak headless service[]
service.headless.annotationsAnnotations for the headless service.{}
service.headless.extraPortsExtra ports to expose on Keycloak headless service[]
ingress.enabledEnable ingress record generation for Keycloakfalse
ingress.ingressClassNameIngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)""
ingress.pathTypeIngress path typeImplementationSpecific
ingress.apiVersionForce Ingress API version (automatically detected if not set)""
ingress.hostnameDefault host for the ingress record (evaluated as template)keycloak.local
ingress.pathDefault path for the ingress record (evaluated as template)""
ingress.servicePortBackend service port to usehttp
ingress.annotationsAdditional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.{}
ingress.labelsAdditional labels for the Ingress resource.{}
ingress.tlsEnable TLS configuration for the host defined at ingress.hostname parameterfalse
ingress.selfSignedCreate a TLS secret for this ingress record using self-signed certificates generated by Helmfalse
ingress.extraHostsAn array with additional hostname(s) to be covered with the ingress record[]
ingress.extraPathsAny additional arbitrary paths that may need to be added to the ingress under the main host.[]
ingress.extraTlsThe tls configuration for additional hostnames to be covered with this ingress record.[]
ingress.secretsIf you're providing your own certificates, please use this to add the certificates as secrets[]
ingress.extraRulesAdditional rules to be covered with this ingress record[]
adminIngress.enabledEnable admin ingress record generation for Keycloakfalse
adminIngress.ingressClassNameIngressClass that will be be used to implement the Ingress (Kubernetes 1.18+)""
adminIngress.pathTypeIngress path typeImplementationSpecific
adminIngress.apiVersionForce Ingress API version (automatically detected if not set)""
adminIngress.hostnameDefault host for the admin ingress record (evaluated as template)keycloak.local
adminIngress.pathDefault path for the admin ingress record (evaluated as template)""
adminIngress.servicePortBackend service port to usehttp
adminIngress.annotationsAdditional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations.{}
adminIngress.labelsAdditional labels for the Ingress resource.{}
adminIngress.tlsEnable TLS configuration for the host defined at adminIngress.hostname parameterfalse
adminIngress.selfSignedCreate a TLS secret for this ingress record using self-signed certificates generated by Helmfalse
adminIngress.extraHostsAn array with additional hostname(s) to be covered with the admin ingress record[]
adminIngress.extraPathsAny additional arbitrary paths that may need to be added to the admin ingress under the main host.[]
adminIngress.extraTlsThe tls configuration for additional hostnames to be covered with this ingress record.[]
adminIngress.secretsIf you're providing your own certificates, please use this to add the certificates as secrets[]
adminIngress.extraRulesAdditional rules to be covered with this ingress record[]
networkPolicy.enabledSpecifies whether a NetworkPolicy should be createdtrue
networkPolicy.allowExternalDon't require server label for connectionstrue
networkPolicy.allowExternalEgressAllow the pod to access any range of port and all destinations.true
networkPolicy.kubeAPIServerPortsList of possible endpoints to kube-apiserver (limit to your cluster settings to increase security)[]
networkPolicy.extraIngressAdd extra ingress rules to the NetworkPolicy[]
networkPolicy.extraEgressAdd extra ingress rules to the NetworkPolicy[]
networkPolicy.ingressNSMatchLabelsLabels to match to allow traffic from other namespaces{}
networkPolicy.ingressNSPodMatchLabelsPod labels to match to allow traffic from other namespaces{}

RBAC parameter

NameDescriptionValue
serviceAccount.createEnable the creation of a ServiceAccount for Keycloak podstrue
serviceAccount.nameName of the created ServiceAccount""
serviceAccount.automountServiceAccountTokenAuto-mount the service account token in the podfalse
serviceAccount.annotationsAdditional custom annotations for the ServiceAccount{}
serviceAccount.extraLabelsAdditional labels for the ServiceAccount{}
rbac.createWhether to create and use RBAC resources or notfalse
rbac.rulesCustom RBAC rules[]

Other parameters

NameDescriptionValue
pdb.createEnable/disable a Pod Disruption Budget creationtrue
pdb.minAvailableMinimum number/percentage of pods that should remain scheduled""
pdb.maxUnavailableMaximum number/percentage of pods that may be made unavailable""
autoscaling.enabledEnable autoscaling for Keycloakfalse
autoscaling.minReplicasMinimum number of Keycloak replicas1
autoscaling.maxReplicasMaximum number of Keycloak replicas11
autoscaling.targetCPUTarget CPU utilization percentage""
autoscaling.targetMemoryTarget Memory utilization percentage""
autoscaling.behavior.scaleUp.stabilizationWindowSecondsThe number of seconds for which past recommendations should be considered while scaling up120
autoscaling.behavior.scaleUp.selectPolicyThe priority of policies that the autoscaler will apply when scaling upMax
autoscaling.behavior.scaleUp.policiesHPA scaling policies when scaling up[]
autoscaling.behavior.scaleDown.stabilizationWindowSecondsThe number of seconds for which past recommendations should be considered while scaling down300
autoscaling.behavior.scaleDown.selectPolicyThe priority of policies that the autoscaler will apply when scaling downMax
autoscaling.behavior.scaleDown.policiesHPA scaling policies when scaling down[]

Metrics parameters

NameDescriptionValue
metrics.enabledEnable exposing Keycloak statisticsfalse
metrics.service.ports.httpMetrics service HTTP port8080
metrics.service.annotationsAnnotations for enabling prometheus to access the metrics endpoints{}
metrics.service.extraPortsAdd additional ports to the keycloak metrics service (i.e. admin port 9000)[]
metrics.serviceMonitor.enabledCreate ServiceMonitor Resource for scraping metrics using PrometheusOperatorfalse
metrics.serviceMonitor.portMetrics service HTTP porthttp
metrics.serviceMonitor.endpointsThe endpoint configuration of the ServiceMonitor. Path is mandatory. Interval, timeout and labellings can be overwritten.[]
metrics.serviceMonitor.pathMetrics service HTTP path. Deprecated: Use @param metrics.serviceMonitor.endpoints instead""
metrics.serviceMonitor.namespaceNamespace which Prometheus is running in""
metrics.serviceMonitor.intervalInterval at which metrics should be scraped30s
metrics.serviceMonitor.scrapeTimeoutSpecify the timeout after which the scrape is ended""
metrics.serviceMonitor.labelsAdditional labels that can be used so ServiceMonitor will be discovered by Prometheus{}
metrics.serviceMonitor.selectorPrometheus instance selector labels{}
metrics.serviceMonitor.relabelingsRelabelConfigs to apply to samples before scraping[]
metrics.serviceMonitor.metricRelabelingsMetricRelabelConfigs to apply to samples before ingestion[]
metrics.serviceMonitor.honorLabelshonorLabels chooses the metric's labels on collisions with target labelsfalse
metrics.serviceMonitor.jobLabelThe name of the label on the target service to use as the job name in prometheus.""
metrics.prometheusRule.enabledCreate PrometheusRule Resource for scraping metrics using PrometheusOperatorfalse
metrics.prometheusRule.namespaceNamespace which Prometheus is running in""
metrics.prometheusRule.labelsAdditional labels that can be used so PrometheusRule will be discovered by Prometheus{}
metrics.prometheusRule.groupsGroups, containing the alert rules.[]

keycloak-config-cli parameters

NameDescriptionValue
keycloakConfigCli.enabledWhether to enable keycloak-config-cli jobfalse
keycloakConfigCli.image.registrykeycloak-config-cli container image registryREGISTRY_NAME
keycloakConfigCli.image.repositorykeycloak-config-cli container image repositoryREPOSITORY_NAME/keycloak-config-cli
keycloakConfigCli.image.digestkeycloak-config-cli container image digest in the way sha256:aa.... Please note this parameter, if set, will override the tag""
keycloakConfigCli.image.pullPolicykeycloak-config-cli container image pull policyIfNotPresent
keycloakConfigCli.image.pullSecretskeycloak-config-cli container image pull secrets[]
keycloakConfigCli.annotationsAnnotations for keycloak-config-cli job{}
keycloakConfigCli.commandCommand for running the container (set to default if not set). Use array form[]
keycloakConfigCli.argsArgs for running the container (set to default if not set). Use array form[]
keycloakConfigCli.automountServiceAccountTokenMount Service Account token in podtrue
keycloakConfigCli.hostAliasesJob pod host aliases[]
keycloakConfigCli.resourcesPresetSet container resources according to one common preset (allowed values: none, nano, micro, small, medium, large, xlarge, 2xlarge). This is ignored if keycloakConfigCli.resources is set (keycloakConfigCli.resources is recommended for production).small
keycloakConfigCli.resourcesSet container requests and limits for different resources like CPU or memory (essential for production workloads){}
keycloakConfigCli.containerSecurityContext.enabledEnabled keycloak-config-cli Security Contexttrue
keycloakConfigCli.containerSecurityContext.seLinuxOptionsSet SELinux options in container{}
keycloakConfigCli.containerSecurityContext.runAsUserSet keycloak-config-cli Security Context runAsUser1001
keycloakConfigCli.containerSecurityContext.runAsGroupSet keycloak-config-cli Security Context runAsGroup1001
keycloakConfigCli.containerSecurityContext.runAsNonRootSet keycloak-config-cli Security Context runAsNonRoottrue
keycloakConfigCli.containerSecurityContext.privilegedSet keycloak-config-cli Security Context privilegedfalse
keycloakConfigCli.containerSecurityContext.readOnlyRootFilesystemSet keycloak-config-cli Security Context readOnlyRootFilesystemtrue
keycloakConfigCli.containerSecurityContext.allowPrivilegeEscalationSet keycloak-config-cli Security Context allowPrivilegeEscalationfalse
keycloakConfigCli.containerSecurityContext.capabilities.dropList of capabilities to be dropped["ALL"]
keycloakConfigCli.containerSecurityContext.seccompProfile.typeSet keycloak-config-cli Security Context seccomp profileRuntimeDefault
keycloakConfigCli.podSecurityContext.enabledEnabled keycloak-config-cli pods' Security Contexttrue
keycloakConfigCli.podSecurityContext.fsGroupChangePolicySet filesystem group change policyAlways
keycloakConfigCli.podSecurityContext.sysctlsSet kernel settings using the sysctl interface[]
keycloakConfigCli.podSecurityContext.supplementalGroupsSet filesystem extra groups[]
keycloakConfigCli.podSecurityContext.fsGroupSet keycloak-config-cli pod's Security Context fsGroup1001
keycloakConfigCli.backoffLimitNumber of retries before considering a Job as failed1
keycloakConfigCli.podLabelsPod extra labels{}
keycloakConfigCli.podAnnotationsAnnotations for job pod{}
keycloakConfigCli.extraEnvVarsAdditional environment variables to set[]
keycloakConfigCli.nodeSelectorNode labels for pod assignment{}
keycloakConfigCli.podTolerationsTolerations for job pod assignment[]
keycloakConfigCli.extraEnvVarsCMConfigMap with extra environment variables""
keycloakConfigCli.extraEnvVarsSecretSecret with extra environment variables""
keycloakConfigCli.extraVolumesExtra volumes to add to the job[]
keycloakConfigCli.extraVolumeMountsExtra volume mounts to add to the container[]
keycloakConfigCli.initContainersAdd additional init containers to the Keycloak config cli pod[]
keycloakConfigCli.sidecarsAdd additional sidecar containers to the Keycloak config cli pod[]
keycloakConfigCli.configurationkeycloak-config-cli realms configuration{}
keycloakConfigCli.existingConfigmapConfigMap with keycloak-config-cli configuration""
keycloakConfigCli.cleanupAfterFinished.enabledEnables Cleanup for Finished Jobsfalse
keycloakConfigCli.cleanupAfterFinished.secondsSets the value of ttlSecondsAfterFinished600

Database parameters

NameDescriptionValue
postgresql.enabledSwitch to enable or disable the PostgreSQL helm charttrue
postgresql.auth.postgresPasswordPassword for the "postgres" admin user. Ignored if auth.existingSecret with key postgres-password is provided""
postgresql.auth.usernameName for a custom user to createbn_keycloak
postgresql.auth.passwordPassword for the custom user to create""
postgresql.auth.databaseName for a custom database to createbitnami_keycloak
postgresql.auth.existingSecretName of existing secret to use for PostgreSQL credentials""
postgresql.architecturePostgreSQL architecture (standalone or replication)standalone
externalDatabase.hostDatabase host""
externalDatabase.portDatabase port number5432
externalDatabase.userNon-root username for Keycloakbn_keycloak
externalDatabase.passwordPassword for the non-root username for Keycloak""
externalDatabase.databaseKeycloak database namebitnami_keycloak
externalDatabase.existingSecretName of an existing secret resource containing the database credentials""
externalDatabase.existingSecretHostKeyName of an existing secret key containing the database host name""
externalDatabase.existingSecretPortKeyName of an existing secret key containing the database port""
externalDatabase.existingSecretUserKeyName of an existing secret key containing the database user""
externalDatabase.existingSecretDatabaseKeyName of an existing secret key containing the database name""
externalDatabase.existingSecretPasswordKeyName of an existing secret key containing the database credentials""
externalDatabase.annotationsAdditional custom annotations for external database secret object{}

Keycloak Cache parameters

NameDescriptionValue
cache.enabledSwitch to enable or disable the keycloak distributed cache for kubernetes.true
cache.stackNameSet infinispan cache stack to usekubernetes
cache.stackFileSet infinispan cache stack filename to use""

Keycloak Logging parameters

NameDescriptionValue
logging.outputAlternates between the default log output format or json formatdefault
logging.levelAllowed values as documented: FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL, OFFINFO

Specify each parameter using the --set key=value[,key=value] argument to helm install. For example,

helm install my-release --set auth.adminPassword=secretpassword oci://REGISTRY_NAME/REPOSITORY_NAME/keycloak

Note: You need to substitute the placeholders REGISTRY_NAME and REPOSITORY_NAME with a reference to your Helm chart registry and repository. For example, in the case of Bitnami, you need to use REGISTRY_NAME=registry-1.docker.io and REPOSITORY_NAME=bitnamicharts.

The above command sets the Keycloak administrator password to secretpassword.

NOTE: Once this chart is deployed, it is not possible to change the application's access credentials, such as usernames or passwords, using Helm. To change these application credentials after deployment, delete any persistent volumes (PVs) used by the chart and re-deploy it, or use the application's built-in administrative tools if available.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

helm install my-release -f values.yaml oci://REGISTRY_NAME/REPOSITORY_NAME/keycloak

Note: You need to substitute the placeholders REGISTRY_NAME and REPOSITORY_NAME with a reference to your Helm chart registry and repository. For example, in the case of Bitnami, you need to use REGISTRY_NAME=registry-1.docker.io and REPOSITORY_NAME=bitnamicharts. Tip: You can use the default values.yaml

Keycloak realms, users and clients can be created from the Keycloak administration panel.

Troubleshooting

Find more information about how to deal with common errors related to Bitnami's Helm charts in this troubleshooting guide.

Upgrading

To 21.0.0

This major release updates the keycloak branch to its newest major, 24.x.x. Follow the upstream documentation for upgrade instructions.

To 20.0.0

This major bump changes the following security defaults:

  • runAsGroup is changed from 0 to 1001
  • readOnlyRootFilesystem is set to true
  • resourcesPreset is changed from none to the minimum size working in our test suites (NOTE: resourcesPreset is not meant for production usage, but resources adapted to your use case).
  • global.compatibility.openshift.adaptSecurityContext is changed from disabled to auto.

This could potentially break any customization or init scripts used in your deployment. If this is the case, change the default values to the previous ones.

To 19.0.0

This major release bumps the PostgreSQL chart version to 14.x.x; no major issues are expected during the upgrade.

To 17.0.0

This major updates the PostgreSQL subchart to its newest major, 13.0.0. Here you can find more information about the changes introduced in that version.

To 15.0.0

This major updates the default serviceType from LoadBalancer to ClusterIP to avoid inadvertently exposing Keycloak directly to the internet without an Ingress.

To 12.0.0

This major updates the PostgreSQL subchart to its newest major, 12.0.0. Here you can find more information about the changes introduced in that version.

To 10.0.0

This major release updates Keycloak to its major version 19. Please, refer to the official Keycloak migration documentation for a complete list of changes and further information.

To 9.0.0

This major release updates Keycloak to its major version 18. Please, refer to the official Keycloak migration documentation for a complete list of changes and further information.

To 8.0.0

This major release updates Keycloak to its major version 17. Among other features, this new version has deprecated WildFly in favor of Quarkus, which introduces breaking changes like:

  • Removal of /auth from the default context path.
  • Changes in the configuration and deployment of custom providers.
  • Significant changes in configuring Keycloak.

Please, refer to the official Keycloak migration documentation and Migrating to Quarkus distribution document for a complete list of changes and further information.

To 7.0.0

This major release updates the PostgreSQL subchart to its newest major 11.x.x, which contain several changes in the supported values (check the upgrade notes to obtain more information).

Upgrading Instructions

To upgrade to 7.0.0 from 6.x, it should be done reusing the PVC(s) used to hold the data on your previous release. To do so, follow the instructions below (the following example assumes that the release name is keycloak and the release namespace default):

  1. Obtain the credentials and the names of the PVCs used to hold the data on your current release:
export KEYCLOAK_PASSWORD=$(kubectl get secret --namespace default keycloak -o jsonpath="{.data.admin-password}" | base64 --decode)
export POSTGRESQL_PASSWORD=$(kubectl get secret --namespace default keycloak-postgresql -o jsonpath="{.data.postgresql-password}" | base64 --decode)
export POSTGRESQL_PVC=$(kubectl get pvc -l app.kubernetes.io/instance=keycloak,app.kubernetes.io/name=postgresql,role=primary -o jsonpath="{.items[0].metadata.name}")
  1. Delete the PostgreSQL statefulset (notice the option --cascade=false) and secret:
kubectl delete statefulsets.apps --cascade=false keycloak-postgresql
kubectl delete secret keycloak-postgresql --namespace default
  1. Upgrade your release using the same PostgreSQL version:
CURRENT_PG_VERSION=$(kubectl exec keycloak-postgresql-0 -- bash -c 'echo $BITNAMI_IMAGE_VERSION')
helm upgrade keycloak bitnami/keycloak \
  --set auth.adminPassword=$KEYCLOAK_PASSWORD \
  --set postgresql.image.tag=$CURRENT_PG_VERSION \
  --set postgresql.auth.password=$POSTGRESQL_PASSWORD \
  --set postgresql.persistence.existingClaim=$POSTGRESQL_PVC
  1. Delete the existing PostgreSQL pods and the new statefulset will create a new one:
kubectl delete pod keycloak-postgresql-0

To 1.0.0

On November 13, 2020, Helm v2 support was formally finished, this major version is the result of the required changes applied to the Helm Chart to be able to incorporate the different features added in Helm v3 and to be consistent with the Helm project itself regarding the Helm v2 EOL.

What changes were introduced in this major version?

  • Previous versions of this Helm Chart use apiVersion: v1 (installable by both Helm 2 and 3), this Helm Chart was updated to apiVersion: v2 (installable by Helm 3 only). Here you can find more information about the apiVersion field.
  • Move dependency information from the requirements.yaml to the Chart.yaml
  • After running helm dependency update, a Chart.lock file is generated containing the same structure used in the previous requirements.lock
  • The different fields present in the Chart.yaml file has been ordered alphabetically in a homogeneous way for all the Bitnami Helm Chart.

Considerations when upgrading to this version

  • If you want to upgrade to this version using Helm v2, this scenario is not supported as this version does not support Helm v2 anymore.
  • If you installed the previous version with Helm v2 and wants to upgrade to this version with Helm v3, please refer to the official Helm documentation about migrating from Helm v2 to v3.

Useful links

License

Copyright © 2024 Broadcom. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.