Back to Charts

Keycloak

incubator/keycloak/README.md

latest9.6 KB
Original Source

Keycloak


NOTE: This chart has been DEPRECATED. Please use stable/keycloak.


Keycloak is an open source identity and access management for modern applications and services.

TL;DR;

console
$ helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator
$ helm install incubator/keycloak

Introduction

This chart bootstraps a Keycloak StatefulSet on a Kubernetes cluster using the Helm package manager. It provisions a fully featured Keycloak installation. For more information on Keycloak and its capabilities, see its documentation.

Prerequisites Details

The chart has an optional dependency on the PostgreSQL chart. By default, the PostgreSQL chart requires PV support on underlying infrastructure (may be disabled).

Installing the Chart

To install the chart with the release name keycloak:

console
$ helm install --name keycloak incubator/keycloak

Uninstalling the Chart

To uninstall/delete the keycloak deployment:

console
$ helm delete keycloak

Configuration

The following table lists the configurable parameters of the Keycloak chart and their default values.

ParameterDescriptionDefault
init.image.repositoryInit image repositoryalpine
init.image.tagInit image tag3.6
init.image.pullPolicyInit image pull policyIfNotPresent
keycloak.replicasThe number of Keycloak replicas1
keycloak.image.repositoryThe Keycloak image repositoryjboss/keycloak
keycloak.image.tagThe Keycloak image tag3.4.3.Final
keycloak.image.pullPolicyThe Keycloak image pull policyIfNotPresent
keycloak.image.pullSecretsSpecify image pull secretsnil (does not add image pull secrets to deployed pods)
keycloak.usernameUsername for the initial Keycloak admin userkeycloak
keycloak.passwordPassword for the initial Keycloak admin user. If not set, a random 10 characters password is created""
keycloak.extraEnvAllows the specification of additional environment variables for Keycloak[]
keycloak.extraVolumeMountsAdd additional volumes mounts, e. g. for custom themes[]
keycloak.extraVolumesAdd additional volumes, e. g. for custom themes[]
keycloak.podDisruptionBudgetPod disruption budget{}
keycloak.resourcesPod resource requests and limits{}
keycloak.affinityPod affinity``
keycloak.nodeSelectorNode labels for pod assignment{}
keycloak.tolerationsNode taints to tolerate[]
keycloak.securityContextSecurity context for the pod{runAsUser: 1000, fsGroup: 1000, runAsNonRoot: true}
keycloak.preStartScriptCustom script to run before Keycloak starts up``
keycloak.livenessProbe.initialDelaySecondsLiveness Probe initialDelaySeconds120
keycloak.livenessProbe.timeoutSecondsLiveness Probe timeoutSeconds5
keycloak.readinessProbe.initialDelaySecondsReadiness Probe initialDelaySeconds30
keycloak.readinessProbe.timeoutSecondsReadiness Probe timeoutSeconds1
keycloak.cli.nodeIdentifierWildFly CLI script for setting the node identifierSee values.yaml
keycloak.cli.loggingWildFly CLI script for logging configurationSee values.yaml
keycloak.cli.reverseProxyWildFly CLI script for reverse proxy configurationSee values.yaml
keycloak.cli.discoveryWildFly CLI script for cluster discoverySee values.yaml
keycloak.cli.customAdditional custom WildFly CLI script""
keycloak.service.annotationsAnnotations for the Keycloak service{}
keycloak.service.labelsAdditional labels for the Keycloak service{}
keycloak.service.typeThe service typeClusterIP
keycloak.service.portThe service port80
keycloak.service.nodePortThe node port used if the service is of type NodePort""
keycloak.ingress.enabledif true, an ingress is createdfalse
keycloak.ingress.annotationsannotations for the ingress{}
keycloak.ingress.pathif true, an ingress is created/
keycloak.ingress.hostsa list of ingress hosts[keycloak.example.com]
keycloak.ingress.tlsa list of IngressTLS items[]
keycloak.persistence.deployPostgresIf true, the PostgreSQL chart is installedtrue
keycloak.persistence.existingSecretName of an existing secret to be used for the database password (if keycloak.persistence.deployPostgres=false). Otherwise a new secret is created""
keycloak.persistence.existingSecretKeyThe key for the database password in the existing secret (if keycloak.persistence.deployPostgres=false)password
keycloak.persistence.dbVendorOne of H2, POSTGRES, or MYSQL (if deployPostgres=false)H2
keycloak.persistence.dbNameThe name of the database to connect to (if deployPostgres=false)keycloak
keycloak.persistence.dbHostThe database host name (if deployPostgres=false)mykeycloak
keycloak.persistence.dbPortThe database host port (if deployPostgres=false)5432
keycloak.persistence.dbUserThe database user (if deployPostgres=false)keycloak
keycloak.persistence.dbPasswordThe database password (if deployPostgres=false)keycloak
postgresql.postgresUserThe PostgreSQL user (if keycloak.persistence.deployPostgres=true)keycloak
postgresql.postgresPasswordThe PostgreSQL password (if keycloak.persistence.deployPostgres=true)""
postgresql.postgresDatabaseThe PostgreSQL database (if keycloak.persistence.deployPostgres=true)keycloak
test.image.repositoryTest image repositoryunguiculus/docker-python3-phantomjs-selenium
test.image.tagTest image tagv1
test.image.pullPolicyTest image pull policyIfNotPresent

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

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

