Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helm: add securityContext to initContainers #602

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Gerrit-K marked this conversation as resolved.
Show resolved Hide resolved
{{- 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
Loading