Skip to content

Commit 74cde3c

Browse files
feat: Add ability to define securityContext and podSecurityContext (#178)
Signed-off-by: Marco Maurer <mkilchhofer@users.noreply.github.com> Co-authored-by: Joshua Wright <19779568+joshw123@users.noreply.github.com>
1 parent 96547b7 commit 74cde3c

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

deploy/charts/version-checker/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ A Helm chart for version-checker
4040
| livenessProbe.initialDelaySeconds | int | `3` | Number of seconds after the container has started before liveness probes are initiated. |
4141
| livenessProbe.periodSeconds | int | `3` | How often (in seconds) to perform the livenessProbe. |
4242
| nodeSelector | object | `{}` | Configure nodeSelector |
43+
| podSecurityContext | object | `{}` | Set pod-level security context |
4344
| prometheus.enabled | bool | `false` | Deploy a Prometheus-Operator Prometheus Object to collect version-checker metrics |
4445
| prometheus.replicas | int | `1` | Number of Prometheus replicas to create |
4546
| prometheus.serviceAccountName | string | `"prometheus"` | ServiceAccount for new Prometheus Object |
@@ -51,6 +52,7 @@ A Helm chart for version-checker
5152
| readinessProbe.periodSeconds | int | `3` | How often (in seconds) to perform the readinessProbe. |
5253
| replicaCount | int | `1` | Replica Count for version-checker |
5354
| resources | object | `{}` | Setup version-checkers resource requests/limits |
55+
| securityContext | object | `{}` | Set container-level security context |
5456
| selfhosted | []{name: "", host: "", username:"", password:"", token:""}] | `[]` | Setup a number of SelfHosted Repositories and their credentials |
5557
| service.annotations | object | `{}` | Additional annotations to add to the service |
5658
| service.labels | object | `{}` | Additional labels to add to the service |

deploy/charts/version-checker/templates/deployment.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ spec:
5454
- "--test-all-containers={{.Values.versionChecker.testAllContainers}}"
5555
resources:
5656
{{- toYaml .Values.resources | nindent 12 }}
57+
{{- with .Values.securityContext }}
58+
securityContext:
59+
{{- toYaml . | nindent 10 }}
60+
{{- end }}
5761
{{- if .Values.livenessProbe.enabled }}
5862
livenessProbe:
5963
{{- omit .Values.livenessProbe "enabled" | toYaml | nindent 10}}
@@ -202,7 +206,10 @@ spec:
202206
{{- if .Values.env }}
203207
{{- toYaml .Values.env | nindent 8 }}
204208
{{- end }}
205-
209+
{{- with .Values.podSecurityContext }}
210+
securityContext:
211+
{{- toYaml . | nindent 8 }}
212+
{{- end }}
206213
volumes:
207214
{{- if $secretEnabled }}
208215
- name: {{ include "version-checker.name" . }}

deploy/charts/version-checker/tests/deployment_test.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,3 +425,21 @@ tests:
425425
- equal:
426426
path: spec.template.metadata.annotations["foo"]
427427
value: bar
428+
429+
- it: (Pod-)SecurityContext is reflected
430+
set:
431+
podSecurityContext:
432+
runAsUser: 65534
433+
securityContext:
434+
allowPrivilegeEscalation: false
435+
readOnlyRootFilesystem: true
436+
asserts:
437+
- equal:
438+
path: spec.template.spec.securityContext
439+
value:
440+
runAsUser: 65534
441+
- equal:
442+
path: spec.template.spec.containers[0].securityContext
443+
value:
444+
allowPrivilegeEscalation: false
445+
readOnlyRootFilesystem: true

deploy/charts/version-checker/values.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,21 @@ resources:
118118
# memory: 128Mi
119119
#
120120

121+
# -- Set container-level security context
122+
securityContext: {}
123+
# allowPrivilegeEscalation: false
124+
# capabilities:
125+
# drop:
126+
# - ALL
127+
# readOnlyRootFilesystem: true
128+
# runAsNonRoot: true
129+
# runAsUser: 65534
130+
# seccompProfile:
131+
# type: RuntimeDefault
132+
133+
# -- Set pod-level security context
134+
podSecurityContext: {}
135+
121136
# Configure the readiness probe for version-checker
122137
readinessProbe:
123138
# -- Enable/Disable the setting of a readinessProbe

0 commit comments

Comments
 (0)