Skip to content

Commit 666a570

Browse files
michaelstinglbutonic
authored andcommitted
feat: implement external Keycloak support with standardized structure
- Restructure Keycloak configuration to follow internal/external pattern per issue opencloud-eu#64 - Fix unused keycloak.external.* fields (fixes opencloud-eu#75) - Enable proper external Keycloak configuration (fixes opencloud-eu#82) - Add 'roles' to WEB_OIDC_SCOPE for proper role mapping - Update all Keycloak template references to use new structure - Update README with new configuration examples and replica warning - Bump chart version to 0.2.0 (breaking change) BREAKING CHANGE: Keycloak configuration structure changed from keycloak.* to keycloak.internal.* and keycloak.external.* Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
1 parent 6b4a435 commit 666a570

File tree

12 files changed

+123
-89
lines changed

12 files changed

+123
-89
lines changed

charts/opencloud/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ maintainers:
1010
1111
url: https://opencloud.eu
1212
type: application
13-
version: 0.1.7
13+
version: 0.2.0
1414
# renovate: datasource=docker depName=opencloudeu/opencloud-rolling
1515
appVersion: latest
1616
kubeVersion: ""

charts/opencloud/README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,18 +275,49 @@ This will prepend `my-registry.com/` to all image references in the chart. For e
275275

276276
### Keycloak Settings
277277

