diff --git a/library/common-test/tests/container_in_deployment/resources_test.yaml b/library/common-test/tests/container_in_deployment/resources_test.yaml index 4dc12490..5261b53f 100644 --- a/library/common-test/tests/container_in_deployment/resources_test.yaml +++ b/library/common-test/tests/container_in_deployment/resources_test.yaml @@ -19,6 +19,15 @@ tests: cpu: 10m memory: 50Mi + - it: should fail with inherit defined in main container + documentIndex: *deploymentDoc + set: + resources: + inherit: + asserts: + - failedTemplate: + errorMessage: key is only available for additional/init/install/upgrade containers. + - it: should fail with empty key in gpu documentIndex: *deploymentDoc set: @@ -35,6 +44,238 @@ tests: - failedTemplate: errorMessage: Value is not provided for GPU ( somekey) + - it: should fail with empty requests.cpu + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 3000m + memory: 4Gi + requests: + cpu: + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: cannot be empty. + + - it: should fail with empty requests.memory + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 3000m + memory: 4Gi + requests: + cpu: 20m + memory: + asserts: + - failedTemplate: + errorMessage: cannot be empty. + + - it: should fail with invalid format in requests.memory (zero) + documentIndex: *deploymentDoc + set: + scaleGPU: + somekey: + resources: + limits: + cpu: 3000m + memory: 4Gi + requests: + cpu: 20m + memory: 0.0 + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in requests.memory (zero exponent) + documentIndex: *deploymentDoc + set: + scaleGPU: + somekey: + resources: + limits: + cpu: 3000m + memory: 4Gi + requests: + cpu: 20m + memory: 0e0 + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in requests.memory (zero with suffix) + documentIndex: *deploymentDoc + set: + scaleGPU: + somekey: + resources: + limits: + cpu: 3000m + memory: 4Gi + requests: + cpu: 20m + memory: 0M + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0M). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in requests.memory (string) + documentIndex: *deploymentDoc + set: + scaleGPU: + somekey: + resources: + limits: + cpu: 3000m + memory: 4Gi + requests: + cpu: 20m + memory: not-valid + asserts: + - failedTemplate: + errorMessage: has invalid format in value (not-valid). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in limits.memory (zero) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 3000m + memory: 0.0 + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in limits.memory (zero exponent) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 3000m + memory: 0e0 + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in requests.limits (zero with suffix) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 3000m + memory: 0M + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0M). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in limits.memory (string) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 3000m + memory: not-valid + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (not-valid). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6). + + - it: should fail with invalid format in limits.cpu (zero) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 0.0 + memory: 4Gi + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m). + + - it: should fail with invalid format in limits.cpu (zero with suffix) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 0m + memory: 4Gi + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0m). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m). + + - it: should fail with invalid format in limits.cpu (string) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: not-valid + memory: 4Gi + requests: + cpu: 20m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (not-valid). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m). + + - it: should fail with invalid format in requests.cpu (zero) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 4000m + memory: 4Gi + requests: + cpu: 0.0 + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m). + + - it: should fail with invalid format in requests.cpu (zero with suffix) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 4000m + memory: 4Gi + requests: + cpu: 0m + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (0m). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m). + + - it: should fail with invalid format in requests.cpu (string) + documentIndex: *deploymentDoc + set: + resources: + limits: + cpu: 4000m + memory: 4Gi + requests: + cpu: not-valid + memory: 100Mi + asserts: + - failedTemplate: + errorMessage: has invalid format in value (not-valid). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m). + - it: should pass with changed resources documentIndex: *deploymentDoc set: @@ -165,20 +406,20 @@ tests: cpu: 20m memory: 100Mi - - it: should pass with empty resources + - it: should pass with empty resources.limits documentIndex: *deploymentDoc set: - scaleGPU: {} resources: limits: cpu: memory: - requests: - cpu: - memory: asserts: - - isNull: + - equal: path: spec.template.spec.containers[0].resources + value: + requests: + cpu: 10m + memory: 50Mi - it: should pass with only limits.cpu defined documentIndex: *deploymentDoc @@ -188,15 +429,15 @@ tests: limits: cpu: 3000m memory: - requests: - cpu: - memory: asserts: - equal: path: spec.template.spec.containers[0].resources value: limits: cpu: 3000m + requests: + cpu: 10m + memory: 50Mi - it: should pass with only limits.memory defined documentIndex: *deploymentDoc @@ -206,15 +447,15 @@ tests: limits: cpu: memory: 4Gi - requests: - cpu: - memory: asserts: - equal: path: spec.template.spec.containers[0].resources value: limits: memory: 4Gi + requests: + cpu: 10m + memory: 50Mi - it: should pass with only requests.cpu defined documentIndex: *deploymentDoc @@ -225,14 +466,14 @@ tests: cpu: memory: requests: - cpu: 10m - memory: + cpu: 30m asserts: - equal: path: spec.template.spec.containers[0].resources value: requests: - cpu: 10m + cpu: 30m + memory: 50Mi - it: should pass with only requests.memory defined documentIndex: *deploymentDoc @@ -243,14 +484,14 @@ tests: cpu: memory: requests: - cpu: - memory: 50Mi + memory: 15Mi asserts: - equal: path: spec.template.spec.containers[0].resources value: requests: - memory: 50Mi + cpu: 10m + memory: 15Mi - it: should pass with only limits.gpu defined documentIndex: *deploymentDoc @@ -261,15 +502,15 @@ tests: limits: cpu: memory: - requests: - cpu: - memory: asserts: - equal: path: spec.template.spec.containers[0].resources value: limits: gpu.intel.com/i915: "1" + requests: + cpu: 10m + memory: 50Mi - it: should pass with only requests defined documentIndex: *deploymentDoc @@ -296,18 +537,19 @@ tests: scaleGPU: {} resources: limits: - cpu: 3000m - memory: 4Gi - requests: - cpu: - memory: + cpu: 1000m + memory: 1Gi asserts: - equal: path: spec.template.spec.containers[0].resources value: limits: - cpu: 3000m - memory: 4Gi + cpu: 1000m + memory: 1Gi + requests: + cpu: 10m + memory: 50Mi + - it: should pass with only gpu defined documentIndex: *deploymentDoc @@ -318,12 +560,12 @@ tests: limits: cpu: memory: - requests: - cpu: - memory: asserts: - equal: path: spec.template.spec.containers[0].resources value: limits: gpu.intel.com/i915: "1" + requests: + cpu: 10m + memory: 50Mi diff --git a/library/common-test/tests/container_in_deployment/securityContext_test.yaml b/library/common-test/tests/container_in_deployment/securityContext_test.yaml index 07920c45..42d1976b 100644 --- a/library/common-test/tests/container_in_deployment/securityContext_test.yaml +++ b/library/common-test/tests/container_in_deployment/securityContext_test.yaml @@ -75,7 +75,7 @@ tests: inherit: true asserts: - failedTemplate: - errorMessage: key is only available for additional/init/install/upgrade containers. + errorMessage: key is only available for additional/init/install/upgrade containers. - it: should fail with securityContext changed, runAsNonRoot true and runAsUser 0 set: diff --git a/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_install_test.yaml b/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_install_test.yaml index f1ddacb4..f99b51fe 100644 --- a/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_install_test.yaml +++ b/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_install_test.yaml @@ -161,6 +161,44 @@ tests: terminationMessagePath: somePath terminationMessagePolicy: File + - it: should pass with resources inherited from main container and modified in init container + documentIndex: *deploymentDoc + set: + resources: + requests: + cpu: 25m + memory: 80Mi + initContainers: + some-name: + resources: + inherit: true + limits: + cpu: 1000m + memory: 1Gi + requests: + memory: 120Mi + asserts: + - isSubset: + path: spec.template.spec.containers[0] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + requests: + cpu: 25m + memory: 80Mi + - isSubset: + path: spec.template.spec.initContainers[0] + content: + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 25m + memory: 120Mi + - it: should pass with resources defined in init container documentIndex: *deploymentDoc set: diff --git a/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_upgrade_test.yaml b/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_upgrade_test.yaml index 502767b9..0dedd18c 100644 --- a/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_upgrade_test.yaml +++ b/library/common-test/tests/initcontainers_in_deployment/init_containers_in_deployment_upgrade_test.yaml @@ -163,6 +163,44 @@ tests: terminationMessagePath: somePath terminationMessagePolicy: File + - it: should pass with resources inherited from main container and modified in init container + documentIndex: *deploymentDoc + set: + resources: + requests: + cpu: 25m + memory: 80Mi + initContainers: + some-name: + resources: + inherit: true + limits: + cpu: 1000m + memory: 1Gi + requests: + memory: 120Mi + asserts: + - isSubset: + path: spec.template.spec.containers[0] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + requests: + cpu: 25m + memory: 80Mi + - isSubset: + path: spec.template.spec.initContainers[0] + content: + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 25m + memory: 120Mi + - it: should pass with resources defined in init container documentIndex: *deploymentDoc set: diff --git a/library/common-test/tests/initcontainers_in_deployment/install_containers_in_deployment_test.yaml b/library/common-test/tests/initcontainers_in_deployment/install_containers_in_deployment_test.yaml index 4671f7b2..cb7c3884 100644 --- a/library/common-test/tests/initcontainers_in_deployment/install_containers_in_deployment_test.yaml +++ b/library/common-test/tests/initcontainers_in_deployment/install_containers_in_deployment_test.yaml @@ -175,6 +175,44 @@ tests: terminationMessagePath: somePath terminationMessagePolicy: File + - it: should pass with resources inherited from main container and modified in init container + documentIndex: *deploymentDoc + set: + resources: + requests: + cpu: 25m + memory: 80Mi + installContainers: + some-name: + resources: + inherit: true + limits: + cpu: 1000m + memory: 1Gi + requests: + memory: 120Mi + asserts: + - isSubset: + path: spec.template.spec.containers[0] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + requests: + cpu: 25m + memory: 80Mi + - isSubset: + path: spec.template.spec.initContainers[0] + content: + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 25m + memory: 120Mi + - it: should pass with resources defined in install container documentIndex: *deploymentDoc set: diff --git a/library/common-test/tests/initcontainers_in_deployment/upgrade_containers_in_deployment_test.yaml b/library/common-test/tests/initcontainers_in_deployment/upgrade_containers_in_deployment_test.yaml index 910ecd8e..8189d0b3 100644 --- a/library/common-test/tests/initcontainers_in_deployment/upgrade_containers_in_deployment_test.yaml +++ b/library/common-test/tests/initcontainers_in_deployment/upgrade_containers_in_deployment_test.yaml @@ -177,6 +177,44 @@ tests: terminationMessagePath: somePath terminationMessagePolicy: File + - it: should pass with resources inherited from main container and modified in init container + documentIndex: *deploymentDoc + set: + resources: + requests: + cpu: 25m + memory: 80Mi + upgradeContainers: + some-name: + resources: + inherit: true + limits: + cpu: 1000m + memory: 1Gi + requests: + memory: 120Mi + asserts: + - isSubset: + path: spec.template.spec.containers[0] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + requests: + cpu: 25m + memory: 80Mi + - isSubset: + path: spec.template.spec.initContainers[0] + content: + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 25m + memory: 120Mi + - it: should pass with resources defined in upgrade container documentIndex: *deploymentDoc set: diff --git a/library/common/1.0.0/templates/lib/container/_resources.tpl b/library/common/1.0.0/templates/lib/container/_resources.tpl index 03cae47c..c0c55a0b 100644 --- a/library/common/1.0.0/templates/lib/container/_resources.tpl +++ b/library/common/1.0.0/templates/lib/container/_resources.tpl @@ -2,63 +2,52 @@ {{- define "ix.v1.common.container.resources" -}} {{- $resources := .resources -}} {{- $gpu := .gpu -}} + {{- $isMainContainer := .isMainContainer -}} {{- $root := .root -}} + {{- if and (hasKey $resources "inherit") $isMainContainer -}} + {{- fail " key is only available for additional/init/install/upgrade containers." -}} + {{- end -}} + {{/* Get defaults from global */}} {{- $defautlResources := $root.Values.global.defaults.resources -}} - {{- $limitsCPU := $defautlResources.limits.cpu -}} - {{- $limitsMemory := $defautlResources.limits.memory -}} - {{- $requestsCPU := $defautlResources.requests.cpu -}} - {{- $requestsMemory := $defautlResources.requests.memory -}} - {{/* TODO: Inherit */}} - {{/* Modify based on user/dev input */}} - {{- with $resources -}} - {{- with $resources.requests -}} - {{- if hasKey . "cpu" -}} - {{- if ne $requestsCPU .cpu -}} - {{- $requestsCPU = .cpu -}} - {{- else if not .cpu -}} {{/* If key exists but it's empty, means user/dev explicitly said "no limit" */}} - {{- $requestsCPU = "" -}} - {{- end -}} - {{- end -}} - {{- if hasKey . "memory" -}} - {{- if ne $requestsMemory .memory -}} - {{- $requestsMemory = .memory -}} - {{- else if not .memory -}} {{/* If key exists but it's empty, means user/dev explicitly said "no limit" */}} - {{- $requestsMemory = "" -}} - {{- end -}} - {{- end -}} - {{- end -}} - {{- with $resources.limits -}} - {{- if hasKey . "cpu" -}} - {{- if ne $limitsCPU .cpu -}} - {{- $limitsCPU = .cpu -}} - {{- else if not .cpu -}} {{/* If key exists but it's empty, means user/dev explicitly said "no limit" */}} - {{- $limitsCPU = "" -}} - {{- end -}} - {{- end -}} - {{- if hasKey . "memory" -}} - {{- if ne $limitsMemory .memory -}} - {{- $limitsMemory = .memory -}} - {{- else if not .memory -}} {{/* If key exists but it's empty, means user/dev explicitly said "no limit" */}} - {{- $limitsMemory = "" -}} - {{- end -}} - {{- end -}} + {{- $newResources := (mustDeepCopy $defautlResources) -}} + + {{- if and $resources.inherit (not $isMainContainer) -}} {{/* if inherit is set, overwrite defaults with values from mainContainer */}} + {{- if (hasKey $root.Values "resources") -}} + {{- $newResources = mustMergeOverwrite $newResources $root.Values.resources -}} {{- end -}} {{- end -}} - {{- if or $resources $defautlResources $gpu -}} - {{- if or $requestsCPU $requestsMemory -}} - {{- with (include "ix.v1.common.container.resources.cpuAndMemory" (dict "cpu" $requestsCPU "memory" $requestsMemory)) }} + {{/* Overwrite from values that user/dev passed on this container */}} + {{- $newResources = mustMergeOverwrite $newResources $resources -}} + + {{/* Validate Values */}} + {{- include "ix.v1.common.lib.resources.validate" (dict "key" "cpu" + "object" "requests" + "required" true + "value" $newResources.requests.cpu) -}} + {{- include "ix.v1.common.lib.resources.validate" (dict "key" "memory" + "object" "requests" + "required" true + "value" $newResources.requests.memory) -}} + {{- include "ix.v1.common.lib.resources.validate" (dict "key" "cpu" + "object" "limits" + "required" false + "value" $newResources.limits.cpu) -}} + {{- include "ix.v1.common.lib.resources.validate" (dict "key" "memory" + "object" "limits" + "required" false + "value" $newResources.limits.memory) -}} + + {{- with (include "ix.v1.common.container.resources.cpuAndMemory" (dict "cpu" $newResources.requests.cpu "memory" $newResources.requests.memory)) }} requests: - {{- . | indent 2 -}} - {{- end -}} - {{- end -}} - {{- if or $limitsCPU $limitsMemory $gpu }} + {{- . | indent 2 -}} + {{- end -}} + {{- if or $newResources.limits.cpu $newResources.limits.memory $gpu }} limits: - {{- include "ix.v1.common.container.resources.cpuAndMemory" (dict "cpu" $limitsCPU "memory" $limitsMemory) | indent 2 -}} - {{- include "ix.v1.common.container.resources.gpu" (dict "gpu" $gpu) | indent 2 -}} - {{- end -}} + {{- include "ix.v1.common.container.resources.cpuAndMemory" (dict "cpu" $newResources.limits.cpu "memory" $newResources.limits.memory) | indent 2 -}} + {{- include "ix.v1.common.container.resources.gpu" (dict "gpu" $gpu) | indent 2 -}} {{- end -}} {{- end -}} @@ -87,3 +76,37 @@ memory: {{ . }} {{- end -}} {{- end -}} {{- end -}} + +{{/* Validates resources to match a pattern */}} +{{- define "ix.v1.common.lib.resources.validate" -}} + {{- $key := .key -}} + {{- $object := .object -}} + {{- $value := .value -}} + {{- $required := .required -}} + + {{- with (toString $value) -}} {{/* Stringify to avoid falsy values evaluating as false */}} + + {{- if $required -}} {{/* If requred and it's empty fail (requests are requried) */}} + {{- if eq . "" -}} + {{- fail (printf " cannot be empty." $object $key) -}} + {{- end -}} + {{- end -}} + + {{/* If it's not null validate input */}} + {{- if ne . "" -}} {{/* Limits can be null, means "no limit" */}} + {{- if eq $key "cpu" -}} + {{/* https://regex101.com/r/TlVTXr/3 */}} {{/*TODO: smallify this? */}} + {{- if not (mustRegexMatch "^([1-9][0-9]*(\\.\\[0-9]+)?m|[1-9][0-9]*|[0-9]*\\.[1-9][0-9]*(m)?)$" .) -}} + {{- fail (printf " has invalid format in value (%s). Valid formats are (Plain Integer eg. 1) (Float eg. 0.5) (Milicpu 500m)." $object $key .) -}} + {{- end -}} + + {{- else if eq $key "memory" -}} + {{/* https://regex101.com/r/NNPV2D/1 */}} + {{- if not (mustRegexMatch "^[1-9][0-9]*([EPTGMK]i?|e[0-9]+)?$" .) -}} + {{- fail (printf " has invalid format in value (%s). Valid formats are (Suffixed with EPTGMK eg. 1G) (Suffixed with EPTGMK + i eg. 1Gi) (Plain integer (in bytes) eg. 1024) (Exponent eg. 134e6)." $object $key .) -}} + {{- end -}} + {{- end -}} + {{- end -}} + + {{- end -}} +{{- end -}} diff --git a/library/common/1.0.0/templates/lib/container/_security.tpl b/library/common/1.0.0/templates/lib/container/_security.tpl index d5ad09e7..553b960c 100644 --- a/library/common/1.0.0/templates/lib/container/_security.tpl +++ b/library/common/1.0.0/templates/lib/container/_security.tpl @@ -13,16 +13,15 @@ The reason is not splitted, is that on one of the places needs a combo of all va {{/* Initialiaze Values */}} {{- $defaultSecCont := $root.Values.global.defaults.securityContext -}} - {{- $returnValue := (deepCopy $defaultSecCont) -}} + {{- $returnValue := (mustDeepCopy $defaultSecCont) -}} {{/* TODO: deviceList + suppleGroups */}} {{- if and (hasKey $secCont "inherit") $isMainContainer -}} - {{- fail " key is only available for additional/init/install/upgrade containers." -}} + {{- fail " key is only available for additional/init/install/upgrade containers." -}} {{- end -}} - {{/* SecurityContext */}} - {{- if and $secCont.inherit (not $isMainContainer) -}} {{/* if inherit is set, overwrite defaults with values from mainContainer */}} + {{- if and $secCont.inherit (not $isMainContainer) -}} {{/* if inherit is set, overwrite values from mainContainer */}} {{- if (hasKey $root.Values "securityContext") -}} {{- $returnValue = mustMergeOverwrite $returnValue $root.Values.securityContext -}} {{- end -}} @@ -77,7 +76,7 @@ The reason is not splitted, is that on one of the places needs a combo of all va {{/* Initialiaze Values */}} {{- $defaultPodSecCont := $root.Values.global.defaults.podSecurityContext -}} - {{- $returnValue := (deepCopy $defaultPodSecCont) -}} + {{- $returnValue := (mustDeepCopy $defaultPodSecCont) -}} {{/* Overwrite from values that user/dev passed */}} {{- $returnValue = mustMergeOverwrite $returnValue $podSecCont -}} @@ -106,7 +105,7 @@ The reason is not splitted, is that on one of the places needs a combo of all va {{/* Initialiaze Values */}} {{- $defaultSecEnvs := $root.Values.global.defaults.security -}} - {{- $returnValue := (deepCopy $defaultSecEnvs) -}} + {{- $returnValue := (mustDeepCopy $defaultSecEnvs) -}} {{/* Overwrite from values that user/dev passed */}} {{- $returnValue = mustMergeOverwrite $returnValue $secEnvs -}} diff --git a/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl b/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl index b01b0ae3..51bd5dff 100644 --- a/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl +++ b/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl @@ -78,7 +78,10 @@ terminationMessagePolicy: {{ . }} {{- end -}} {{- end -}} - {{- with (include "ix.v1.common.container.resources" (dict "resources" $container.resources "gpu" $container.scaleGPU "root" $root) | trim) }} + {{- with (include "ix.v1.common.container.resources" (dict "resources" $container.resources + "gpu" $container.scaleGPU + "isMainContainer" false + "root" $root) | trim) }} resources: {{- . | nindent 4 }} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl b/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl index c1984dd1..56535e0d 100644 --- a/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl +++ b/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl @@ -61,7 +61,10 @@ So it can work on multiple places, like additional containers and not only the m {{- with (include "ix.v1.common.container.probes" (dict "probes" .Values.probes "services" .Values.service "root" $) | trim) }} {{- . | nindent 2 }} {{- end -}} - {{- with (include "ix.v1.common.container.resources" (dict "resources" .Values.resources "gpu" .Values.scaleGPU "root" $) | trim) }} + {{- with (include "ix.v1.common.container.resources" (dict "resources" .Values.resources + "gpu" .Values.scaleGPU + "isMainContainer" true + "root" $) | trim) }} resources: {{- . | nindent 4 }} {{- end -}}