Skip to content

Commit

Permalink
Add securityContext to initContainers (#602)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit-K authored Jan 7, 2025
1 parent bcc97ec commit f898b2c
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helm/polaris/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ spec:
imagePullPolicy: {{ tpl .Values.toolsImage.pullPolicy . }}
command: ["jar"]
args: ["-cf", "/eclipselink-config/conf.jar", "-C", "/secret", "persistence.xml"]
{{- if .Values.securityContext}}
securityContext:
{{- tpl (toYaml .Values.securityContext) . | nindent 12 }}
{{- end }}
volumeMounts:
- name: eclipselink-config-volume
mountPath: /eclipselink-config
Expand Down
4 changes: 4 additions & 0 deletions helm/polaris/templates/job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ spec:
imagePullPolicy: {{ tpl .Values.toolsImage.pullPolicy . }}
command: ["jar"]
args: ["-cf", "/eclipselink-config/conf.jar", "-C", "/secret", "persistence.xml"]
{{- if .Values.securityContext}}
securityContext:
{{- tpl (toYaml .Values.securityContext) . | nindent 12 }}
{{- end }}
volumeMounts:
- name: eclipselink-config-volume
mountPath: /eclipselink-config
Expand Down
24 changes: 24 additions & 0 deletions helm/polaris/tests/deployment_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,30 @@ tests:
content:
runAsUser: 1000

# spec.template.spec.containers[0].securityContext
- it: should not set initContainer securityContext by default
set:
persistenceConfigSecret: polaris-persistence-secret
polarisServerConfig:
metaStoreManager:
conf-file: /eclipselink-config/conf.jar!/persistence.xml
asserts:
- notExists:
path: spec.template.spec.initContainers[0].securityContext
- it: should set initContainer securityContext
set:
persistenceConfigSecret: polaris-persistence-secret
polarisServerConfig:
metaStoreManager:
conf-file: /eclipselink-config/conf.jar!/persistence.xml
securityContext:
runAsUser: 1000
asserts:
- isSubset:
path: spec.template.spec.initContainers[0].securityContext
content:
runAsUser: 1000

# spec.template.spec.containers[0].image
- it: should set container image
set:
Expand Down
26 changes: 26 additions & 0 deletions helm/polaris/tests/job_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,32 @@ tests:
content:
runAsUser: 1000

# spec.template.spec.containers[0].securityContext (with bootstrapMetastoreManager enabled)
- it: should not set initContainer securityContext by default
set:
bootstrapMetastoreManager: true
persistenceConfigSecret: polaris-persistence-secret
polarisServerConfig:
metaStoreManager:
conf-file: /eclipselink-config/conf.jar!/persistence.xml
asserts:
- notExists:
path: spec.template.spec.initContainers[0].securityContext
- it: should set initContainer securityContext
set:
bootstrapMetastoreManager: true
persistenceConfigSecret: polaris-persistence-secret
polarisServerConfig:
metaStoreManager:
conf-file: /eclipselink-config/conf.jar!/persistence.xml
securityContext:
runAsUser: 1000
asserts:
- isSubset:
path: spec.template.spec.initContainers[0].securityContext
content:
runAsUser: 1000

# spec.template.spec.containers[0].image (with bootstrapMetastoreManager enabled)
- it: should set container image
set:
Expand Down

0 comments on commit f898b2c

Please sign in to comment.