Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/helm_lib/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v2
type: library
name: deckhouse_lib_helm
version: 1.72.34
version: 1.72.35
description: "Helm utils template definitions for Deckhouse modules."
2 changes: 1 addition & 1 deletion charts/helm_lib/templates/_capi_controller_manager.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}

{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
{{- if $hostNetwork }}
---
apiVersion: deckhouse.io/v1alpha1
Expand Down
4 changes: 2 additions & 2 deletions charts/helm_lib/templates/_cloud_controller_manager.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ spec:
metadata:
labels:
app: {{ $fullname }}
{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
security.deckhouse.io/security-policy-exception: {{ $fullname }}
{{- end }}
{{- with $additionalPodLabels }}
Expand Down Expand Up @@ -221,7 +221,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}

{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
---
apiVersion: deckhouse.io/v1alpha1
kind: SecurityPolicyException
Expand Down
4 changes: 2 additions & 2 deletions charts/helm_lib/templates/_csi_controller.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ spec:
metadata:
labels:
app: {{ $fullname }}
{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
security.deckhouse.io/security-policy-exception: {{ $fullname }}
{{- end }}
{{- if or (hasPrefix "cloud-provider-" $context.Chart.Name) ($additionalCsiControllerPodAnnotations) }}
Expand Down Expand Up @@ -570,7 +570,7 @@ spec:
{{- $additionalControllerVolumes | toYaml | nindent 6 }}
{{- end }}

{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
{{- $controllerContainer := dict "name" "controller" "securityContext" (dict "allowPrivilegeEscalation" false) "ports" ($additionalControllerPorts | default list) }}
{{- $relaxations := include "helm_lib_csi_spe_container_relaxations" (list (concat (list $controllerContainer) ($additionalContainers | default list) ($initContainers | default list)) (eq $csiControllerHostNetwork "true")) | fromYaml }}
{{- $privileged := or $forceCsiControllerPrivilegedContainer (gt (len $relaxations.privileged) 0) }}
Expand Down
4 changes: 2 additions & 2 deletions charts/helm_lib/templates/_csi_node.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ spec:
metadata:
labels:
app: {{ $fullname }}
{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
security.deckhouse.io/security-policy-exception: {{ $fullname }}
{{- end }}
{{- if or (hasPrefix "cloud-provider-" $context.Chart.Name) ($additionalCsiNodePodAnnotations) }}
Expand Down Expand Up @@ -307,7 +307,7 @@ spec:
{{- $additionalNodeVolumes | toYaml | nindent 6 }}
{{- end }}

{{- if and $securityPolicyExceptionEnabled ($context.Values.global.enabledModules | has "admission-policy-engine-crd") }}
{{- if and $securityPolicyExceptionEnabled (include "helm_lib_api_version_exists" (list $context "deckhouse.io/v1alpha1/SecurityPolicyException")) }}
{{- $relaxations := include "helm_lib_csi_spe_container_relaxations" (list (concat ($additionalContainers | default list) ($initContainers | default list)) (eq $csiNodeHostNetwork "true")) | fromYaml }}
{{- $capabilityValues := $relaxations.capabilityValues }}
{{- if $setSysAdminCapability }}
Expand Down
37 changes: 36 additions & 1 deletion tests/tests/helm_lib_capi_controller_manager_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,8 @@ tests:
enabledModules:
- admission-policy-engine-crd
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
fullname: capz-controller-manager
Expand All @@ -774,12 +776,37 @@ tests:
kind: SecurityPolicyException
apiVersion: deckhouse.io/v1alpha1

- it: does not render SecurityPolicyException when admission-policy-engine-crd module is not enabled
- it: renders SecurityPolicyException when the SecurityPolicyException API exists although admission-policy-engine-crd is not enabled
set:
global:
modules:
placement: {}
enabledModules: []
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
fullname: capz-controller-manager
image: controllerImage
capiProviderName: infrastructure-zvirt
securityPolicyExceptionEnabled: true
hostNetwork: true
documentSelector:
path: kind
value: SecurityPolicyException
asserts:
- containsDocument:
kind: SecurityPolicyException
apiVersion: deckhouse.io/v1alpha1

- it: does not render SecurityPolicyException when the SecurityPolicyException API is missing although admission-policy-engine-crd is enabled
set:
global:
modules:
placement: {}
enabledModules:
- admission-policy-engine-crd
discovery:
d8SpecificNodeCountByRole: {}
_testvalues:
Expand All @@ -802,6 +829,8 @@ tests:
enabledModules:
- admission-policy-engine-crd
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
fullname: capz-controller-manager
Expand All @@ -825,6 +854,8 @@ tests:
enabledModules:
- admission-policy-engine-crd
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
fullname: capcd-controller-manager
Expand Down Expand Up @@ -873,6 +904,8 @@ tests:
enabledModules:
- admission-policy-engine-crd
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
fullname: capcd-controller-manager
Expand Down Expand Up @@ -909,6 +942,8 @@ tests:
enabledModules:
- admission-policy-engine-crd
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
fullname: capcd-controller-manager
Expand Down
52 changes: 50 additions & 2 deletions tests/tests/helm_lib_cloud_controller_manager_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ tests:
- admission-policy-engine-crd
clusterIsBootstrapped: true
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
image: controllerImage
Expand Down Expand Up @@ -609,6 +611,8 @@ tests:
- admission-policy-engine-crd
clusterIsBootstrapped: true
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
image: controllerImage
Expand Down Expand Up @@ -651,14 +655,16 @@ tests:
path: spec.volumes.hostPath.allowedValues[0].readOnly
value: true

- it: does not render SecurityPolicyException when admission policy module is disabled
- it: renders SecurityPolicyException when the SecurityPolicyException API exists although admission-policy-engine-crd is not enabled
set:
global:
modules:
placement: {}
enabledModules: []
clusterIsBootstrapped: true
discovery:
apiVersions:
- deckhouse.io/v1alpha1/SecurityPolicyException
d8SpecificNodeCountByRole: {}
_testvalues:
image: controllerImage
Expand All @@ -670,4 +676,46 @@ tests:
type: DirectoryOrCreate
asserts:
- hasDocuments:
count: 2
count: 3

- it: does not render SecurityPolicyException when the SecurityPolicyException API is missing although admission-policy-engine-crd is enabled
set:
global:
modules:
placement: {}
enabledModules:
- admission-policy-engine-crd
clusterIsBootstrapped: true
discovery:
d8SpecificNodeCountByRole: {}
_testvalues:
image: controllerImage
securityPolicyExceptionEnabled: true
additionalVolumes:
- name: k8s-certs
hostPath:
path: /etc/kubernetes/pki
type: DirectoryOrCreate
asserts:
- hasDocuments:
count: 2

- it: does not add pod metadata marker when the SecurityPolicyException API is missing although admission-policy-engine-crd is enabled
set:
global:
modules:
placement: {}
enabledModules:
- admission-policy-engine-crd
clusterIsBootstrapped: true
discovery:
d8SpecificNodeCountByRole: {}
_testvalues:
image: controllerImage
securityPolicyExceptionEnabled: true
documentSelector:
path: kind
value: Deployment
asserts:
- notExists:
path: spec.template.metadata.labels["security.deckhouse.io/security-policy-exception"]
Loading
Loading