diff --git a/charts/library/common-test/tests/vpa/spec_test.yaml b/charts/library/common-test/tests/vpa/spec_test.yaml new file mode 100644 index 00000000000..1346296b820 --- /dev/null +++ b/charts/library/common-test/tests/vpa/spec_test.yaml @@ -0,0 +1,181 @@ +suite: vpa spec test +templates: + - common.yaml +release: + name: test-release-name + namespace: test-release-namespace +tests: + - it: should create vpa + set: + workload: &workload + workload-name: + enabled: true + primary: true + type: Deployment + podSpec: {} + vpa: + vpa-name: + enabled: true + asserts: + - documentIndex: &vpaDoc 1 + isKind: + of: VerticalPodAutoscaler + - documentIndex: *vpaDoc + isAPIVersion: + of: autoscaling.k8s.io/v1 + - documentIndex: *vpaDoc + isSubset: + path: spec + content: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: test-release-name-common-test + updatePolicy: + updateMode: Auto + + - it: should create vpa with targetSelector + set: + workload: + workload-name: + enabled: true + primary: true + type: Deployment + podSpec: {} + workload-name-2: + enabled: true + type: Deployment + podSpec: {} + vpa: + vpa-name: + enabled: true + targetSelector: + - workload-name-2 + asserts: + - hasDocuments: + count: 3 # 2 Deployments, 1 VPA + - documentIndex: &vpaDoc 2 + isKind: + of: VerticalPodAutoscaler + - documentIndex: *vpaDoc + isAPIVersion: + of: autoscaling.k8s.io/v1 + - documentIndex: *vpaDoc + isSubset: + path: spec + content: + targetRef: + apiVersion: apps/v1 + kind: Deployment + name: test-release-name-common-test-workload-name-2 + updatePolicy: + updateMode: Auto + + - it: should create vpa with options + set: + workload: *workload + vpa: + vpa-name: + enabled: true + updatePolicy: + minReplicas: 2 + evictionRequirements: + - resources: ["cpu"] + changeRequirement: TargetHigherThanRequests + - resources: ["memory"] + changeRequirement: TargetLowerThanRequests + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + controlledResources: ["cpu", "memory"] + controlledValues: RequestsAndLimits + minAllowed: + cpu: 1000m + memory: 1000Mi + maxAllowed: + cpu: 1000m + memory: 1000Mi + asserts: + - documentIndex: &vpaDoc 1 + isKind: + of: VerticalPodAutoscaler + - documentIndex: *vpaDoc + isAPIVersion: + of: autoscaling.k8s.io/v1 + - documentIndex: *vpaDoc + equal: + path: spec.updatePolicy + value: + updateMode: Auto + minReplicas: 2 + evictionRequirements: + - changeRequirement: TargetHigherThanRequests + resources: ["cpu"] + - changeRequirement: TargetLowerThanRequests + resources: ["memory"] + - documentIndex: *vpaDoc + equal: + path: spec.resourcePolicy + value: + containerPolicies: + - containerName: "*" + mode: Auto + controlledResources: ["cpu", "memory"] + controlledValues: RequestsAndLimits + minAllowed: + cpu: 1000m + memory: 1000Mi + maxAllowed: + cpu: 1000m + memory: 1000Mi + - it: should create vpa with containerPolicies options ignored when mode is Off + set: + workload: *workload + vpa: + vpa-name: + enabled: true + updatePolicy: + minReplicas: 2 + evictionRequirements: + - resources: ["cpu"] + changeRequirement: TargetHigherThanRequests + - resources: ["memory"] + changeRequirement: TargetLowerThanRequests + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: "Off" + controlledResources: ["cpu", "memory"] + controlledValues: RequestsAndLimits + minAllowed: + cpu: 1000m + memory: 1000Mi + maxAllowed: + cpu: 1000m + memory: 1000Mi + asserts: + - documentIndex: &vpaDoc 1 + isKind: + of: VerticalPodAutoscaler + - documentIndex: *vpaDoc + isAPIVersion: + of: autoscaling.k8s.io/v1 + - documentIndex: *vpaDoc + equal: + path: spec.updatePolicy + value: + updateMode: Auto + minReplicas: 2 + evictionRequirements: + - changeRequirement: TargetHigherThanRequests + resources: ["cpu"] + - changeRequirement: TargetLowerThanRequests + resources: ["memory"] + - documentIndex: *vpaDoc + equal: + path: spec.resourcePolicy + value: + containerPolicies: + - containerName: "*" + mode: "Off" diff --git a/charts/library/common-test/tests/vpa/validation_test.yaml b/charts/library/common-test/tests/vpa/validation_test.yaml index b8b652394b8..e6dee26ae09 100644 --- a/charts/library/common-test/tests/vpa/validation_test.yaml +++ b/charts/library/common-test/tests/vpa/validation_test.yaml @@ -61,7 +61,7 @@ tests: updatePolicy: "not a dict" asserts: - failedTemplate: - errorMessage: Vertical Pod Autoscaler - Expected [updatePolicy] to be a dictionary, but got [string] + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.updatePolicy] to be a dictionary, but got [string] - it: should fail with updatePolicy.updateMode not valid set: @@ -154,3 +154,186 @@ tests: asserts: - failedTemplate: errorMessage: Vertical Pod Autoscaler - Value [some-change-requirement] on [vpa.vpa-name.updatePolicy.evictionRequirements.0.changeRequirement] is not valid. Must be one of [TargetHigherThanRequests, TargetLowerThanRequests] + + - it: should fail with resourcePolicy.containerPolicies not a list + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: not-a-list + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Value on [vpa.vpa-name.resourcePolicy.containerPolicies] must be a list, but got [string] + + - it: should fail with resourcePolicy.containerPolicies item not a dict + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - item + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.resourcePolicy.containerPolicies.0] to be a dictionary, but got [string] + + - it: should fail with invalid resourcePolicy.containerPolicies.#.containerName + set: + workload: + workload-name: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + some-container: + enabled: true + primary: true + probes: &probes + readiness: + enabled: false + liveness: + enabled: false + startup: + enabled: false + some-other-container: + enabled: true + probes: *probes + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Value [invalid] on [vpa.vpa-name.resourcePolicy.containerPolicies.0.containerName] is not valid. Must be one of [some-container, some-other-container, *] + + - it: should fail with invalid resourcePolicy.containerPolicies.#.mode + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Value [invalid] on [vpa.vpa-name.resourcePolicy.containerPolicies.0.mode] is not valid. Must be one of [Auto, Off] + + - it: should fail with resourcePolicy.containerPolicies.controlledResources not a list + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + controlledResources: not-a-list + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.resourcePolicy.containerPolicies.0.controlledResources] to be a list, but got [string] + + - it: should fail with invalid item in resourcePolicy.containerPolicies.#.controlledResources + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + controlledResources: + - invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Value [invalid] on [vpa.vpa-name.resourcePolicy.containerPolicies.0.controlledResources.0] is not valid. Must be one of [cpu, memory] + + - it: should fail with invalid value in resourcePolicy.containerPolicies.#.controlledValues + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + controlledValues: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Value [invalid] on [vpa.vpa-name.resourcePolicy.containerPolicies.0.controlledValues] is not valid. Must be one of [RequestsAndLimits, RequestsOnly] + + - it: should fail with invalid cpu in minAllowed + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + minAllowed: + cpu: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.resourcePolicy.containerPolicies.0.minAllowed.cpu] to have one of the following formats [(Plain Integer - eg. 1), (Float - eg. 0.5), (Milicpu - eg. 500m)], but got [invalid] + + - it: should fail with invalid memory in minAllowed + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + minAllowed: + cpu: 1 + memory: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.resourcePolicy.containerPolicies.0.minAllowed.memory] to have one of the following formats [(Suffixed with E/P/T/G/M/K - eg. 1G), (Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi), (Plain Integer in bytes - eg. 1024), (Exponent - eg. 134e6)], but got [invalid] + + - it: should fail with invalid cpu in maxAllowed + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + maxAllowed: + cpu: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.resourcePolicy.containerPolicies.0.maxAllowed.cpu] to have one of the following formats [(Plain Integer - eg. 1), (Float - eg. 0.5), (Milicpu - eg. 500m)], but got [invalid] + + - it: should fail with invalid memory in maxAllowed + set: + workload: *workload + vpa: + vpa-name: + enabled: true + resourcePolicy: + containerPolicies: + - containerName: "*" + mode: Auto + maxAllowed: + cpu: 1000m + memory: invalid + asserts: + - failedTemplate: + errorMessage: Vertical Pod Autoscaler - Expected [vpa.vpa-name.resourcePolicy.containerPolicies.0.maxAllowed.memory] to have one of the following formats [(Suffixed with E/P/T/G/M/K - eg. 1G), (Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi), (Plain Integer in bytes - eg. 1024), (Exponent - eg. 134e6)], but got [invalid] diff --git a/charts/library/common/templates/class/_verticalPodAutoscaler.tpl b/charts/library/common/templates/class/_verticalPodAutoscaler.tpl index 976dbb1ab38..fe4c6d4bf47 100644 --- a/charts/library/common/templates/class/_verticalPodAutoscaler.tpl +++ b/charts/library/common/templates/class/_verticalPodAutoscaler.tpl @@ -39,7 +39,39 @@ spec: {{- range $req := $objectData.updatePolicy.evictionRequirements }} - resources: {{ $req.resources | toJson }} changeRequirement: {{ $req.changeRequirement }} - {{- end }} + {{- end -}} {{- end -}} + {{- if and $objectData.resourcePolicy $objectData.resourcePolicy.containerPolicies }} + resourcePolicy: + containerPolicies: + {{- range $cPol := $objectData.resourcePolicy.containerPolicies }} + - containerName: {{ $cPol.containerName | quote }} + mode: {{ $cPol.mode }} + {{- if eq $cPol.mode "Off" -}}{{- continue -}}{{- end }} + controlledValues: {{ $cPol.controlledValues | default "RequestsAndLimits" }} + {{- if $cPol.controlledResources }} + controlledResources: {{ $cPol.controlledResources | toJson }} + {{- end -}} + {{- with $cPol.minAllowed -}} + {{- include "tc.v1.common.class.vpa.resources" (dict "item" "minAllowed" "resources" $cPol.minAllowed) | nindent 8 -}} + {{- end -}} + {{- with $cPol.maxAllowed -}} + {{- include "tc.v1.common.class.vpa.resources" (dict "item" "maxAllowed" "resources" $cPol.maxAllowed) | nindent 8 -}} + {{- end -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{- define "tc.v1.common.class.vpa.resources" -}} + {{- $item := .item -}} + {{- $resources := .resources -}} + + {{ $item }}: + {{- with $resources.cpu }} + cpu: {{ . }} + {{- end -}} + {{- with $resources.memory }} + memory: {{ . }} + {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/lib/container/_resources.tpl b/charts/library/common/templates/lib/container/_resources.tpl index 0cdb76d4957..7bbdebfab20 100644 --- a/charts/library/common/templates/lib/container/_resources.tpl +++ b/charts/library/common/templates/lib/container/_resources.tpl @@ -46,6 +46,25 @@ limits: {{- end -}} {{- end -}} + +{{- define "tc.v1.common.lib.resources.validation.data" -}} + {{/* CPU: https://regex101.com/r/D4HouI/1 */}} + {{/* MEM: https://regex101.com/r/NNPV2D/1 */}} + {{- $regex := (dict + "cpu" "^(0\\.[1-9]|[1-9][0-9]*)(\\.[0-9]|m?)$" + "memory" "^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$" + ) -}} + + {{- $errorMsg := (dict + "cpu" "(Plain Integer - eg. 1), (Float - eg. 0.5), (Milicpu - eg. 500m)" + "memory" "(Suffixed with E/P/T/G/M/K - eg. 1G), (Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi), (Plain Integer in bytes - eg. 1024), (Exponent - eg. 134e6)" + ) -}} + + {{- $data := (dict "regex" $regex "errorMsg" $errorMsg) -}} + + {{- $data | toJson -}} +{{- end -}} + {{/* Validates resources to match a pattern */}} {{/* Call this template: {{ include "tc.v1.common.lib.container.resources.validation" (dict "resources" $resources) }} @@ -54,14 +73,9 @@ resources: The resources object */}} {{- define "tc.v1.common.lib.container.resources.validation" -}} {{- $resources := .resources -}} - {{/* CPU: https://regex101.com/r/D4HouI/1 */}} - {{/* MEM: https://regex101.com/r/NNPV2D/1 */}} - {{- $regex := (dict - "cpu" "^(0\\.[1-9]|[1-9][0-9]*)(\\.[0-9]|m?)$" - "memory" "^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$") -}} - {{- $errorMsg := (dict - "cpu" "(Plain Integer - eg. 1), (Float - eg. 0.5), (Milicpu - eg. 500m)" - "memory" "(Suffixed with E/P/T/G/M/K - eg. 1G), (Suffixed with Ei/Pi/Ti/Gi/Mi/Ki - eg. 1Gi), (Plain Integer in bytes - eg. 1024), (Exponent - eg. 134e6)") -}} + {{- $data := (include "tc.v1.common.lib.resources.validation.data" .) | fromJson -}} + {{- $regex := $data.regex -}} + {{- $errorMsg := $data.errorMsg -}} {{- $resourceTypes := (list "cpu" "memory") -}} diff --git a/charts/library/common/templates/lib/vpa/_validation.tpl b/charts/library/common/templates/lib/vpa/_validation.tpl index bb7b9027bb1..2ede292734c 100644 --- a/charts/library/common/templates/lib/vpa/_validation.tpl +++ b/charts/library/common/templates/lib/vpa/_validation.tpl @@ -5,14 +5,12 @@ {{- $updPolicy := $objectData.updatePolicy -}} {{- if $updPolicy -}} {{- if not (kindIs "map" $updPolicy) -}} - {{- fail (printf "Vertical Pod Autoscaler - Expected [updatePolicy] to be a dictionary, but got [%s]" (kindOf $updPolicy)) -}} + {{- fail (printf "Vertical Pod Autoscaler - Expected [vpa.%s.updatePolicy] to be a dictionary, but got [%s]" $objectData.vpaName (kindOf $updPolicy)) -}} {{- end -}} - {{- if $updPolicy.updateMode -}} - {{- $validModes := list "Auto" "Off" "Initial" "Recreate" -}} - {{- if not (mustHas $updPolicy.updateMode $validModes) -}} - {{- fail (printf "Vertical Pod Autoscaler - Value [%s] on [vpa.%s.updatePolicy.updateMode] is not valid. Must be one of [%s]" $updPolicy.updateMode $objectData.vpaName (join ", " $validModes)) -}} - {{- end -}} + {{- $validModes := list "Auto" "Off" "Initial" "Recreate" -}} + {{- if and $updPolicy.updateMode (not (mustHas $updPolicy.updateMode $validModes)) -}} + {{- fail (printf "Vertical Pod Autoscaler - Value [%s] on [vpa.%s.updatePolicy.updateMode] is not valid. Must be one of [%s]" $updPolicy.updateMode $objectData.vpaName (join ", " $validModes)) -}} {{- end -}} {{- if and $updPolicy.minReplicas (le ($updPolicy.minReplicas | int) 0) -}} @@ -50,6 +48,68 @@ {{- end -}} {{- end -}} + {{- end -}} + {{- $resPolicy := $objectData.resourcePolicy -}} + {{- if and $resPolicy $resPolicy.containerPolicies -}} + {{- if not (kindIs "slice" $resPolicy.containerPolicies) -}} + {{- fail (printf "Vertical Pod Autoscaler - Value on [vpa.%s.resourcePolicy.containerPolicies] must be a list, but got [%s]" $objectData.vpaName (kindOf $resPolicy.containerPolicies)) -}} + {{- end -}} + + {{- $validModes := (list "Auto" "Off") -}} + {{- range $idx, $cPol := $resPolicy.containerPolicies -}} + {{- if not (kindIs "map" $cPol) -}} + {{- fail (printf "Vertical Pod Autoscaler - Expected [vpa.%s.resourcePolicy.containerPolicies.%d] to be a dictionary, but got [%s]" $objectData.vpaName $idx (kindOf $cPol)) -}} + {{- end -}} + + {{- $validContainers := mustAppend $objectData.containerNames "*" -}} + {{- if not (mustHas $cPol.containerName $validContainers) -}} + {{- fail (printf "Vertical Pod Autoscaler - Value [%s] on [vpa.%s.resourcePolicy.containerPolicies.%d.containerName] is not valid. Must be one of [%s]" $cPol.containerName $objectData.vpaName $idx (join ", " $validContainers)) -}} + {{- end -}} + + {{- if and $cPol.mode (not (mustHas $cPol.mode $validModes)) -}} + {{- fail (printf "Vertical Pod Autoscaler - Value [%s] on [vpa.%s.resourcePolicy.containerPolicies.%d.mode] is not valid. Must be one of [%s]" $cPol.mode $objectData.vpaName $idx (join ", " $validModes)) -}} + {{- end -}} + + {{- if $cPol.controlledResources -}} + {{- if not (kindIs "slice" $cPol.controlledResources) -}} + {{- fail (printf "Vertical Pod Autoscaler - Expected [vpa.%s.resourcePolicy.containerPolicies.%d.controlledResources] to be a list, but got [%s]" $objectData.vpaName $idx (kindOf $cPol.controlledResources)) -}} + {{- end -}} + + {{- $validRes := (list "cpu" "memory") -}} + {{- range $x, $r := $cPol.controlledResources -}} + {{- if not (mustHas $r $validRes) -}} + {{- fail (printf "Vertical Pod Autoscaler - Value [%s] on [vpa.%s.resourcePolicy.containerPolicies.%d.controlledResources.%d] is not valid. Must be one of [%s]" $r $objectData.vpaName $idx $x (join ", " $validRes)) -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- if $cPol.controlledValues -}} + {{- $validVals := (list "RequestsAndLimits" "RequestsOnly") -}} + {{- if not (mustHas $cPol.controlledValues $validVals) -}} + {{- fail (printf "Vertical Pod Autoscaler - Value [%s] on [vpa.%s.resourcePolicy.containerPolicies.%d.controlledValues] is not valid. Must be one of [%s]" $cPol.controlledValues $objectData.vpaName $idx (join ", " $validVals)) -}} + {{- end -}} + {{- end -}} + + {{- $data := (include "tc.v1.common.lib.resources.validation.data" .) | fromJson -}} + {{- $regex := $data.regex -}} + {{- $errorMsg := $data.errorMsg -}} + + {{- $items := (list "minAllowed" "maxAllowed") -}} + {{- range $item := $items -}} + {{- if not (get $cPol $item) -}}{{- continue -}}{{- end -}} + + {{- if not (kindIs "map" (get $cPol $item)) -}} + {{- fail (printf "Vertical Pod Autoscaler - Expected [vpa.%s.resourcePolicy.containerPolicies.%d.%s] to be a dictionary, but got [%s]" $objectData.vpaName $idx $item (kindOf (get $cPol $item))) -}} + {{- end -}} + + {{- range $k, $v := (get $cPol $item) -}} + {{- if not (mustRegexMatch (get $regex $k) (toString $v)) -}} + {{- fail (printf "Vertical Pod Autoscaler - Expected [vpa.%s.resourcePolicy.containerPolicies.%d.%s.%s] to have one of the following formats [%s], but got [%s]" $objectData.vpaName $idx $item $k (get $errorMsg $k) $v) -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- end -}} {{- end -}} {{- end -}} diff --git a/charts/library/common/templates/spawner/_verticalPodAutoscaler.tpl b/charts/library/common/templates/spawner/_verticalPodAutoscaler.tpl index 97f83fa25ef..4b1ea84d580 100644 --- a/charts/library/common/templates/spawner/_verticalPodAutoscaler.tpl +++ b/charts/library/common/templates/spawner/_verticalPodAutoscaler.tpl @@ -15,18 +15,29 @@ {{- $objectData := (mustDeepCopy $vpa) -}} {{- $_ := set $objectData "vpaName" $name -}} - {{- include "tc.v1.common.lib.vpa.validation" (dict "objectData" $objectData "rootCtx" $) -}} {{- include "tc.v1.common.lib.chart.names.validation" (dict "name" $name) -}} {{- range $workloadName, $workload := $.Values.workload -}} {{- $enabled := (include "tc.v1.common.lib.util.enabled" (dict "rootCtx" $ "objectData" $workload - "name" $name "caller" "vpa" + "name" $name "caller" "Vertical Pod Autoscaler" "key" "workload")) -}} {{- if ne $enabled "true" -}}{{- continue -}}{{- end -}} + {{- $containerNames := list -}} + {{- range $cName, $c := $workload.podSpec.containers -}} + {{- $enabledContainer := (include "tc.v1.common.lib.util.enabled" (dict + "rootCtx" $ "objectData" $c + "name" $cName "caller" "Vertical Pod Autoscaler" + "key" "workload.podSpec.containers")) -}} + {{- if ne $enabledContainer "true" -}}{{- continue -}}{{- end -}} + {{- $containerNames = mustAppend $containerNames $cName -}} + {{- end -}} + {{- $_ := set $objectData "containerNames" $containerNames -}} + {{- include "tc.v1.common.lib.vpa.validation" (dict "objectData" $objectData "rootCtx" $) -}} + {{/* Create a copy of the workload */}} {{- $_ := set $objectData "workload" (mustDeepCopy $workload) -}} @@ -46,7 +57,7 @@ {{/* Short name is the one that defined on the chart, used on selectors */}} {{- $_ := set $objectData "shortName" $workloadName -}} - {{- if or (not $objectData.targetSelector) (hasKey $objectData.targetSelector $workloadName) -}} + {{- if or (not $objectData.targetSelector) (mustHas $workloadName $objectData.targetSelector) -}} {{/* Call class to create the object */}} {{- $types := (list "Deployment" "StatefulSet" "DaemonSet") -}} {{- if (mustHas $objectData.workload.type $types) -}}