bash
$ helm install --name keycloak -f values.yaml incubator/keycloak

Database Setup

By default, the PostgreSQL chart is deployed and used as database. Please refer to this chart for additional PostgreSQL configuration options. If PostgreSQL is disabled, Keycloak uses an embedded H2 database which is only suitable for testing with a single replica.

Using an External Database

The Keycloak Docker image supports PostgreSQL and MySQL. The password for the database user is read from a Kubernetes secret. It is possible to specify an existing secret that is not managed with this chart. The key in the secret the password is read from may be specified as well (defaults to password).

yaml
keycloak:
  persistence:

    # Disable deployment of the PostgreSQL chart
    deployPostgres: false

    # Optionally specify an existing secret
    existingSecret: "my-database-password-secret"
    existingSecretKey: "password-key in-my-database-secret"

    dbVendor: POSTGRES # for MySQL use "MYSQL"

    dbName: keycloak
    dbHost: mykeycloak
    dbPort: 5432 # 5432 is PostgreSQL's default port. For MySQL it would be 3306
    dbUser: keycloak

    # Only used if no existing secret is specified. In this case a new secret is created
    dbPassword: keycloak

See also:

Configuring additional environment variables:

yaml
keycloak:
  extraEnv:
    - name: KEYCLOAK_LOGLEVEL
      value: : DEBUG
    - name: WILDFLY_LOGLEVEL
      value: DEBUG
    - name: CACHE_OWNERS:
      value"3"

WildFly Configuration

WildFly can be configured via its command line interface (CLI). This chart uses the official Keycloak Docker image and customizes the installation running CLI scripts at server startup.

In order to make further customization easier, the CLI commands are separated by their concerns into smaller scripts. Everything is in values.yaml and can be overridden. Additional CLI commands may be added via keycloak.cli.custom, which is empty by default.

High Availability and Clustering

For high availability, Keycloak should be run with multiple replicas (keycloak.replicas > 1). WildFly uses Infinispan for caching. These caches can be replicated across all instances forming a cluster. If keycloak.replicas > 1, the WildFly CLI script keycloak.cli.discovery adds JGroups' JDBC_PING for cluster discovery and Keycloak is started with --server-config standalone-ha.xml.

Why StatefulSet?

The chart sets node identifiers to the system property jboss.node.name which is in fact the pod name. Node identifiers must not be longer than 23 characters. This can be problematic because pod names are quite long. We would have to truncate the chart's fullname to six characters because pods get a 17-character suffix (e. g. -697f8b7655-mf5ht). Using a StatefulSet allows us to truncate to 20 characters leaving room for up to 99 replicas, which is much better. Additionally, we get stable values for jboss.node.name which can be advantageous for cluster discovery.