-
Notifications
You must be signed in to change notification settings - Fork 0
/
_module_security_context.tpl
199 lines (182 loc) · 8.55 KB
/
_module_security_context.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_run_as_user_custom" (list . 1000 1000) }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with custom user and group */ -}}
{{- define "helm_lib_module_pod_security_context_run_as_user_custom" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
{{- /* User id */ -}}
{{- /* Group id */ -}}
securityContext:
runAsNonRoot: true
runAsUser: {{ index . 1 }}
runAsGroup: {{ index . 2 }}
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_run_as_user_nobody" . }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with user and group "nobody" */ -}}
{{- define "helm_lib_module_pod_security_context_run_as_user_nobody" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
runAsNonRoot: true
runAsUser: 65534
runAsGroup: 65534
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_run_as_user_nobody_with_writable_fs" . }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with user and group "nobody" with write access to mounted volumes */ -}}
{{- define "helm_lib_module_pod_security_context_run_as_user_nobody_with_writable_fs" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
runAsNonRoot: true
runAsUser: 65534
runAsGroup: 65534
fsGroup: 65534
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_run_as_user_deckhouse" . }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with user and group "deckhouse" */ -}}
{{- define "helm_lib_module_pod_security_context_run_as_user_deckhouse" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
runAsNonRoot: true
runAsUser: 64535
runAsGroup: 64535
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_run_as_user_deckhouse_with_writable_fs" . }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with user and group "deckhouse" with write access to mounted volumes */ -}}
{{- define "helm_lib_module_pod_security_context_run_as_user_deckhouse_with_writable_fs" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
runAsNonRoot: true
runAsUser: 64535
runAsGroup: 64535
fsGroup: 64535
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_run_as_user_deckhouse_pss_restricted" . }} */ -}}
{{- /* returns SecurityContext parameters for Container with user and group "deckhouse" plus minimal required settings to comply with the Restricted mode of the Pod Security Standards */ -}}
{{- define "helm_lib_module_container_security_context_run_as_user_deckhouse_pss_restricted" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- all
runAsGroup: 64535
runAsNonRoot: true
runAsUser: 64535
seccompProfile:
type: RuntimeDefault
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_run_as_user_root" . }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with user and group 0 */ -}}
{{- define "helm_lib_module_pod_security_context_run_as_user_root" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
runAsNonRoot: false
runAsUser: 0
runAsGroup: 0
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_pod_security_context_runtime_default" . }} */ -}}
{{- /* returns PodSecurityContext parameters for Pod with seccomp profile RuntimeDefault */ -}}
{{- define "helm_lib_module_pod_security_context_runtime_default" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
seccompProfile:
type: RuntimeDefault
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_not_allow_privilege_escalation" . }} */ -}}
{{- /* returns SecurityContext parameters for Container with allowPrivilegeEscalation false */ -}}
{{- define "helm_lib_module_container_security_context_not_allow_privilege_escalation" -}}
securityContext:
allowPrivilegeEscalation: false
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_read_only_root_filesystem_with_selinux" . }} */ -}}
{{- /* returns SecurityContext parameters for Container with read only root filesystem and options for SELinux compatibility*/ -}}
{{- define "helm_lib_module_container_security_context_read_only_root_filesystem_with_selinux" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
seLinuxOptions:
level: 's0'
type: 'spc_t'
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_read_only_root_filesystem" . }} */ -}}
{{- /* returns SecurityContext parameters for Container with read only root filesystem */ -}}
{{- define "helm_lib_module_container_security_context_read_only_root_filesystem" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_privileged" . }} */ -}}
{{- /* returns SecurityContext parameters for Container running privileged */ -}}
{{- define "helm_lib_module_container_security_context_privileged" -}}
securityContext:
privileged: true
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_escalated_sys_admin_privileged" . }} */ -}}
{{- /* returns SecurityContext parameters for Container running privileged with escalation and sys_admin */ -}}
{{- define "helm_lib_module_container_security_context_escalated_sys_admin_privileged" -}}
securityContext:
allowPrivilegeEscalation: true
capabilities:
add:
- SYS_ADMIN
privileged: true
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_privileged_read_only_root_filesystem" . }} */ -}}
{{- /* returns SecurityContext parameters for Container running privileged with read only root filesystem */ -}}
{{- define "helm_lib_module_container_security_context_privileged_read_only_root_filesystem" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
privileged: true
readOnlyRootFilesystem: true
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all" . }} */ -}}
{{- /* returns SecurityContext for Container with read only root filesystem and all capabilities dropped */ -}}
{{- define "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add" (list . (list "KILL" "SYS_PTRACE")) }} */ -}}
{{- /* returns SecurityContext parameters for Container with read only root filesystem, all dropped and some added capabilities */ -}}
{{- define "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
{{- /* List of capabilities */ -}}
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
add: {{ index . 1 | toJson }}
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_capabilities_drop_all_and_add" (list . (list "KILL" "SYS_PTRACE")) }} */ -}}
{{- /* returns SecurityContext parameters for Container with all dropped and some added capabilities */ -}}
{{- define "helm_lib_module_container_security_context_capabilities_drop_all_and_add" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
{{- /* List of capabilities */ -}}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
add: {{ index . 1 | toJson }}
{{- end }}
{{- /* Usage: {{ include "helm_lib_module_container_security_context_capabilities_drop_all_and_run_as_user_custom" (list . 1000 1000) }} */ -}}
{{- /* returns SecurityContext parameters for Container with read only root filesystem, all dropped, and custom user ID */ -}}
{{- define "helm_lib_module_container_security_context_capabilities_drop_all_and_run_as_user_custom" -}}
{{- /* Template context with .Values, .Chart, etc */ -}}
{{- /* User id */ -}}
{{- /* Group id */ -}}
securityContext:
runAsUser: {{ index . 1 }}
runAsGroup: {{ index . 2 }}
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
{{- end }}