Skip to content

Commit 4f35acc

Browse files
sgaistolevski
andauthored
refactor: harmonize security context handling (#4077)
* refactor: harmonize security context handling securityContext content was defined in multiple different manifests. Their content being hard coded there made them unsuitable for modifications such as required for OpenShift deployment. This patch makes them all use the content coming from the values file since they were mostly all using the same values. * chore: reconcile the two security contexts PRs (#4074) --------- Co-authored-by: Tasko Olevski <tasko.olevski@sdsc.ethz.ch>
1 parent 2c59293 commit 4f35acc

12 files changed

Lines changed: 49 additions & 42 deletions

helm-chart/renku/templates/_certificates-init-container.tpl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
- name: init-certificates
44
image: "{{ .Values.global.certificates.image.repository }}:{{ .Values.global.certificates.image.tag }}"
55
securityContext:
6-
allowPrivilegeEscalation: false
7-
runAsUser: 1000
8-
runAsGroup: 1000
9-
runAsNonRoot: true
6+
{{- toYaml .Values.securityContext | nindent 4 }}
107
volumeMounts:
118
- name: etc-ssl-certs
129
mountPath: /etc/ssl/certs/

helm-chart/renku/templates/authz/deployment.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ spec:
3636
# and the database migration will not read the db connection uri string from an env variable
3737
image: "{{ .Values.authz.image.repository }}:{{ .Values.authz.image.tag }}-debug"
3838
imagePullPolicy: {{ .Values.authz.image.pullPolicy }}
39+
securityContext:
40+
{{- toYaml .Values.securityContext | nindent 12 }}
3941
env:
4042
- name: "SPICEDB_DATASTORE_CONN_URI"
4143
valueFrom:

helm-chart/renku/templates/setup-job-authz-db.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ spec:
1818
chart: {{ template "renku.chart" . }}
1919
spec:
2020
restartPolicy: Never
21+
securityContext:
22+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
2123
containers:
2224
- name: initialize-postgres-authz
2325
image: "{{ .Values.initDb.image.repository }}:{{ .Values.initDb.image.tag }}"
2426
args: [ "authz_db_init.py" ]
2527
securityContext:
26-
runAsUser: 1000
27-
runAsGroup: 1000
28-
allowPrivilegeEscalation: false
29-
runAsNonRoot: true
28+
{{- toYaml .Values.securityContext | nindent 12 }}
3029
env:
3130
- name: DB_HOST
3231
value: {{ template "postgresql.fullname" . }}

helm-chart/renku/templates/setup-job-keycloak-db.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,14 @@ spec:
1919
chart: {{ template "renku.chart" . }}
2020
spec:
2121
restartPolicy: Never
22+
securityContext:
23+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
2224
containers:
2325
- name: initialize-postgres-keycloak
2426
image: "{{ .Values.initDb.image.repository }}:{{ .Values.initDb.image.tag }}"
2527
args: [ "keycloak_db_init.py" ]
2628
securityContext:
27-
runAsUser: 1000
28-
runAsGroup: 1000
29-
allowPrivilegeEscalation: false
30-
runAsNonRoot: true
29+
{{- toYaml .Values.securityContext | nindent 12 }}
3130
env:
3231
- name: DB_HOST
3332
value: {{ template "postgresql.fullname" . }}

helm-chart/renku/templates/setup-job-keycloak-realms.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@ spec:
2020
chart: {{ template "renku.chart" . }}
2121
spec:
2222
restartPolicy: Never
23+
securityContext:
24+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
2325
initContainers:
2426
{{- include "certificates.initContainer" . | nindent 8 }}
2527
containers:
2628
- name: init-keycloak
2729
image: "{{ .Values.keycloakx.initRealm.image.repository }}:{{ .Values.keycloakx.initRealm.image.tag }}"
2830
securityContext:
29-
runAsUser: 1000
30-
runAsGroup: 1000
31-
allowPrivilegeEscalation: false
32-
runAsNonRoot: true
31+
{{- toYaml .Values.securityContext | nindent 12 }}
3332
command: ["python"]
3433
args: [
3534
"/app/init-realm.py",

helm-chart/renku/templates/setup-job-platform-init.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ spec:
2020
chart: {{ template "renku.chart" . }}
2121
spec:
2222
restartPolicy: Never
23+
securityContext:
24+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
2325
containers:
2426
- name: initialize-platform
2527
image: "{{ .Values.platformInit.image.repository }}:{{ .Values.platformInit.image.tag }}"
2628
args: [ "platform-init.py" ]
2729
securityContext:
28-
runAsUser: 1000
29-
runAsGroup: 1000
30-
allowPrivilegeEscalation: false
31-
runAsNonRoot: true
30+
{{- toYaml .Values.securityContext | nindent 12 }}
3231
env:
3332
- name: K8S_NAMESPACE
3433
value: {{ .Release.Namespace }}

helm-chart/renku/templates/setup-job-renku-dbs.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ spec:
1818
chart: {{ template "renku.chart" . }}
1919
spec:
2020
restartPolicy: Never
21+
securityContext:
22+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
2123
containers:
2224
- name: initialize-postgres-renku
2325
image: "{{ .Values.initDb.image.repository }}:{{ .Values.initDb.image.tag }}"
2426
args: [ "renku_db_init.py" ]
2527
securityContext:
26-
runAsUser: 1000
27-
runAsGroup: 1000
28-
allowPrivilegeEscalation: false
29-
runAsNonRoot: true
28+
{{- toYaml .Values.securityContext | nindent 12 }}
3029
env:
3130
- name: DB_HOST
3231
value: {{ template "postgresql.fullname" . }}

helm-chart/renku/templates/tests/test-renku.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ metadata:
77
annotations:
88
"helm.sh/hook": test
99
spec:
10+
securityContext:
11+
{{- toYaml .Values.podSecurityContext | nindent 4 }}
1012
volumes:
1113
- name: dshm
1214
emptyDir:
@@ -15,6 +17,8 @@ spec:
1517
containers:
1618
- name: sbt
1719
image: {{ .Values.tests.image.repository }}:{{ .Values.tests.image.tag }}
20+
securityContext:
21+
{{- toYaml .Values.securityContext | nindent 6 }}
1822
env:
1923
- name: RENKU_TEST_URL
2024
value: '{{ template "renku.http" . }}://{{ .Values.global.renku.domain }}'

helm-chart/renku/templates/ui/ui-client-deployment-template.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ spec:
113113
resources:
114114
{{ toYaml .Values.ui.client.resources | indent 12 }}
115115
securityContext:
116-
{{- toYaml .Values.ui.client.securityContext | nindent 12 }}
116+
{{- toYaml .Values.securityContext | nindent 12 }}
117117
{{- with .Values.ui.client.nodeSelector }}
118118
nodeSelector:
119119
{{ toYaml . | indent 8 }}
@@ -127,7 +127,7 @@ spec:
127127
{{ toYaml . | indent 8 }}
128128
{{- end }}
129129
securityContext:
130-
{{- toYaml .Values.ui.client.podSecurityContext | nindent 8 }}
130+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
131131
{{- if .Values.ui.client.image.pullSecrets }}
132132
imagePullSecrets:
133133
{{- range .Values.ui.client.image.pullSecrets }}

helm-chart/renku/templates/ui/ui-server-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ spec:
2929
{{- toYaml . | nindent 8 }}
3030
{{- end }}
3131
securityContext:
32-
{{- toYaml .Values.ui.server.podSecurityContext | nindent 8 }}
32+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
3333
automountServiceAccountToken: {{ .Values.global.debug }}
3434
initContainers:
3535
{{- include "certificates.initContainer" . | nindent 8 }}
3636
containers:
3737
- name: {{ .Chart.Name }}
3838
securityContext:
39-
{{- toYaml .Values.ui.server.securityContext | nindent 12 }}
39+
{{- toYaml .Values.securityContext | nindent 12 }}
4040
image: "{{ .Values.ui.server.image.repository }}:{{ .Values.ui.server.image.tag }}"
4141
imagePullPolicy: {{ .Values.ui.server.image.pullPolicy }}
4242
ports:

0 commit comments

Comments
 (0)