278+
Keycloak configuration follows the standardized internal/external pattern (see issue #64).
279+
280+
#### Internal Keycloak
281+
282+
| Parameter | Description | Default |
283+
| --------- | ----------- | ------- |
284+
| `keycloak.internal.enabled` | Enable internal Keycloak deployment | `true` |
285+
| `keycloak.internal.image.repository` | Keycloak image repository | `quay.io/keycloak/keycloak` |
286+
| `keycloak.internal.image.tag` | Keycloak image tag | `26.1.4` |
287+
| `keycloak.internal.image.pullPolicy` | Image pull policy | `IfNotPresent` |
288+
| `keycloak.internal.replicas` | Number of replicas | `1` |
289+
| `keycloak.internal.adminUser` | Admin user | `admin` |
290+
| `keycloak.internal.adminPassword` | Admin password | `admin` |
291+
| `keycloak.internal.realm` | Realm name | `openCloud` |
292+
| `keycloak.internal.resources` | CPU/Memory resource requests/limits | `{}` |
293+
| `keycloak.internal.cors.enabled` | Enable CORS | `true` |
294+
| `keycloak.internal.cors.allowAllOrigins` | Allow all origins | `true` |
295+
296+
> **Note**: When using internal Keycloak with multiple OpenCloud replicas (`opencloud.replicas > 1`), you must use an external shared database or LDAP. The embedded IDM does not support replication. See [issue #53](https://github.com/opencloud-eu/helm/issues/53) for details.
297+
298+
#### External Keycloak
299+
278300
| Parameter | Description | Default |
279301
| --------- | ----------- | ------- |
280-
| `keycloak.enabled` | Enable Keycloak | `true` |
281-
| `keycloak.replicas` | Number of replicas | `1` |
282-
| `keycloak.adminUser` | Admin user | `admin` |
283-
| `keycloak.adminPassword` | Admin password | `admin` |
284-
| `keycloak.resources` | CPU/Memory resource requests/limits | `{}` |
285-
| `keycloak.realm` | Realm name | `openCloud` |
286-
| `keycloak.persistence.enabled` | Enable persistence | `true` |
287-
| `keycloak.persistence.size` | Size of the persistent volume | `1Gi` |
288-
| `keycloak.persistence.storageClass` | Storage class | `""` |
289-
| `keycloak.persistence.accessMode` | Access mode | `ReadWriteOnce` |
302+
| `keycloak.external.enabled` | Enable external Keycloak | `false` |
303+
| `keycloak.external.url` | External Keycloak URL (without /realms/...) | `""` |
304+
| `keycloak.external.realm` | External Keycloak realm | `openCloud` |
305+
| `keycloak.external.clientId` | External Keycloak client ID | `web` |
306+
307+
#### Example: Using External Keycloak
308+
309+
```yaml
310+
keycloak:
311+
internal:
312+
enabled: false
313+
external:
314+
enabled: true
315+
url: "https://keycloak.example.com"
316+
realm: "my-realm"
317+
clientId: "opencloud-web"
318+
```
319+
320+
**Note**: Only one of `keycloak.internal.enabled` or `keycloak.external.enabled` should be set to `true`.
290321

291322
### PostgreSQL Settings
292323

charts/opencloud/templates/keycloak/deployment.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.keycloak.enabled .Values.keycloak.internal.enabled }}
1+
{{- if .Values.keycloak.internal.enabled }}
22
apiVersion: apps/v1
33
kind: Deployment
44
metadata:
@@ -7,7 +7,7 @@ metadata:
77
{{- include "opencloud.labels" . | nindent 4 }}
88
app.kubernetes.io/component: keycloak
99
spec:
10-
replicas: {{ .Values.keycloak.replicas }}
10+
replicas: {{ .Values.keycloak.internal.replicas }}
1111
selector:
1212
matchLabels:
1313
{{- include "opencloud.selectorLabels" . | nindent 6 }}
@@ -24,8 +24,8 @@ spec:
2424
fsGroup: 1000
2525
containers:
2626
- name: keycloak
27-
image: {{ include "opencloud.image" (dict "imageValues" .Values.keycloak.image "global" .Values.global) | quote }}
28-
imagePullPolicy: {{ include "opencloud.image.pullPolicy" (dict "pullPolicy" .Values.keycloak.image.pullPolicy "global" .Values.global) }}
27+
image: {{ include "opencloud.image" (dict "imageValues" .Values.keycloak.internal.image "global" .Values.global) | quote }}
28+
imagePullPolicy: {{ include "opencloud.image.pullPolicy" (dict "pullPolicy" .Values.keycloak.internal.image.pullPolicy "global" .Values.global) }}
2929
securityContext:
3030
allowPrivilegeEscalation: false
3131
capabilities:
@@ -58,29 +58,29 @@ spec:
5858
- name: KC_FEATURES
5959
value: impersonation
6060
- name: KEYCLOAK_ADMIN
61-
value: {{ .Values.keycloak.adminUser }}
61+
value: {{ .Values.keycloak.internal.adminUser }}
6262
- name: KEYCLOAK_ADMIN_PASSWORD
63-
value: {{ .Values.keycloak.adminPassword }}
64-
{{- if .Values.keycloak.cors.enabled }}
63+
value: {{ .Values.keycloak.internal.adminPassword }}
64+
{{- if .Values.keycloak.internal.cors.enabled }}
6565
- name: KC_SPI_CORS_ENABLED
6666
value: "true"
67-
{{- if .Values.keycloak.cors.allowAllOrigins }}
67+
{{- if .Values.keycloak.internal.cors.allowAllOrigins }}
6868
- name: KC_SPI_CORS_ORIGINS
6969
value: "*"
7070
{{- else }}
7171
- name: KC_SPI_CORS_ORIGINS
72-
value: {{ join "," .Values.keycloak.cors.origins | quote }}
72+
value: {{ join "," .Values.keycloak.internal.cors.origins | quote }}
7373
{{- end }}
7474
- name: KC_SPI_CORS_METHODS
75-
value: {{ .Values.keycloak.cors.methods | quote }}
75+
value: {{ .Values.keycloak.internal.cors.methods | quote }}
7676
- name: KC_SPI_CORS_HEADERS
77-
value: {{ .Values.keycloak.cors.headers | quote }}
77+
value: {{ .Values.keycloak.internal.cors.headers | quote }}
7878
- name: KC_SPI_CORS_EXPOSED_HEADERS
79-
value: {{ .Values.keycloak.cors.exposedHeaders | quote }}
79+
value: {{ .Values.keycloak.internal.cors.exposedHeaders | quote }}
8080
- name: KC_SPI_CORS_ALLOW_CREDENTIALS
81-
value: {{ .Values.keycloak.cors.allowCredentials | quote }}
81+
value: {{ .Values.keycloak.internal.cors.allowCredentials | quote }}
8282
- name: KC_SPI_CORS_MAX_AGE
83-
value: {{ .Values.keycloak.cors.maxAge | quote }}
83+
value: {{ .Values.keycloak.internal.cors.maxAge | quote }}
8484
{{- end }}
8585
ports:
8686
- name: http
@@ -93,7 +93,7 @@ spec:
9393
mountPath: /opt/keycloak/data/import-dist/opencloud-realm.json
9494
subPath: opencloud-realm.json
9595
resources:
96-
{{- toYaml .Values.keycloak.resources | nindent 12 }}
96+
{{- toYaml .Values.keycloak.internal.resources | nindent 12 }}
9797
volumes:
9898
- name: script
9999
configMap:

