-
Notifications
You must be signed in to change notification settings - Fork 13
[Mirror] Kubernetes/securitycontexts #7117
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
base: main
Are you sure you want to change the base?
Changes from all commits
b90ea65
c455fee
2bee3e3
225d3c1
3bd0e4f
8c3adea
5bfb810
30987e9
fd1e2bc
f9e87aa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| {{- define "loculus.podSecurityContext" -}} | ||
| {{- $args := . -}} | ||
| {{- $componentName := index $args 0 -}} | ||
| {{- $values := index $args 1 -}} | ||
|
|
||
| {{- if and $values.podSecurityContext (hasKey $values.podSecurityContext $componentName) }} | ||
| securityContext: | ||
| {{ toYaml (index $values.podSecurityContext $componentName) | indent 2 }} | ||
| {{- else if and $values.podSecurityContext (hasKey $values.podSecurityContext "default") }} | ||
| securityContext: | ||
| {{ toYaml $values.podSecurityContext.default | indent 2 }} | ||
| {{- end }} | ||
|
Comment on lines
+6
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two things about the
Neither is a bug, but (1) is the one likely to be hit in practice. |
||
| {{- end }} | ||
|
|
||
| {{- define "loculus.containerSecurityContext" -}} | ||
| {{- $args := . -}} | ||
| {{- $componentName := index $args 0 -}} | ||
| {{- $values := index $args 1 -}} | ||
|
|
||
| {{- if and $values.containerSecurityContext (hasKey $values.containerSecurityContext $componentName) }} | ||
| securityContext: | ||
| {{ toYaml (index $values.containerSecurityContext $componentName) | indent 2 }} | ||
| {{- else if and $values.containerSecurityContext (hasKey $values.containerSecurityContext "default") }} | ||
| securityContext: | ||
| {{ toYaml $values.containerSecurityContext.default | indent 2 }} | ||
| {{- end }} | ||
| {{- end }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing trailing newline at EOF. Also, the two defines are byte-identical apart from the values key. Worth collapsing into one helper to avoid the two drifting apart: and call it as |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,13 +23,15 @@ spec: | |
| spec: | ||
| {{- include "possiblePriorityClassName" . | nindent 6 }} | ||
| {{- include "loculus.podScheduling" . | nindent 6 }} | ||
| {{- include "loculus.podSecurityContext" (list "backend" $.Values) | nindent 6 }} | ||
| initContainers: | ||
| {{- include "loculus.configProcessor" (dict "name" "loculus-backend-config" "dockerTag" $dockerTag "imagePullPolicy" $.Values.imagePullPolicy) | nindent 8 }} | ||
| {{- include "loculus.configProcessor" (dict "name" "loculus-backend-config" "dockerTag" $dockerTag "imagePullPolicy" $.Values.imagePullPolicy "Values" $.Values) | nindent 8 }} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation of this line changed from column 0 to 4 while adding the |
||
| containers: | ||
| - name: backend | ||
| image: "{{ $.Values.images.backend.repository }}:{{ $.Values.images.backend.tag | default $dockerTag }}" | ||
| imagePullPolicy: "{{ $.Values.images.backend.pullPolicy | default $.Values.imagePullPolicy }}" | ||
| {{- include "loculus.resources" (list "backend" $.Values) | nindent 10 }} | ||
| {{- include "loculus.containerSecurityContext" (list "backend" $.Values) | nindent 10 }} | ||
| startupProbe: | ||
| httpGet: | ||
| path: "/actuator/health/liveness" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes
Valuesa required key of theloculus.configProcessordict — a caller that omits it fails withnil pointer evaluating interface {}.containerSecurityContext. All five current callers were updated, so this is correct today, but the contract is now implicit.Worth documenting the expected dict keys in a comment above the
define(the way_ingest-pod-spec.tpl:6-12does), so the next person adding a caller doesn't have to discover it from a render failure.