diff --git a/charts/helm_lib/Chart.yaml b/charts/helm_lib/Chart.yaml index aabbec5..a602ada 100644 --- a/charts/helm_lib/Chart.yaml +++ b/charts/helm_lib/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 type: library name: deckhouse_lib_helm -version: 1.72.32 +version: 1.72.33 description: "Helm utils template definitions for Deckhouse modules." diff --git a/charts/helm_lib/README.md b/charts/helm_lib/README.md index 8f56709..a7de336 100644 --- a/charts/helm_lib/README.md +++ b/charts/helm_lib/README.md @@ -128,6 +128,7 @@ | [helm_lib_module_container_security_context_privileged_read_only_root_filesystem](#helm_lib_module_container_security_context_privileged_read_only_root_filesystem) | | [helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all](#helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all) | | [helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add](#helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add) | +| [helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default](#helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default) | | [helm_lib_module_container_security_context_capabilities_drop_all_and_add](#helm_lib_module_container_security_context_capabilities_drop_all_and_add) | | [helm_lib_module_container_security_context_capabilities_drop_all_and_run_as_user_custom](#helm_lib_module_container_security_context_capabilities_drop_all_and_run_as_user_custom) | | [helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_pss_restricted](#helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_pss_restricted) | @@ -1558,6 +1559,21 @@ list: - List of capabilities +### helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default + + returns SecurityContext parameters for Container with read only root filesystem, all dropped and some added capabilities, and the RuntimeDefault seccomp profile + +#### Usage + +`{{ include "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default" (list . (list "KILL" "SYS_PTRACE")) }} ` + +#### Arguments + +list: +- Template context with .Values, .Chart, etc +- List of capabilities + + ### helm_lib_module_container_security_context_capabilities_drop_all_and_add returns SecurityContext parameters for Container with all dropped and some added capabilities diff --git a/charts/helm_lib/templates/_module_security_context.tpl b/charts/helm_lib/templates/_module_security_context.tpl index 04f042f..c72d27c 100644 --- a/charts/helm_lib/templates/_module_security_context.tpl +++ b/charts/helm_lib/templates/_module_security_context.tpl @@ -224,6 +224,22 @@ securityContext: add: {{ index . 1 | toJson }} {{- end }} +{{- /* Usage: {{ include "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default" (list . (list "KILL" "SYS_PTRACE")) }} */ -}} +{{- /* returns SecurityContext parameters for Container with read only root filesystem, all dropped and some added capabilities, and the RuntimeDefault seccomp profile */ -}} +{{- define "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default" -}} +{{- /* Template context with .Values, .Chart, etc */ -}} +{{- /* List of capabilities */ -}} +securityContext: + readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + add: {{ index . 1 | toJson }} + seccompProfile: + type: RuntimeDefault +{{- 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" -}} diff --git a/tests/templates/helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default.yaml b/tests/templates/helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default.yaml new file mode 100644 index 0000000..02b4409 --- /dev/null +++ b/tests/templates/helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default.yaml @@ -0,0 +1 @@ +{{ include "helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default" (list . (list "DAC_OVERRIDE" "NET_ADMIN")) }} diff --git a/tests/tests/helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default_test.yaml b/tests/tests/helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default_test.yaml new file mode 100644 index 0000000..e82d11b --- /dev/null +++ b/tests/tests/helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default_test.yaml @@ -0,0 +1,19 @@ +suite: helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default +templates: + - helm_lib_module_container_security_context_read_only_root_filesystem_capabilities_drop_all_and_add_runtime_default.yaml +tests: + - it: drops all, adds the given capabilities and sets the RuntimeDefault seccomp profile + asserts: + - equal: + path: securityContext + value: + readOnlyRootFilesystem: true + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + add: + - DAC_OVERRIDE + - NET_ADMIN + seccompProfile: + type: RuntimeDefault