From 3beb68d94cf116421e5bcc6e7e2ae3ecd53a6693 Mon Sep 17 00:00:00 2001 From: Ryan Dawson Date: Mon, 11 Jun 2018 11:13:26 +0100 Subject: [PATCH] [stable/keycloak] option to set realm using start param (#5950) * option to set realm using start param * expose postStartScript * increment chart versions * don't change incubator * remove readme change to incubator * remove postStartScript and provide example for realm import * extra clarification * rename extraParams to extraArgs * Update README.md --- stable/keycloak/Chart.yaml | 2 +- stable/keycloak/README.md | 29 ++++++++++++++++++++++-- stable/keycloak/templates/configmap.yaml | 2 +- stable/keycloak/values.yaml | 3 +++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/stable/keycloak/Chart.yaml b/stable/keycloak/Chart.yaml index 33dde64d62..fe2d4939b7 100644 --- a/stable/keycloak/Chart.yaml +++ b/stable/keycloak/Chart.yaml @@ -1,5 +1,5 @@ name: keycloak -version: 1.1.1 +version: 1.2.0 appVersion: 3.4.3.Final description: Open Source Identity and Access Management For Modern Applications and Services keywords: diff --git a/stable/keycloak/README.md b/stable/keycloak/README.md index f6729a2991..1af8a7f570 100644 --- a/stable/keycloak/README.md +++ b/stable/keycloak/README.md @@ -62,6 +62,7 @@ Parameter | Description | Default `keycloak.tolerations` | Node taints to tolerate | `[]` `keycloak.securityContext` | Security context for the pod | `{runAsUser: 1000, fsGroup: 1000, runAsNonRoot: true}` `keycloak.preStartScript` | Custom script to run before Keycloak starts up | `` +`keycloak.extraArgs` | Additional arguments to the start command | `` `keycloak.livenessProbe.initialDelaySeconds` | Liveness Probe `initialDelaySeconds` | `120` `keycloak.livenessProbe.timeoutSeconds` | Liveness Probe `timeoutSeconds` | `5` `keycloak.readinessProbe.initialDelaySeconds` | Readiness Probe `initialDelaySeconds` | `30` @@ -149,11 +150,11 @@ See also: keycloak: extraEnv: - name: KEYCLOAK_LOGLEVEL - value: : DEBUG + value: DEBUG - name: WILDFLY_LOGLEVEL value: DEBUG - name: CACHE_OWNERS: - value"3" + value: "3" ``` ### Providing a Custom Theme @@ -196,6 +197,30 @@ keycloak: - name: theme emptyDir: {} ``` +### Setting a Custom Realm + +A realm can be added by creating a secret or configmap for the realm json file and then supplying this into the chart. +It could be mounted using `extraVolumeMounts` and then specified in `extraArgs` using `-Dimport`. +First we could create a Secret from a json file using `kubectl create secret generic realm-secret --from-file=realm.json` which we need to reference in `values.yaml`: + +```yaml +keycloak: + extraVolumes: + - name: realm-secret + secret: + secretName: realm-secret + + extraVolumeMounts: + - name: realm-secret + mountPath: "/realm/" + readOnly: true + + extraArgs: -Dkeycloak.import=/realm/realm.json +``` + +Alternatively, the file could be added to a custom image (set in `keycloak.image`) and then referenced by `-Dimport`. + +After startup the web admin console for the realm should be available on the path /auth/admin/\/console/ ### WildFly Configuration diff --git a/stable/keycloak/templates/configmap.yaml b/stable/keycloak/templates/configmap.yaml index 12899331d0..2e9b26602e 100644 --- a/stable/keycloak/templates/configmap.yaml +++ b/stable/keycloak/templates/configmap.yaml @@ -21,7 +21,7 @@ data: {{ . | indent 4 }} {{- end }} - exec /opt/jboss/docker-entrypoint.sh -b 0.0.0.0 {{- if $highAvailability }} --server-config standalone-ha.xml{{ end }} + exec /opt/jboss/docker-entrypoint.sh -b 0.0.0.0 {{ .Values.keycloak.extraArgs }}{{- if $highAvailability }} --server-config standalone-ha.xml{{ end }} exit "$?" keycloak.cli: | diff --git a/stable/keycloak/values.yaml b/stable/keycloak/values.yaml index 85e27ddc00..080636336f 100644 --- a/stable/keycloak/values.yaml +++ b/stable/keycloak/values.yaml @@ -29,6 +29,9 @@ keycloak: ## Custom script that is run before Keycloak is started. preStartScript: + ## Additional arguments to start command e.g. -Dkeycloak.import= to load a realm + extraArgs: + ## Username for the initial Keycloak admin user username: keycloak