Skip to content

Commit d2d64bd

Browse files
authored
Merge pull request opencloud-eu#84 from michaelstingl/fix/external-keycloak-75-82
feat: implement external Keycloak support (fixes opencloud-eu#75, opencloud-eu#82)
2 parents 6b4a435 + be6e734 commit d2d64bd

File tree

13 files changed

+124
-121
lines changed

13 files changed

+124
-121
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
email: info@opencloud.eu
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: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ This will prepend `my-registry.com/` to all image references in the chart. For e
224224
| `global.domain.wopi` | Domain for WOPI server | `wopiserver.opencloud.test` |
225225
| `global.tls.enabled` | Enable TLS (set to false when using gateway TLS termination externally) | `false` |
226226
| `global.tls.secretName` | secretName for TLS certificate | `""` |
227+
| `global.oidc.issuer` | OpenID Connect Issuer URL | `""` generated to use the internal keycloak|
228+
| `global.oidc.clientId` | OpenID Connect Client ID used by OpenCloud | `"web"` |
227229
| `global.storage.storageClass` | Storage class for persistent volumes | `""` |
228230
| `global.image.registry` | Global registry override for all images (e.g., `my-registry.com`) | `""` |
229231
| `global.image.pullPolicy` | Global pull policy override for all images (`Always`, `IfNotPresent`, `Never`) | `""` |
@@ -275,18 +277,40 @@ This will prepend `my-registry.com/` to all image references in the chart. For e
275277

276278
### Keycloak Settings
277279

280+
By default the chart deploys an internal keycloak. It can be disabled and replaced with an external IdP.
281+
282+
#### Internal Keycloak
283+
278284
| Parameter | Description | Default |
279285
| --------- | ----------- | ------- |
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` |
286+
| `keycloak.internal.enabled` | Enable internal Keycloak deployment | `true` |
287+
| `keycloak.internal.image.repository` | Keycloak image repository | `quay.io/keycloak/keycloak` |
288+
| `keycloak.internal.image.tag` | Keycloak image tag | `26.1.4` |
289+
| `keycloak.internal.image.pullPolicy` | Image pull policy | `IfNotPresent` |
290+
| `keycloak.internal.replicas` | Number of replicas | `1` |
291+
| `keycloak.internal.adminUser` | Admin user | `admin` |
292+
| `keycloak.internal.adminPassword` | Admin password | `admin` |
293+
| `keycloak.internal.realm` | Realm name | `openCloud` |
294+
| `keycloak.internal.resources` | CPU/Memory resource requests/limits | `{}` |
295+
| `keycloak.internal.cors.enabled` | Enable CORS | `true` |
296+
| `keycloak.internal.cors.allowAllOrigins` | Allow all origins | `true` |
297+
298+
> **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.
299+
300+
#### Example: Using External IDP
301+
302+
```yaml
303+
global:
304+
oidc:
305+
issuer: "https://idp.example.com/realms/openCloud"
306+
clientId: "opencloud-web"
307+
308+
keycloak:
309+
internal:
310+
enabled: false
311+
```
312+
313+
**Note**: If `keycloak.internal.enabled` is `true`, the `global.oidc.issuer` should be left empty to not override the generated issuer URL.
290314

291315
### PostgreSQL Settings
292316

charts/opencloud/templates/gateway/keycloak-https-httproute.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if and .Values.httpRoute.enabled .Values.keycloak.enabled (not .Values.keycloak.external.enabled) }}
1+
{{- if and .Values.httpRoute.enabled .Values.keycloak.internal.enabled }}
22
apiVersion: gateway.networking.k8s.io/v1beta1
33
kind: HTTPRoute
44
metadata:

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: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,18 +200,25 @@ spec:
200200
- name: NOTIFICATIONS_SMTP_ENCRYPTION
201201
value: "{{ .Values.opencloud.smtp.encryption }}"
202202
{{- end }}
203-
{{- if .Values.keycloak.enabled }}
204-
# Keycloak IDP specific configuration
203+
{{- if or .Values.keycloak.internal.enabled .Values.global.oidc.issuer }}
204+
# IDP specific configuration
205205
- name: PROXY_AUTOPROVISION_ACCOUNTS
206206
value: "true"
207+
# user properties are edited in the idp, so we hate to make them readonly
208+
- name: FRONTEND_READONLY_USER_ATTRIBUTES
209+
value: "user.onPremisesSamAccountName,user.displayName,user.mail,user.passwordProfile,user.accountEnabled,user.appRoleAssignments"
207210
- name: PROXY_ROLE_ASSIGNMENT_DRIVER
208211
value: "oidc"
209212
- name: OC_OIDC_ISSUER
210-
value: "https://{{ include "opencloud.keycloak.domain" . }}/realms/{{ .Values.keycloak.realm }}"
213+
{{- if .Values.global.oidc.issuer }}
214+
value: {{ .Values.global.oidc.issuer | quote }}
215+
{{- else }}
216+
value: {{ printf "https://%s/realms/%s" (include "opencloud.keycloak.domain" .) .Values.keycloak.internal.realm | quote }}
217+
{{- end }}
211218
- name: PROXY_OIDC_REWRITE_WELLKNOWN
212219
value: "true"
213220
- name: WEB_OIDC_CLIENT_ID
214-
value: "web"
221+
value: {{ .Values.global.oidc.clientId | quote}}
215222
- name: PROXY_USER_OIDC_CLAIM
216223
value: "preferred_username"
217224
- name: PROXY_USER_CS3_CLAIM
@@ -222,15 +229,18 @@ spec:
222229
value: "false"
223230
- name: GRAPH_USERNAME_MATCH
224231
value: "none"
225-
# Additional OIDC settings from docker-compose
226232
- name: PROXY_ROLE_ASSIGNMENT_OIDC_CLAIM
227233
value: "roles"
228234
- name: PROXY_OIDC_ACCESS_TOKEN_VERIFY_METHOD
229235
value: "jwt"
230236
- name: WEB_OIDC_METADATA_URL
231-
value: "https://{{ include "opencloud.keycloak.domain" . }}/realms/{{ .Values.keycloak.realm }}/.well-known/openid-configuration"
237+
{{- if .Values.global.oidc.issuer }}
238+
value: {{ printf "%s/.well-known/openid-configuration" .Values.global.oidc.issuer | quote }}
239+
{{- else }}
240+
value: {{ printf "https://%s/realms/%s/.well-known/openid-configuration" (include "opencloud.keycloak.domain" .) .Values.keycloak.internal.realm | quote }}
241+
{{- end }}
232242
- name: WEB_OIDC_SCOPE
233-
value: "openid profile email groups"
243+
value: "openid profile email groups roles"
234244
{{- end }}
235245
# Admin user password
236246
- 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:

0 commit comments

Comments
 (0)