Skip to content

Commit

Permalink
helm: Move some securityContext fields to container's securityContext
Browse files Browse the repository at this point in the history
The `privileged` and `readOnlyRootFilesystem` fields are not valid in
the pod's security context and can only be used in the container's
security context. Trying to apply the generated resource would cause the
error:

```
error validating data: [ValidationError(Deployment.spec.template.spec.securityContext): unknown field "privileged" in io.k8s.api.core.v1.PodSecurityContext, ValidationError(Deployment.spec.template.spec.securityContext): unknown field "readOnlyRootFilesystem" in io.k8s.api.core.v1.PodSecurityContext]; if you choose to ignore these errors, turn validation off with --validate=false
```
  • Loading branch information
cezarsa committed Aug 18, 2020
1 parent f32fd0b commit 4d0cdaa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions helm/draino/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ spec:
port: 10002
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
serviceAccountName: {{ if .Values.rbac.create }}{{ template "draino.fullname" . }}{{ else }}"{{ .Values.rbac.serviceAccountName }}"{{ end }}
{{- with .Values.securityContext }}
securityContext:
Expand Down
2 changes: 2 additions & 0 deletions helm/draino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,7 @@ securityContext:
runAsGroup: 101
runAsNonRoot: true
runAsUser: 100

containerSecurityContext:
privileged: false
readOnlyRootFilesystem: true

0 comments on commit 4d0cdaa

Please sign in to comment.