diff --git a/library/common-test/tests/deployment/dns-network_test.yaml b/library/common-test/tests/deployment/dns-network_test.yaml index 6b69ba1199..2b6c1dbc7a 100644 --- a/library/common-test/tests/deployment/dns-network_test.yaml +++ b/library/common-test/tests/deployment/dns-network_test.yaml @@ -109,8 +109,11 @@ tests: - it: should pass with hostNet and changed dnsPolicy documentIndex: *deploymentDoc set: - dnsPolicy: Default - hostNetwork: true + controllers: + main: + pod: + dnsPolicy: Default + hostNetwork: true asserts: - equal: path: spec.template.spec.dnsPolicy @@ -326,8 +329,11 @@ tests: - it: should fail without hostnames in hostAliases set: - hostAliases: - - ip: 1.1.1.1 + controllers: + main: + pod: + hostAliases: + - ip: 1.1.1.1 asserts: - failedTemplate: errorMessage: At least one is required in hostAliases diff --git a/library/common-test/tests/deployment/label_test.yaml b/library/common-test/tests/deployment/label_test.yaml index 979eac28de..05bc4e69e5 100644 --- a/library/common-test/tests/deployment/label_test.yaml +++ b/library/common-test/tests/deployment/label_test.yaml @@ -34,10 +34,11 @@ tests: documentIndex: *deploymentDoc set: some_key: some_value - controller: - labels: - controller_key: controller_value - controller_key2: "{{ .Values.some_key }}" + controllers: + main: + labels: + controller_key: controller_value + controller_key2: "{{ .Values.some_key }}" global: labels: global_key: global_value @@ -63,9 +64,12 @@ tests: documentIndex: *deploymentDoc set: some_key: some_value2 - podLabels: - test: some_value - test2: "{{ .Values.some_key }}" + controllers: + main: + pod: + labels: + test: some_value + test2: "{{ .Values.some_key }}" asserts: - equal: path: spec.template.metadata.labels.test2 diff --git a/library/common-test/tests/deployment/names_test.yaml b/library/common-test/tests/deployment/names_test.yaml index a626c68f8b..696345ea7a 100644 --- a/library/common-test/tests/deployment/names_test.yaml +++ b/library/common-test/tests/deployment/names_test.yaml @@ -16,7 +16,9 @@ tests: - it: should pass with nameOverride documentIndex: *deploymentDoc set: - nameOverride: overrodename + controllers: + main: + nameOverride: overrodename asserts: - equal: path: metadata.name @@ -25,7 +27,9 @@ tests: - it: should pass with global.nameOverride documentIndex: *deploymentDoc set: - nameOverride: overrodename + controllers: + main: + nameOverride: overrodename global: nameOverride: globaloverrodename asserts: diff --git a/library/common-test/tests/deployment/podSecurityContext_test.yaml b/library/common-test/tests/deployment/podSecurityContext_test.yaml index a2dbc06a50..0385269100 100644 --- a/library/common-test/tests/deployment/podSecurityContext_test.yaml +++ b/library/common-test/tests/deployment/podSecurityContext_test.yaml @@ -16,7 +16,7 @@ tests: fsGroupChangePolicy: OnRootMismatch supplementalGroups: [] - - it: should pass with changed podSecurity values + - it: should pass with changed podSecurity values from default documentIndex: *deploymentDoc set: podSecurityContext: @@ -33,42 +33,77 @@ tests: supplementalGroups: - 1000 + - it: should pass with changed podSecurity values + documentIndex: *deploymentDoc + set: + controllers: + main: + pod: + securityContext: + fsGroup: 999 + fsGroupChangePolicy: Always + supplementalGroups: + - 1000 + asserts: + - equal: + path: spec.template.spec.securityContext + value: + fsGroup: 999 + fsGroupChangePolicy: Always + supplementalGroups: + - 1000 + - it: should fail with invalid fsGroupChangePolicy set: - podSecurityContext: - fsGroupChangePolicy: invalid_policy + controllers: + main: + pod: + securityContext: + fsGroupChangePolicy: invalid_policy asserts: - failedTemplate: errorMessage: Invalid option for fsGroupChangePolicy. Valid options are and . - it: should fail with empty fsGroupChangePolicy set: - podSecurityContext: - fsGroupChangePolicy: + controllers: + main: + pod: + securityContext: + fsGroupChangePolicy: asserts: - failedTemplate: errorMessage: key cannot be empty. Set a value or remove the key for the default (OnRootMismatch) to take effect. - it: should fail with empty fsGroup set: - podSecurityContext: - fsGroup: + controllers: + main: + pod: + securityContext: + fsGroup: asserts: - failedTemplate: errorMessage: key cannot be empty. Set a value or remove the key for the default (568) to take effect. - it: should fail with non-int fsGroup set: - podSecurityContext: - fsGroup: "1000" + controllers: + main: + pod: + securityContext: + fsGroup: "1000" asserts: - failedTemplate: errorMessage: key has value of ("1000"). But must be an int. - it: should fail with empty supplementalGroups set: - podSecurityContext: - supplementalGroups: + controllers: + main: + pod: + securityContext: + supplementalGroups: asserts: - failedTemplate: errorMessage: key has a value (). But it must be a list. Set a list value or remove the key for the default ([]) to take effect. diff --git a/library/common-test/tests/deployment/runtimeClass_test.yaml b/library/common-test/tests/deployment/runtimeClass_test.yaml index 28cf9317fc..cc242bed9f 100644 --- a/library/common-test/tests/deployment/runtimeClass_test.yaml +++ b/library/common-test/tests/deployment/runtimeClass_test.yaml @@ -45,7 +45,10 @@ tests: - it: should pass overriding global and per pod runtime documentIndex: *deploymentDoc set: - runtimeClassName: perpod + controllers: + main: + pod: + runtimeClassName: perpod scaleGPU: something: blabla globalDefaults: @@ -82,7 +85,10 @@ tests: - it: should pass with pod runtime set documentIndex: *deploymentDoc set: - runtimeClassName: something + controllers: + main: + pod: + runtimeClassName: something asserts: - equal: path: spec.template.spec.runtimeClassName diff --git a/library/common-test/tests/deployment/various_options_test.yaml b/library/common-test/tests/deployment/various_options_test.yaml index 869d0526ac..dd09b56ca6 100644 --- a/library/common-test/tests/deployment/various_options_test.yaml +++ b/library/common-test/tests/deployment/various_options_test.yaml @@ -15,7 +15,10 @@ tests: - it: should pass with terminationGracePeriodSeconds set documentIndex: *deploymentDoc set: - terminationGracePeriodSeconds: 25 + controllers: + main: + pod: + terminationGracePeriodSeconds: 25 asserts: - equal: path: spec.template.spec.terminationGracePeriodSeconds @@ -24,7 +27,10 @@ tests: - it: should pass with schedulerName set documentIndex: *deploymentDoc set: - schedulerName: some_scheduler + controllers: + main: + pod: + schedulerName: some_scheduler asserts: - equal: path: spec.template.spec.schedulerName @@ -34,7 +40,10 @@ tests: documentIndex: *deploymentDoc set: name: some_scheduler - schedulerName: "{{ .Values.name }}" + controllers: + main: + pod: + schedulerName: "{{ .Values.name }}" asserts: - equal: path: spec.template.spec.schedulerName @@ -43,7 +52,10 @@ tests: - it: should pass with schedulerName set documentIndex: *deploymentDoc set: - priorityClassName: some_priority_class_name + controllers: + main: + pod: + priorityClassName: some_priority_class_name asserts: - equal: path: spec.template.spec.priorityClassName @@ -53,7 +65,10 @@ tests: documentIndex: *deploymentDoc set: name: some_priority_class_name - priorityClassName: "{{ .Values.name }}" + controllers: + main: + pod: + priorityClassName: "{{ .Values.name }}" asserts: - equal: path: spec.template.spec.priorityClassName @@ -69,7 +84,10 @@ tests: - it: should pass with set restartPolicy documentIndex: *deploymentDoc set: - restartPolicy: Always + controllers: + main: + pod: + restartPolicy: Always asserts: - equal: path: spec.template.spec.restartPolicy @@ -77,54 +95,54 @@ tests: - it: should fail with invalid restartPolicy set: - restartPolicy: invalid + controllers: + main: + pod: + restartPolicy: invalid asserts: - failedTemplate: errorMessage: Invalid (invalid). Valid options are Always, Never, OnFailure - it: should fail with invalid restartPolicy on Deployment set: - controller: - type: Deployment - restartPolicy: OnFailure + controllers: + main: + type: Deployment + pod: + restartPolicy: OnFailure asserts: - failedTemplate: - errorMessage: Invalid @@ -132,9 +150,12 @@ tests: - it: should pass with nodeSelector set documentIndex: *deploymentDoc set: - nodeSelector: - diskType: ssd - cpuType: intel + controllers: + main: + pod: + nodeSelector: + diskType: ssd + cpuType: intel asserts: - equal: path: spec.template.spec.nodeSelector @@ -147,9 +168,12 @@ tests: set: some_key: ssd some_other_key: intel - nodeSelector: - diskType: "{{ .Values.some_key }}" - cpuType: "{{ .Values.some_other_key }}" + controllers: + main: + pod: + nodeSelector: + diskType: "{{ .Values.some_key }}" + cpuType: "{{ .Values.some_other_key }}" asserts: - equal: path: spec.template.spec.nodeSelector @@ -159,44 +183,59 @@ tests: - it: should fail with invalid operator in tolerations set: - tolerations: - - operator: invalid_op + controllers: + main: + pod: + tolerations: + - operator: invalid_op asserts: - failedTemplate: errorMessage: Invalid . Valid options are Exists, Equal. - it: should fail with invalid effect in tolerations set: - tolerations: - - effect: invalid_effect - operator: Exists + controllers: + main: + pod: + tolerations: + - effect: invalid_effect + operator: Exists asserts: - failedTemplate: errorMessage: Invalid (invalid_effect). Valid options are NoExecute, NoSchedule, PreferNoSchedule - it: should fail with empty key and operator Equal in tolerations set: - tolerations: - - key: "" - operator: Equal + controllers: + main: + pod: + tolerations: + - key: "" + operator: Equal asserts: - failedTemplate: errorMessage: is required when is set to - it: should fail with operator Exists and defined value in tolerations set: - tolerations: - - value: something - operator: Exists + controllers: + main: + pod: + tolerations: + - value: something + operator: Exists asserts: - failedTemplate: errorMessage: When is set to , you cannot define a - it: should fail with operator Exists and non-integer tolerationSeconds in tolerations set: - tolerations: - - tolerationSeconds: not_an_int - operator: Exists + controllers: + main: + pod: + tolerations: + - tolerationSeconds: not_an_int + operator: Exists asserts: - failedTemplate: errorMessage: must result to an integer. @@ -204,9 +243,12 @@ tests: - it: should pass with tolerations defined, with tolerationSeconds set documentIndex: *deploymentDoc set: - tolerations: - - operator: Exists - tolerationSeconds: 6000 + controllers: + main: + pod: + tolerations: + - operator: Exists + tolerationSeconds: 6000 asserts: - equal: path: spec.template.spec.tolerations @@ -217,8 +259,11 @@ tests: - it: should pass with tolerations defined, with only operator Exists documentIndex: *deploymentDoc set: - tolerations: - - operator: Exists + controllers: + main: + pod: + tolerations: + - operator: Exists asserts: - equal: path: spec.template.spec.tolerations @@ -229,8 +274,11 @@ tests: documentIndex: *deploymentDoc set: op: Exists - tolerations: - - operator: "{{ .Values.op }}" + controllers: + main: + pod: + tolerations: + - operator: "{{ .Values.op }}" asserts: - equal: path: spec.template.spec.tolerations @@ -240,9 +288,12 @@ tests: - it: should pass with tolerations defined, with only operator Equal and key defined documentIndex: *deploymentDoc set: - tolerations: - - operator: Equal - key: key1 + controllers: + main: + pod: + tolerations: + - operator: Equal + key: key1 asserts: - equal: path: spec.template.spec.tolerations @@ -254,9 +305,12 @@ tests: documentIndex: *deploymentDoc set: some_key: key1 - tolerations: - - operator: Equal - key: "{{ .Values.some_key }}" + controllers: + main: + pod: + tolerations: + - operator: Equal + key: "{{ .Values.some_key }}" asserts: - equal: path: spec.template.spec.tolerations @@ -267,9 +321,12 @@ tests: - it: should pass with tolerations defined, with operator Exists and effect defined documentIndex: *deploymentDoc set: - tolerations: - - operator: Exists - effect: NoExecute + controllers: + main: + pod: + tolerations: + - operator: Exists + effect: NoExecute asserts: - equal: path: spec.template.spec.tolerations @@ -281,9 +338,12 @@ tests: documentIndex: *deploymentDoc set: ef1: NoExecute - tolerations: - - operator: Exists - effect: "{{ .Values.ef1 }}" + controllers: + main: + pod: + tolerations: + - operator: Exists + effect: "{{ .Values.ef1 }}" asserts: - equal: path: spec.template.spec.tolerations @@ -294,10 +354,13 @@ tests: - it: should pass with tolerations defined, with operator Equal and value defined documentIndex: *deploymentDoc set: - tolerations: - - operator: Equal - value: some_value - key: key1 + controllers: + main: + pod: + tolerations: + - operator: Equal + value: some_value + key: key1 asserts: - equal: path: spec.template.spec.tolerations @@ -310,10 +373,13 @@ tests: documentIndex: *deploymentDoc set: val: some_value - tolerations: - - operator: Equal - value: "{{ .Values.val }}" - key: key1 + controllers: + main: + pod: + tolerations: + - operator: Equal + value: "{{ .Values.val }}" + key: key1 asserts: - equal: path: spec.template.spec.tolerations @@ -326,10 +392,13 @@ tests: documentIndex: *deploymentDoc set: val: some_value - tolerations: - - operator: Equal - value: "{{ .Values.val }}" - key: key1 + controllers: + main: + pod: + tolerations: + - operator: Equal + value: "{{ .Values.val }}" + key: key1 asserts: - equal: path: spec.template.spec.tolerations @@ -341,12 +410,15 @@ tests: - it: should pass with tolerations defined, with everything set, multiple entries documentIndex: *deploymentDoc set: - tolerations: - - operator: Equal - value: some_value - key: key1 - effect: NoExecute - tolerationSeconds: 6000 + controllers: + main: + pod: + tolerations: + - operator: Equal + value: some_value + key: key1 + effect: NoExecute + tolerationSeconds: 6000 asserts: - equal: path: spec.template.spec.tolerations @@ -368,17 +440,20 @@ tests: val2: some_value2 k2: key2 ef2: NoSchedule - tolerations: - - operator: "{{ .Values.op1 }}" - value: "{{ .Values.val1 }}" - key: "{{ .Values.k1 }}" - effect: "{{ .Values.ef1 }}" - tolerationSeconds: 6000 - - operator: "{{ .Values.op2 }}" - value: "{{ .Values.val2 }}" - key: "{{ .Values.k2 }}" - effect: "{{ .Values.ef2 }}" - tolerationSeconds: 6000 + controllers: + main: + pod: + tolerations: + - operator: "{{ .Values.op1 }}" + value: "{{ .Values.val1 }}" + key: "{{ .Values.k1 }}" + effect: "{{ .Values.ef1 }}" + tolerationSeconds: 6000 + - operator: "{{ .Values.op2 }}" + value: "{{ .Values.val2 }}" + key: "{{ .Values.k2 }}" + effect: "{{ .Values.ef2 }}" + tolerationSeconds: 6000 asserts: - equal: path: spec.template.spec.tolerations diff --git a/library/common/1.0.0/templates/lib/pod/_dns.tpl b/library/common/1.0.0/templates/lib/pod/_dns.tpl index 9fac5be993..de0f32cf4c 100644 --- a/library/common/1.0.0/templates/lib/pod/_dns.tpl +++ b/library/common/1.0.0/templates/lib/pod/_dns.tpl @@ -3,16 +3,15 @@ {{- $dnsPolicy := .dnsPolicy -}} {{- $hostNetwork := .hostNetwork -}} {{- $root := .root -}} - {{- $policy := $root.Values.dnsPolicy -}} {{- if $dnsPolicy -}} - {{- if not (mustHas $dnsPolicy (list "Default" "ClusterFirst" "ClusterFirstWithHostNet" "None")) -}} - {{- fail (printf "Not valid dnsPolicy (%s). Valid options are ClusterFirst, Default, ClusterFirstWithHostNet, None" $dnsPolicy) -}} - {{- end -}} {{- $policy = $dnsPolicy -}} {{- else if $hostNetwork -}} {{- $policy = "ClusterFirstWithHostNet" -}} {{- end -}} + {{- if not (mustHas $policy (list "Default" "ClusterFirst" "ClusterFirstWithHostNet" "None")) -}} + {{- fail (printf "Not valid dnsPolicy (%s). Valid options are ClusterFirst, Default, ClusterFirstWithHostNet, None" $policy) -}} + {{- end -}} {{- $policy -}} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/pod/_pod.tpl b/library/common/1.0.0/templates/lib/pod/_pod.tpl index 1ecc76b24c..c36212e591 100644 --- a/library/common/1.0.0/templates/lib/pod/_pod.tpl +++ b/library/common/1.0.0/templates/lib/pod/_pod.tpl @@ -27,11 +27,13 @@ priorityClassName: {{ . }} hostname: {{ . }} {{- end -}} +{{- $dnsPol := (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $values.controllers.main.pod.dnsPolicy "hostNetwork" $hostNet "root" $root) | trim ) -}} {{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $values.controllers.main.pod.dnsPolicy "hostNetwork" $hostNet "root" $root) | trim ) }} dnsPolicy: {{ . }} {{- end -}} -{{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" $values.controllers.main.pod.dnsPolicy "dnsConfig" $values.controllers.main.pod.dnsConfig "root" $root) | trim ) }} +{{- $dnsConf := ($values.controllers.main.pod.dnsConfig | default $root.Values.dnsConfig) -}} +{{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" $dnsPol "dnsConfig" $dnsConf "root" $root) | trim ) }} dnsConfig: {{- . | nindent 2 }} {{- end -}}