-
Notifications
You must be signed in to change notification settings - Fork 892
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
csi/server.statefulset: custom security context #767
Changes from all commits
86d4b22
ca70177
135335f
3e45aa5
ee047f6
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 | ||||
---|---|---|---|---|---|---|
|
@@ -474,14 +474,20 @@ Sets extra injector service annotations | |||||
securityContext for the injector pod level. | ||||||
*/}} | ||||||
{{- define "injector.securityContext.pod" -}} | ||||||
{{- if or (.Values.injector.uid) (.Values.injector.gid) }} | ||||||
{{- if .Values.injector.securityContext.pod }} | ||||||
securityContext: | ||||||
{{- $tp := typeOf .Values.injector.securityContext.pod }} | ||||||
{{- if eq $tp "string" }} | ||||||
{{- tpl .Values.injector.securityContext.pod . | nindent 8 }} | ||||||
{{- else }} | ||||||
{{- toYaml .Values.injector.securityContext.pod | nindent 8 }} | ||||||
{{- end }} | ||||||
{{- else if not .Values.global.openshift }} | ||||||
securityContext: | ||||||
runAsNonRoot: true | ||||||
runAsGroup: {{ .Values.injector.gid | default 1000 }} | ||||||
runAsUser: {{ .Values.injector.uid | default 100 }} | ||||||
{{- else if .Values.injector.securityContext.pod }} | ||||||
securityContext: | ||||||
{{- toYaml .Values.injector.securityContext.pod | nindent 8 }} | ||||||
fsGroup: {{ .Values.injector.gid | default 1000 }} | ||||||
{{- end }} | ||||||
{{- end -}} | ||||||
|
||||||
|
@@ -491,9 +497,60 @@ securityContext for the injector container level. | |||||
{{- define "injector.securityContext.container" -}} | ||||||
{{- if .Values.injector.securityContext.container}} | ||||||
securityContext: | ||||||
{{- toYaml .Values.injector.securityContext.container | nindent 12 }} | ||||||
{{- $tp := typeOf .Values.injector.securityContext.container }} | ||||||
{{- if eq $tp "string" }} | ||||||
{{- tpl .Values.injector.securityContext.container . | nindent 12 }} | ||||||
{{- else }} | ||||||
{{- toYaml .Values.injector.securityContext.container | nindent 12 }} | ||||||
{{- end }} | ||||||
{{- else if not .Values.global.openshift }} | ||||||
securityContext: | ||||||
allowPrivilegeEscalation: false | ||||||
capabilities: | ||||||
drop: | ||||||
- ALL | ||||||
{{- end }} | ||||||
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. Should we move the openshift check into the helper here to match server and csi? i.e.
Suggested change
And remove the check from injector-deployment.yaml. 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. Sure, but wouldn't the else here be empty? 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. Oh, nevermind -- I see, we should move the default out of 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. Done. |
||||||
{{- end -}} | ||||||
{{- end -}} | ||||||
|
||||||
{{/* | ||||||
securityContext for the statefulset pod template. | ||||||
*/}} | ||||||
{{- define "server.statefulSet.securityContext.pod" -}} | ||||||
{{- if .Values.server.statefulSet.securityContext.pod }} | ||||||
securityContext: | ||||||
{{- $tp := typeOf .Values.server.statefulSet.securityContext.pod }} | ||||||
{{- if eq $tp "string" }} | ||||||
{{- tpl .Values.server.statefulSet.securityContext.pod . | nindent 8 }} | ||||||
{{- else }} | ||||||
{{- toYaml .Values.server.statefulSet.securityContext.pod | nindent 8 }} | ||||||
{{- end }} | ||||||
{{- else if not .Values.global.openshift }} | ||||||
securityContext: | ||||||
runAsNonRoot: true | ||||||
runAsGroup: {{ .Values.server.gid | default 1000 }} | ||||||
runAsUser: {{ .Values.server.uid | default 100 }} | ||||||
fsGroup: {{ .Values.server.gid | default 1000 }} | ||||||
{{- end }} | ||||||
{{- end -}} | ||||||
|
||||||
{{/* | ||||||
securityContext for the statefulset vault container | ||||||
*/}} | ||||||
{{- define "server.statefulSet.securityContext.container" -}} | ||||||
{{- if .Values.server.statefulSet.securityContext.container }} | ||||||
securityContext: | ||||||
{{- $tp := typeOf .Values.server.statefulSet.securityContext.container }} | ||||||
{{- if eq $tp "string" }} | ||||||
{{- tpl .Values.server.statefulSet.securityContext.container . | nindent 12 }} | ||||||
{{- else }} | ||||||
{{- toYaml .Values.server.statefulSet.securityContext.container | nindent 12 }} | ||||||
{{- end }} | ||||||
{{- else if not .Values.global.openshift }} | ||||||
securityContext: | ||||||
allowPrivilegeEscalation: false | ||||||
{{- end }} | ||||||
{{- end -}} | ||||||
|
||||||
|
||||||
{{/* | ||||||
Sets extra injector service account annotations | ||||||
|
@@ -731,6 +788,37 @@ Sets extra CSI daemonset annotations | |||||
{{- end }} | ||||||
{{- end -}} | ||||||
|
||||||
{{/* | ||||||
Sets CSI daemonset securityContext for pod template | ||||||
*/}} | ||||||
{{- define "csi.daemonSet.securityContext.pod" -}} | ||||||
{{- if .Values.csi.daemonSet.securityContext.pod }} | ||||||
securityContext: | ||||||
{{- $tp := typeOf .Values.csi.daemonSet.securityContext.pod }} | ||||||
{{- if eq $tp "string" }} | ||||||
{{- tpl .Values.csi.daemonSet.securityContext.pod . | nindent 8 }} | ||||||
{{- else }} | ||||||
{{- toYaml .Values.csi.daemonSet.securityContext.pod | nindent 8 }} | ||||||
{{- end }} | ||||||
{{- end }} | ||||||
{{- end -}} | ||||||
|
||||||
{{/* | ||||||
Sets CSI daemonset securityContext for container | ||||||
*/}} | ||||||
{{- define "csi.daemonSet.securityContext.container" -}} | ||||||
{{- if .Values.csi.daemonSet.securityContext.container }} | ||||||
securityContext: | ||||||
{{- $tp := typeOf .Values.csi.daemonSet.securityContext.container }} | ||||||
{{- if eq $tp "string" }} | ||||||
{{- tpl .Values.csi.daemonSet.securityContext.container . | nindent 12 }} | ||||||
{{- else }} | ||||||
{{- toYaml .Values.csi.daemonSet.securityContext.container | nindent 12 }} | ||||||
{{- end }} | ||||||
{{- end }} | ||||||
{{- end -}} | ||||||
|
||||||
|
||||||
{{/* | ||||||
Sets the injector toleration for pod placement | ||||||
*/}} | ||||||
|
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.
Might be good to add another test that sets this as a multi-line string.
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.
👍