Skip to content

Commit 9e530e4

Browse files
denniseffingunguiculus
authored andcommitted
[keycloak] Fix iptables permission denied error on Istio 1.1.2 and below (#25)
Istio 1.1.2 and below does not include an explicit security context configuration for its init containers. They instead inherit the security context configuration defined on the PodSpecification level. This change splits security context config into separate pod and container security contexts. This allows for a more fine grained security context configuration and is less obtrusive regarding additionally injected containers. Fixes: #24 Signed-off-by: Dennis Effing <[email protected]>
1 parent aaa513b commit 9e530e4

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

charts/keycloak/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: keycloak
2-
version: 4.13.1
2+
version: 4.13.2
33
appVersion: 5.0.0
44
description: Open Source Identity and Access Management For Modern Applications and Services
55
keywords:

charts/keycloak/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ Parameter | Description | Default
7070
`keycloak.podAnnotations` | Extra annotations to add to pod | `{}`
7171
`keycloak.hostAliases` | Mapping between IP and hostnames that will be injected as entries in the pod's hosts files | `[]`
7272
`keycloak.enableServiceLinks` | Indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links | `false`
73-
`keycloak.securityContext` | Security context for the pod | `{runAsUser: 1000, fsGroup: 1000, runAsNonRoot: true}`
73+
`keycloak.securityContext` | Security context for the entire pod. Every container running in the pod will inherit this security context. This might be relevant when other components of the environment inject additional containers into running pods (service meshs are the most prominent example for this) | `{fsGroup: 1000}`
74+
`keycloak.containerSecurityContext` | Security context for containers running in the pod. Will not be inherited by additionally injected containers | `{runAsUser: 1000, runAsNonRoot: true}`
7475
`keycloak.preStartScript` | Custom script to run before Keycloak starts up | ``
7576
`keycloak.lifecycleHooks` | Container lifecycle hooks. Passed through the `tpl` function and thus to be configured a string | ``
7677
`keycloak.extraArgs` | Additional arguments to the start command | ``
@@ -117,7 +118,8 @@ Parameter | Description | Default
117118
`test.image.repository` | Test image repository | `unguiculus/docker-python3-phantomjs-selenium`
118119
`test.image.tag` | Test image tag | `v1`
119120
`test.image.pullPolicy` | Test image pull policy | `IfNotPresent`
120-
`test.securityContext` | Security context for the test pod | `{runAsUser: 1000, fsGroup: 1000, runAsNonRoot: true}`
121+
`test.securityContext` | Security context for the test pod. Every container running in the pod will inherit this security context. This might be relevant when other components of the environment inject additional containers into the running pod (service meshs are the most prominent example for this) | `{fsGroup: 1000}`
122+
`test.containerSecurityContext` | Security context for containers running in the test pod. Will not be inherited by additionally injected containers | `{runAsUser: 1000, runAsNonRoot: true}`
121123

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

charts/keycloak/templates/statefulset.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ spec:
5151
- name: wait-for-postgresql
5252
image: "{{ .Values.init.image.repository }}:{{ .Values.init.image.tag }}"
5353
imagePullPolicy: {{ .Values.init.image.pullPolicy }}
54+
securityContext:
55+
{{ toYaml .Values.keycloak.containerSecurityContext | indent 12 }}
5456
command:
5557
- sh
5658
- -c
@@ -69,6 +71,8 @@ spec:
6971
- name: {{ .Chart.Name }}
7072
image: "{{ .Values.keycloak.image.repository }}:{{ .Values.keycloak.image.tag }}"
7173
imagePullPolicy: {{ .Values.keycloak.image.pullPolicy }}
74+
securityContext:
75+
{{ toYaml .Values.keycloak.containerSecurityContext | indent 12 }}
7276
command:
7377
- /scripts/keycloak.sh
7478
{{- if .Values.keycloak.lifecycleHooks }}

charts/keycloak/templates/test/test-pod.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ metadata:
1313
"helm.sh/hook": test-success
1414
spec:
1515
securityContext:
16-
{{ toYaml .Values.test.securityContext | indent 8 }}
16+
{{ toYaml .Values.test.securityContext | indent 4 }}
1717
containers:
1818
- name: {{ .Chart.Name }}-test
1919
image: "{{ .Values.test.image.repository }}:{{ .Values.test.image.tag }}"
2020
imagePullPolicy: {{ .Values.test.image.pullPolicy }}
21+
securityContext:
22+
{{ toYaml .Values.test.containerSecurityContext | indent 8 }}
2123
command:
2224
- python3
2325
- /tests/test.py

charts/keycloak/values.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ keycloak:
2929
enableServiceLinks: false
3030

3131
securityContext:
32-
runAsUser: 1000
3332
fsGroup: 1000
33+
34+
containerSecurityContext:
35+
runAsUser: 1000
3436
runAsNonRoot: true
3537

3638
## The path keycloak will be served from. To serve keycloak from the root path, use two quotes (e.g. "").
@@ -288,6 +290,7 @@ test:
288290
tag: v1
289291
pullPolicy: IfNotPresent
290292
securityContext:
291-
runAsUser: 1000
292293
fsGroup: 1000
294+
containerSecurityContext:
295+
runAsUser: 1000
293296
runAsNonRoot: true

0 commit comments

Comments
 (0)