charts/opencloud/templates/keycloak/ingress.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.ingress.enabled .Values.keycloak.enabled }}
1+
{{- if .Values.keycloak.internal.enabled }}
22
apiVersion: networking.k8s.io/v1
33
kind: Ingress
44
metadata:

charts/opencloud/templates/keycloak/realm-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.keycloak.enabled .Values.keycloak.internal.enabled }}
1+
{{- if .Values.keycloak.internal.enabled }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/opencloud/templates/keycloak/script-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.keycloak.enabled (not .Values.keycloak.external.enabled) }}
1+
{{- if .Values.keycloak.internal.enabled }}
22
apiVersion: v1
33
kind: ConfigMap
44
metadata:

charts/opencloud/templates/keycloak/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.keycloak.enabled .Values.keycloak.internal.enabled }}
1+
{{- if .Values.keycloak.internal.enabled }}
22
apiVersion: v1
33
kind: Service
44
metadata:

charts/opencloud/templates/opencloud/deployment.yaml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,26 @@ spec:
200200
- name: NOTIFICATIONS_SMTP_ENCRYPTION
201201
value: "{{ .Values.opencloud.smtp.encryption }}"
202202
{{- end }}
203-
{{- if .Values.keycloak.enabled }}
203+
{{- if or .Values.keycloak.internal.enabled .Values.keycloak.external.enabled }}
204204
# Keycloak IDP specific configuration
205205
- name: PROXY_AUTOPROVISION_ACCOUNTS
206206
value: "true"
207207
- name: PROXY_ROLE_ASSIGNMENT_DRIVER
208208
value: "oidc"
209209
- name: OC_OIDC_ISSUER
210-
value: "https://{{ include "opencloud.keycloak.domain" . }}/realms/{{ .Values.keycloak.realm }}"
210+
{{- if .Values.keycloak.external.enabled }}
211+
value: "{{ .Values.keycloak.external.url }}/realms/{{ .Values.keycloak.external.realm }}"
212+
{{- else }}
213+
value: "https://{{ include "opencloud.keycloak.domain" . }}/realms/{{ .Values.keycloak.internal.realm }}"
214+
{{- end }}
211215
- name: PROXY_OIDC_REWRITE_WELLKNOWN
212216
value: "true"
213217
- name: WEB_OIDC_CLIENT_ID
218+
{{- if .Values.keycloak.external.enabled }}
219+
value: "{{ .Values.keycloak.external.clientId }}"
220+
{{- else }}
214221
value: "web"
222+
{{- end }}
215223
- name: PROXY_USER_OIDC_CLAIM
216224
value: "preferred_username"
217225
- name: PROXY_USER_CS3_CLAIM
@@ -228,9 +236,13 @@ spec:
228236
- name: PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD
229237
value: "jwt"
230238
- name: WEB_OIDC_METADATA_URL
231-
value: "https://{{ include "opencloud.keycloak.domain" . }}/realms/{{ .Values.keycloak.realm }}/.well-known/openid-configuration"
239+
{{- if .Values.keycloak.external.enabled }}
240+
value: "{{ .Values.keycloak.external.url }}/realms/{{ .Values.keycloak.external.realm }}/.well-known/openid-configuration"
241+
{{- else }}
242+
value: "https://{{ include "opencloud.keycloak.domain" . }}/realms/{{ .Values.keycloak.internal.realm }}/.well-known/openid-configuration"
243+
{{- end }}
232244
- name: WEB_OIDC_SCOPE
233-
value: "openid profile email groups"
245+
value: "openid profile email groups roles"
234246
{{- end }}
235247
# Admin user password
236248
- name: IDM_ADMIN_PASSWORD

charts/opencloud/templates/postgres/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.postgres.enabled .Values.keycloak.enabled }}
1+
{{- if and .Values.postgres.enabled .Values.keycloak.internal.enabled }}
22
apiVersion: apps/v1
33
kind: Deployment
44
metadata:

charts/opencloud/templates/postgres/pvc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.postgres.enabled .Values.keycloak.enabled .Values.postgres.persistence.enabled }}
1+
{{- if and .Values.postgres.enabled .Values.keycloak.internal.enabled .Values.postgres.persistence.enabled }}
22
apiVersion: v1
33
kind: PersistentVolumeClaim
44
metadata:

0 commit comments

Comments
 (0)