From 667da2ee40a155338b1a5a32b04942ff7f4f3d99 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Sat, 28 Jan 2023 20:46:48 +0200 Subject: [PATCH] more changes --- library/common-test/ci/basic-values.yaml | 26 +- library/common-test/ci/configmap-values.yaml | 26 +- library/common-test/ci/daemonset-values.yaml | 33 +- .../common-test/ci/persistence-values.yaml | 25 +- library/common-test/ci/rbac-values.yaml | 25 +- library/common-test/ci/secrets-values.yaml | 25 +- .../common-test/ci/statefulset-values.yaml | 36 +- .../command-arg_test.yaml | 177 ++++-- .../container_in_deployment/env_from.yaml | 122 ++-- .../container_in_deployment/env_list.yaml | 122 ++-- .../container_in_deployment/env_test.yaml | 528 ++++++++++------ .../fixedEnv_test.yaml | 165 +++-- .../container_in_deployment/image_test.yaml | 35 +- .../lifecycle_test.yaml | 160 +++-- .../container_in_deployment/port_test.yaml | 19 +- .../container_in_deployment/probe_test.yaml | 578 ++++++++++++------ .../common/1.0.0/templates/class/_service.tpl | 4 +- .../1.0.0/templates/lib/container/_probes.tpl | 1 - .../templates/lib/container/_security.tpl | 5 +- .../templates/lib/container/_volumeMounts.tpl | 4 +- .../lib/container/env/_fixedEnvs.tpl | 2 +- .../1.0.0/templates/lib/general/_names.tpl | 16 +- .../1.0.0/templates/lib/job/_jobPod.tpl | 32 +- .../1.0.0/templates/lib/job/_jobTemplate.tpl | 2 +- .../templates/lib/pod/_extraContainers.tpl | 11 +- .../templates/lib/pod/_mainContainer.tpl | 17 +- .../common/1.0.0/templates/lib/pod/_pod.tpl | 28 +- .../templates/lib/pod/_podAnnotations.tpl | 2 +- .../1.0.0/templates/lib/pod/_podLabels.tpl | 2 +- .../templates/lib/pod/_restartPolicy.tpl | 2 +- .../templates/lib/pod/_runtimeClassName.tpl | 2 +- .../lib/values/lists/_deviceList.tpl | 2 +- .../common/1.0.0/templates/loader/_apply.tpl | 12 +- .../1.0.0/templates/pods/_daemonset.tpl | 10 +- .../1.0.0/templates/pods/_deployment.tpl | 12 +- .../1.0.0/templates/pods/_statefulset.tpl | 12 +- .../templates/spawner/_jobAndCronJob.tpl | 12 +- library/common/1.0.0/values.yaml | 296 ++++----- 38 files changed, 1658 insertions(+), 930 deletions(-) diff --git a/library/common-test/ci/basic-values.yaml b/library/common-test/ci/basic-values.yaml index 16c6b98b04..f51d3375a6 100644 --- a/library/common-test/ci/basic-values.yaml +++ b/library/common-test/ci/basic-values.yaml @@ -10,14 +10,18 @@ service: protocol: HTTP port: 8080 -args: - - --port - - "8080" - -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true +controllers: + main: + pod: + containers: + main: + args: + - --port + - "8080" + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true diff --git a/library/common-test/ci/configmap-values.yaml b/library/common-test/ci/configmap-values.yaml index 254a3c5199..ac70a8044f 100644 --- a/library/common-test/ci/configmap-values.yaml +++ b/library/common-test/ci/configmap-values.yaml @@ -9,18 +9,22 @@ service: main: protocol: HTTP port: 8080 +controllers: + main: + pod: + containers: + main: + args: + - --port + - "8080" -args: - - --port - - "8080" - -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true k1: value1 k2: 80 diff --git a/library/common-test/ci/daemonset-values.yaml b/library/common-test/ci/daemonset-values.yaml index dd678d2704..4f42f65be0 100644 --- a/library/common-test/ci/daemonset-values.yaml +++ b/library/common-test/ci/daemonset-values.yaml @@ -3,13 +3,6 @@ image: pullPolicy: IfNotPresent tag: latest -controller: - # -- Enable the controller. - enabled: true - # -- Set the controller type. - # Valid options are: Deployment | DaemonSet | StatefulSet - type: DaemonSet - service: main: ports: @@ -17,14 +10,20 @@ service: protocol: HTTP port: 8080 -args: - - --port - - "8080" +controllers: + main: + type: DaemonSet + pod: + containers: + main: + args: + - --port + - "8080" -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true diff --git a/library/common-test/ci/persistence-values.yaml b/library/common-test/ci/persistence-values.yaml index fc6c323a18..73f5972456 100644 --- a/library/common-test/ci/persistence-values.yaml +++ b/library/common-test/ci/persistence-values.yaml @@ -9,17 +9,22 @@ service: main: port: 8080 -args: - - --port - - '8080' +controllers: + main: + pod: + containers: + main: + args: + - --port + - '8080' -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true persistence: pvc-stock: diff --git a/library/common-test/ci/rbac-values.yaml b/library/common-test/ci/rbac-values.yaml index 5e6de232b6..326735fc0b 100644 --- a/library/common-test/ci/rbac-values.yaml +++ b/library/common-test/ci/rbac-values.yaml @@ -9,17 +9,22 @@ service: main: port: 8080 -args: - - --port - - '8080' +controllers: + main: + pod: + containers: + main: + args: + - --port + - '8080' -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true rbac: main: diff --git a/library/common-test/ci/secrets-values.yaml b/library/common-test/ci/secrets-values.yaml index e1a90a96ec..cd883e3ae0 100644 --- a/library/common-test/ci/secrets-values.yaml +++ b/library/common-test/ci/secrets-values.yaml @@ -10,17 +10,22 @@ service: protocol: HTTP port: 8080 -args: - - --port - - "8080" +controllers: + main: + pod: + containers: + main: + args: + - --port + - "8080" -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true k1: value1 k2: 80 diff --git a/library/common-test/ci/statefulset-values.yaml b/library/common-test/ci/statefulset-values.yaml index e1bfd36363..fc772eb347 100644 --- a/library/common-test/ci/statefulset-values.yaml +++ b/library/common-test/ci/statefulset-values.yaml @@ -3,15 +3,6 @@ image: pullPolicy: IfNotPresent tag: latest -controller: - # -- Enable the controller. - enabled: true - # -- Set the controller type. - # Valid options are: Deployment | DaemonSet | StatefulSet - type: StatefulSet - # -- Number of desired pods - replicas: 2 - volumeClaimTemplates: test: mountPath: /test @@ -25,14 +16,21 @@ service: protocol: HTTP port: 8080 -args: - - --port - - "8080" +controllers: + main: + type: StatefulSet + replicas: 2 + pod: + containers: + main: + args: + - --port + - "8080" -probes: - liveness: - enabled: true - readiness: - enabled: true - startup: - enabled: true + probes: + liveness: + enabled: true + readiness: + enabled: true + startup: + enabled: true diff --git a/library/common-test/tests/container_in_deployment/command-arg_test.yaml b/library/common-test/tests/container_in_deployment/command-arg_test.yaml index e5e912e906..d04aa4c587 100644 --- a/library/common-test/tests/container_in_deployment/command-arg_test.yaml +++ b/library/common-test/tests/container_in_deployment/command-arg_test.yaml @@ -13,7 +13,12 @@ tests: - it: should pass with command set single value documentIndex: *deploymentDoc set: - command: entrypoint.sh + controllers: + main: + pod: + containers: + main: + command: entrypoint.sh asserts: - equal: path: spec.template.spec.containers[0].command @@ -24,7 +29,12 @@ tests: documentIndex: *deploymentDoc set: cmd: entrypoint.sh - command: "{{ .Values.cmd }}" + controllers: + main: + pod: + containers: + main: + command: "{{ .Values.cmd }}" asserts: - equal: path: spec.template.spec.containers[0].command @@ -34,9 +44,14 @@ tests: - it: should pass with command set documentIndex: *deploymentDoc set: - command: - - /bin/bash - - test + controllers: + main: + pod: + containers: + main: + command: + - /bin/bash + - test asserts: - equal: path: spec.template.spec.containers[0].command @@ -47,12 +62,17 @@ tests: - it: should pass with command block set documentIndex: *deploymentDoc set: - command: - - /bin/bash - - -c - - | - echo "works!" - exit + controllers: + main: + pod: + containers: + main: + command: + - /bin/bash + - -c + - | + echo "works!" + exit asserts: - equal: path: spec.template.spec.containers[0].command @@ -67,9 +87,14 @@ tests: documentIndex: *deploymentDoc set: some_key: some_value - command: - - /bin/bash - - "{{ .Values.some_key }}" + controllers: + main: + pod: + containers: + main: + command: + - /bin/bash + - "{{ .Values.some_key }}" asserts: - equal: path: spec.template.spec.containers[0].command @@ -80,7 +105,12 @@ tests: - it: should pass with args set with single value documentIndex: *deploymentDoc set: - args: --worker + controllers: + main: + pod: + containers: + main: + args: --worker asserts: - equal: path: spec.template.spec.containers[0].args @@ -91,7 +121,12 @@ tests: documentIndex: *deploymentDoc set: some_arg: --worker - args: "{{ .Values.some_arg }}" + controllers: + main: + pod: + containers: + main: + args: "{{ .Values.some_arg }}" asserts: - equal: path: spec.template.spec.containers[0].args @@ -101,9 +136,14 @@ tests: - it: should pass with args set documentIndex: *deploymentDoc set: - args: - - --port - - 8000 + controllers: + main: + pod: + containers: + main: + args: + - --port + - 8000 asserts: - equal: path: spec.template.spec.containers[0].args @@ -115,9 +155,14 @@ tests: documentIndex: *deploymentDoc set: some_port: 9000 - args: - - --port - - "{{ .Values.some_port }}" + controllers: + main: + pod: + containers: + main: + args: + - --port + - "{{ .Values.some_port }}" asserts: - equal: path: spec.template.spec.containers[0].args @@ -128,7 +173,12 @@ tests: - it: should pass with extraArgs set single value documentIndex: *deploymentDoc set: - extraArgs: --worker + controllers: + main: + pod: + containers: + main: + extraArgs: --worker asserts: - equal: path: spec.template.spec.containers[0].args @@ -139,7 +189,12 @@ tests: documentIndex: *deploymentDoc set: some_extra_arg: --worker - extraArgs: "{{ .Values.some_extra_arg }}" + controllers: + main: + pod: + containers: + main: + extraArgs: "{{ .Values.some_extra_arg }}" asserts: - equal: path: spec.template.spec.containers[0].args @@ -149,9 +204,14 @@ tests: - it: should pass with extraArgs set documentIndex: *deploymentDoc set: - extraArgs: - - --port - - 8000 + controllers: + main: + pod: + containers: + main: + extraArgs: + - --port + - 8000 asserts: - equal: path: spec.template.spec.containers[0].args @@ -163,9 +223,14 @@ tests: documentIndex: *deploymentDoc set: some_port: 9000 - extraArgs: - - --port - - "{{ .Values.some_port }}" + controllers: + main: + pod: + containers: + main: + extraArgs: + - --port + - "{{ .Values.some_port }}" asserts: - equal: path: spec.template.spec.containers[0].args @@ -176,12 +241,17 @@ tests: - it: should pass with args and extraArgs set documentIndex: *deploymentDoc set: - args: - - --port - - 8000 - extraArgs: - - --photos - - /photos + controllers: + main: + pod: + containers: + main: + args: + - --port + - 8000 + extraArgs: + - --photos + - /photos asserts: - equal: path: spec.template.spec.containers[0].args @@ -196,12 +266,17 @@ tests: set: some_port: 9000 some_path: /photos - args: - - --port - - "{{ .Values.some_port }}" - extraArgs: - - --photos - - "{{ .Values.some_path }}" + controllers: + main: + pod: + containers: + main: + args: + - --port + - "{{ .Values.some_port }}" + extraArgs: + - --photos + - "{{ .Values.some_path }}" asserts: - equal: path: spec.template.spec.containers[0].args @@ -214,8 +289,13 @@ tests: - it: should pass with args and extraArgs set - single values documentIndex: *deploymentDoc set: - args: --path - extraArgs: /photos + controllers: + main: + pod: + containers: + main: + args: --path + extraArgs: /photos asserts: - equal: path: spec.template.spec.containers[0].args @@ -228,8 +308,13 @@ tests: set: some_arg: --path some_path: /photos - args: "{{ .Values.some_arg }}" - extraArgs: "{{ .Values.some_path }}" + controllers: + main: + pod: + containers: + main: + args: "{{ .Values.some_arg }}" + extraArgs: "{{ .Values.some_path }}" asserts: - equal: path: spec.template.spec.containers[0].args diff --git a/library/common-test/tests/container_in_deployment/env_from.yaml b/library/common-test/tests/container_in_deployment/env_from.yaml index 2cc21a8970..ee89c2f5a8 100644 --- a/library/common-test/tests/container_in_deployment/env_from.yaml +++ b/library/common-test/tests/container_in_deployment/env_from.yaml @@ -12,45 +12,70 @@ tests: - it: should fail with envFrom configMapRef has empty name set: - envFrom: - - configMapRef: - name: "" + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: "" asserts: - failedTemplate: errorMessage: Name is required for configMapRef in envFrom. - it: should fail with envFrom secretRef has empty name set: - envFrom: - - secretRef: - name: "" + controllers: + main: + pod: + containers: + main: + envFrom: + - secretRef: + name: "" asserts: - failedTemplate: errorMessage: Name is required for secretRef in envFrom. - it: should fail with envFrom secretRef has missing name set: - envFrom: - - secretRef: + controllers: + main: + pod: + containers: + main: + envFrom: + - secretRef: asserts: - failedTemplate: errorMessage: Not valid Ref or key is missing in envFrom. - it: should fail with envFrom configMapRef has missing name set: - envFrom: - - configMapRef: + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: asserts: - failedTemplate: errorMessage: Not valid Ref or key is missing in envFrom. - it: should fail with envFrom configMapRef and secretRef on the same item set: - envFrom: - - configMapRef: - name: something - secretRef: - name: something + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: something + secretRef: + name: something asserts: - failedTemplate: errorMessage: You can't define both secretRef and configMapRef on the same item. @@ -58,9 +83,14 @@ tests: - it: should pass with envFrom configMapRef entry added documentIndex: *deploymentDoc set: - envFrom: - - configMapRef: - name: some_name + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: some_name asserts: - equal: path: spec.template.spec.containers[0].envFrom @@ -73,11 +103,16 @@ tests: set: some_name: a_name some_name2: a_name2 - envFrom: - - configMapRef: - name: "{{ .Values.some_name }}" - - configMapRef: - name: "{{ .Values.some_name2 }}" + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: "{{ .Values.some_name }}" + - configMapRef: + name: "{{ .Values.some_name2 }}" asserts: - equal: path: spec.template.spec.containers[0].envFrom @@ -90,9 +125,14 @@ tests: - it: should pass with envFrom secretRef entry added documentIndex: *deploymentDoc set: - envFrom: - - secretRef: - name: some_name + controllers: + main: + pod: + containers: + main: + envFrom: + - secretRef: + name: some_name asserts: - equal: path: spec.template.spec.containers[0].envFrom @@ -105,11 +145,16 @@ tests: set: some_name: a_name some_name2: a_name2 - envFrom: - - secretRef: - name: "{{ .Values.some_name }}" - - secretRef: - name: "{{ .Values.some_name2 }}" + controllers: + main: + pod: + containers: + main: + envFrom: + - secretRef: + name: "{{ .Values.some_name }}" + - secretRef: + name: "{{ .Values.some_name2 }}" asserts: - equal: path: spec.template.spec.containers[0].envFrom @@ -124,11 +169,16 @@ tests: set: some_name: a_name some_name2: a_name2 - envFrom: - - secretRef: - name: "{{ .Values.some_name }}" - - configMapRef: - name: "{{ .Values.some_name2 }}" + controllers: + main: + pod: + containers: + main: + envFrom: + - secretRef: + name: "{{ .Values.some_name }}" + - configMapRef: + name: "{{ .Values.some_name2 }}" asserts: - equal: path: spec.template.spec.containers[0].envFrom diff --git a/library/common-test/tests/container_in_deployment/env_list.yaml b/library/common-test/tests/container_in_deployment/env_list.yaml index c0ce959888..af2c9b5164 100644 --- a/library/common-test/tests/container_in_deployment/env_list.yaml +++ b/library/common-test/tests/container_in_deployment/env_list.yaml @@ -12,56 +12,86 @@ tests: - it: should fail with envList missing name set: - envList: - - value: some_value + controllers: + main: + pod: + containers: + main: + envList: + - value: some_value asserts: - failedTemplate: errorMessage: Please specify both name and value for environment variable - it: should fail with envList missing value set: - envList: - - name: some_name + controllers: + main: + pod: + containers: + main: + envList: + - name: some_name asserts: - failedTemplate: errorMessage: Please specify both name and value for environment variable - it: should fail with envList name as a map set: - envList: - - name: - some_key: some_value - value: some_value + controllers: + main: + pod: + containers: + main: + envList: + - name: + some_key: some_value + value: some_value asserts: - failedTemplate: errorMessage: Name in envList cannot be a map or slice - it: should fail with envList name as a slice set: - envList: - - name: - - some_key: some_value - value: some_value + controllers: + main: + pod: + containers: + main: + envList: + - name: + - some_key: some_value + value: some_value asserts: - failedTemplate: errorMessage: Name in envList cannot be a map or slice - it: should fail with envList value as a map set: - envList: - - name: some_name - value: - some_key: some_value + controllers: + main: + pod: + containers: + main: + envList: + - name: some_name + value: + some_key: some_value asserts: - failedTemplate: errorMessage: Value in envList cannot be a map or slice - it: should fail with envList value as a slice set: - envList: - - name: some_name - value: - - some_key: some_value + controllers: + main: + pod: + containers: + main: + envList: + - name: some_name + value: + - some_key: some_value asserts: - failedTemplate: errorMessage: Value in envList cannot be a map or slice @@ -69,9 +99,14 @@ tests: - it: should pass with envList entry added documentIndex: *deploymentDoc set: - envList: - - name: some_name - value: some_value + controllers: + main: + pod: + containers: + main: + envList: + - name: some_name + value: some_value asserts: - equal: path: spec.template.spec.containers[0].env @@ -92,11 +127,16 @@ tests: - it: should pass with envList entries added documentIndex: *deploymentDoc set: - envList: - - name: some_name - value: some_value - - name: some_name2 - value: some_value2 + controllers: + main: + pod: + containers: + main: + envList: + - name: some_name + value: some_value + - name: some_name2 + value: some_value2 asserts: - equal: path: spec.template.spec.containers[0].env @@ -121,9 +161,14 @@ tests: set: some_name: a_name some_value: a_value - envList: - - name: "{{ .Values.some_name }}" - value: "{{ .Values.some_value }}" + controllers: + main: + pod: + containers: + main: + envList: + - name: "{{ .Values.some_name }}" + value: "{{ .Values.some_value }}" asserts: - equal: path: spec.template.spec.containers[0].env @@ -148,11 +193,16 @@ tests: some_value: a_value some_name2: a_name2 some_value2: a_value2 - envList: - - name: "{{ .Values.some_name }}" - value: "{{ .Values.some_value }}" - - name: "{{ .Values.some_name2 }}" - value: "{{ .Values.some_value2 }}" + controllers: + main: + pod: + containers: + main: + envList: + - name: "{{ .Values.some_name }}" + value: "{{ .Values.some_value }}" + - name: "{{ .Values.some_name2 }}" + value: "{{ .Values.some_value2 }}" asserts: - equal: path: spec.template.spec.containers[0].env diff --git a/library/common-test/tests/container_in_deployment/env_test.yaml b/library/common-test/tests/container_in_deployment/env_test.yaml index 34c2deafba..1a1cd4fec7 100644 --- a/library/common-test/tests/container_in_deployment/env_test.yaml +++ b/library/common-test/tests/container_in_deployment/env_test.yaml @@ -12,206 +12,291 @@ tests: - it: should fail with envs defined as a list set: - env: - - name: some_name - value: some_value + controllers: + main: + pod: + containers: + main: + env: + - name: some_name + value: some_value asserts: - failedTemplate: errorMessage: Environment Variables as a list is not supported. Use key-value format. - it: should fail with envs defined with an invalid keyRef set: - env: - ENVVAR: - invalidKeyRef: - name: blabla - key: blbla + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + invalidKeyRef: + name: blabla + key: blbla asserts: - failedTemplate: errorMessage: Not a valid valueFrom reference. Valid options are (configMapKeyRef and secretKeyRef) - it: should fail with envs defined without a name in configMapKeyRef set: - env: - ENVVAR: - configMapKeyRef: - key: some_key + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + configMapKeyRef: + key: some_key asserts: - failedTemplate: errorMessage: for the keyRef is not defined in (ENVVAR) - it: should fail with envs defined without a name in secretKeyRef set: - env: - ENVVAR: - secretKeyRef: - key: some_key + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + key: some_key asserts: - failedTemplate: errorMessage: for the keyRef is not defined in (ENVVAR) - it: should fail with envs defined without a key in configMapKeyRef set: - env: - ENVVAR: - configMapKeyRef: - name: some_name + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + configMapKeyRef: + name: some_name asserts: - failedTemplate: errorMessage: for the keyRef is not defined in (ENVVAR) - it: should fail with envs defined without a key in secretKeyRef set: - env: - ENVVAR: - secretKeyRef: - name: some_name + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + name: some_name asserts: - failedTemplate: errorMessage: for the keyRef is not defined in (ENVVAR) - it: should fail with envs defined with a non-bool in secretKeyRef set: - env: - ENVVAR: - secretKeyRef: - name: some_name - key: some_key - optional: non-bool + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + name: some_name + key: some_key + optional: non-bool asserts: - failedTemplate: errorMessage: in secretKeyRef must be a boolean on Environment Variable (ENVVAR) - it: should fail with envs defined with valueFrom key set: - env: - ENVVAR: - valueFrom: - secretKeyRef: - name: some_name - key: some_key - optional: non-bool + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + valueFrom: + secretKeyRef: + name: some_name + key: some_key + optional: non-bool asserts: - failedTemplate: errorMessage: Please remove and use directly configMapKeyRef or secretKeyRef - it: should fail with envs defined with optional in configMapKeyRef set: - env: - ENVVAR: - configMapKeyRef: - name: some_name - key: some_key - optional: non-bool + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + configMapKeyRef: + name: some_name + key: some_key + optional: non-bool asserts: - failedTemplate: errorMessage: is not supported in configMapRefKey - it: should fail with env trying to override fixedEnv set: - env: - TZ: something + controllers: + main: + pod: + containers: + main: + env: + TZ: something asserts: - failedTemplate: errorMessage: Environment Variable (TZ) on container (RELEASE-NAME-common-test) is set more than once. [to (UTC) on (fixedEnv)] and [to (something) on (env)] - it: should fail with env trying to override configmap set: - env: - ENVVAR: something + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: something + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' configmap: somename: enabled: true parseAsEnv: true content: ENVVAR: ABC - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (ENVVAR) on container (RELEASE-NAME-common-test) is set more than once. [to (something) on (env)] and [to (ABC) on (configmap-RELEASE-NAME-common-test-somename)] - it: should fail with env trying to override secret set: - env: - ENVVAR: something + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: something + envFrom: + - secretRef: + name: RELEASE-NAME-common-test-somename secret: somename: enabled: true parseAsEnv: true content: ENVVAR: ABC - envFrom: - - secretRef: - name: RELEASE-NAME-common-test-somename asserts: - failedTemplate: errorMessage: Environment Variable (ENVVAR) on container (RELEASE-NAME-common-test) is set more than once. [to (something) on (env)] and [to (ABC) on (secret-RELEASE-NAME-common-test-somename)] - it: should fail with env trying to override envList set: - env: - ENVVAR: something - envList: - - name: ENVVAR - value: ABC + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: something + envList: + - name: ENVVAR + value: ABC asserts: - failedTemplate: errorMessage: Environment Variable (ENVVAR) on container (RELEASE-NAME-common-test) is set more than once. [to (something) on (env)] and [to (ABC) on (envList)] - it: should fail with envList trying to override fixedEnv set: - envList: - - name: TZ - value: something + controllers: + main: + pod: + containers: + main: + envList: + - name: TZ + value: something asserts: - failedTemplate: errorMessage: Environment Variable (TZ) on container (RELEASE-NAME-common-test) is set more than once. [to (UTC) on (fixedEnv)] and [to (something) on (envList)] - it: should fail with envList trying to override env set: - env: - POSTGRES_HOST: postgres.svc.cluster.local - envList: - - name: POSTGRES_HOST - value: something + controllers: + main: + pod: + containers: + main: + env: + POSTGRES_HOST: postgres.svc.cluster.local + envList: + - name: POSTGRES_HOST + value: something asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (postgres.svc.cluster.local) on (env)] and [to (something) on (envList)] - it: should fail with envList trying to override configmap set: - envList: - - name: POSTGRES_HOST - value: something + controllers: + main: + pod: + containers: + main: + envList: + - name: POSTGRES_HOST + value: something + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' configmap: somename: enabled: true parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (something) on (envList)] and [to (something) on (configmap-RELEASE-NAME-common-test-somename)] - it: should fail with envList trying to override secret set: - envList: - - name: POSTGRES_HOST - value: something + controllers: + main: + pod: + containers: + main: + envList: + - name: POSTGRES_HOST + value: something + envFrom: + - secretRef: + name: RELEASE-NAME-common-test-somename secret: somename: enabled: true parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - secretRef: - name: RELEASE-NAME-common-test-somename asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (something) on (envList)] and [to (something) on (secret-RELEASE-NAME-common-test-somename)] @@ -224,44 +309,59 @@ tests: parseAsEnv: true content: TZ: something - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (TZ) on container (RELEASE-NAME-common-test) is set more than once. [to (UTC) on (fixedEnv)] and [to (something) on (configmap-RELEASE-NAME-common-test-somename)] - it: should fail with configmap trying to override env set: - env: - POSTGRES_HOST: postgres.svc.cluster.local + controllers: + main: + pod: + containers: + main: + env: + POSTGRES_HOST: postgres.svc.cluster.local + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' configmap: somename: enabled: true parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (postgres.svc.cluster.local) on (env)] and [to (something) on (configmap-RELEASE-NAME-common-test-somename)] - it: should fail with configmap trying to override envList set: - envList: - - name: POSTGRES_HOST - value: postgres.svc.cluster.local + controllers: + main: + pod: + containers: + main: + envList: + - name: POSTGRES_HOST + value: postgres.svc.cluster.local + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' configmap: somename: enabled: true parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (postgres.svc.cluster.local) on (envList)] and [to (something) on (configmap-RELEASE-NAME-common-test-somename)] @@ -280,11 +380,16 @@ tests: parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' - - secretRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' + - secretRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (something) on (configmap-RELEASE-NAME-common-test-somename)] and [to (something123) on (secret-RELEASE-NAME-common-test-somename)] @@ -297,44 +402,59 @@ tests: parseAsEnv: true content: TZ: something - envFrom: - - secretRef: - name: RELEASE-NAME-common-test-somename + controllers: + main: + pod: + containers: + main: + envFrom: + - secretRef: + name: RELEASE-NAME-common-test-somename asserts: - failedTemplate: errorMessage: Environment Variable (TZ) on container (RELEASE-NAME-common-test) is set more than once. [to (UTC) on (fixedEnv)] and [to (something) on (secret-RELEASE-NAME-common-test-somename)] - it: should fail with secret trying to override env set: - env: - POSTGRES_HOST: postgres.svc.cluster.local + controllers: + main: + pod: + containers: + main: + env: + POSTGRES_HOST: postgres.svc.cluster.local + envFrom: + - secretRef: + name: RELEASE-NAME-common-test-somename secret: somename: enabled: true parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - secretRef: - name: RELEASE-NAME-common-test-somename asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (postgres.svc.cluster.local) on (env)] and [to (something) on (secret-RELEASE-NAME-common-test-somename)] - it: should fail with secret trying to override envList set: - envList: - - name: POSTGRES_HOST - value: postgres.svc.cluster.local + controllers: + main: + pod: + containers: + main: + envList: + - name: POSTGRES_HOST + value: postgres.svc.cluster.local + envFrom: + - secretRef: + name: RELEASE-NAME-common-test-somename secret: somename: enabled: true parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - secretRef: - name: RELEASE-NAME-common-test-somename asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (postgres.svc.cluster.local) on (envList)] and [to (something) on (secret-RELEASE-NAME-common-test-somename)] @@ -353,11 +473,16 @@ tests: parseAsEnv: true content: POSTGRES_HOST: something - envFrom: - - configMapRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' - - secretRef: - name: '{{ include "ix.v1.common.names.fullname" . }}-somename' + controllers: + main: + pod: + containers: + main: + envFrom: + - configMapRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' + - secretRef: + name: '{{ include "ix.v1.common.names.fullname" . }}-somename' asserts: - failedTemplate: errorMessage: Environment Variable (POSTGRES_HOST) on container (RELEASE-NAME-common-test) is set more than once. [to (something123) on (configmap-RELEASE-NAME-common-test-somename)] and [to (something) on (secret-RELEASE-NAME-common-test-somename)] @@ -365,8 +490,13 @@ tests: - it: should pass with envs defined with int value documentIndex: *deploymentDoc set: - env: - ENVVAR: 123 + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: 123 asserts: - equal: path: spec.template.spec.containers[0].env @@ -387,8 +517,13 @@ tests: - it: should pass with envs defined with bool value documentIndex: *deploymentDoc set: - env: - ENVVAR: true + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: true asserts: - equal: path: spec.template.spec.containers[0].env @@ -409,8 +544,13 @@ tests: - it: should pass with envs defined with string value documentIndex: *deploymentDoc set: - env: - ENVVAR: "some_value" + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: "some_value" asserts: - equal: path: spec.template.spec.containers[0].env @@ -434,10 +574,15 @@ tests: some_string: a_string some_int: 123 some_bool: false - env: - ENVVAR: "{{ .Values.some_string }}" - ENVVAR2: "{{ .Values.some_int }}" - ENVVAR3: "{{ .Values.some_bool }}" + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: "{{ .Values.some_string }}" + ENVVAR2: "{{ .Values.some_int }}" + ENVVAR3: "{{ .Values.some_bool }}" asserts: - equal: path: spec.template.spec.containers[0].env @@ -462,11 +607,16 @@ tests: - it: should pass with envs defined with valueFrom configMapKeyRef documentIndex: *deploymentDoc set: - env: - ENVVAR: - configMapKeyRef: - name: some_name - key: some_key + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + configMapKeyRef: + name: some_name + key: some_key asserts: - equal: path: spec.template.spec.containers[0].env @@ -490,11 +640,16 @@ tests: - it: should pass with envs defined with valueFrom secretKeyRef documentIndex: *deploymentDoc set: - env: - ENVVAR: - secretKeyRef: - name: some_name - key: some_key + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + name: some_name + key: some_key asserts: - equal: path: spec.template.spec.containers[0].env @@ -520,11 +675,16 @@ tests: set: name: some_name key: some_key - env: - ENVVAR: - configMapKeyRef: - name: "{{ .Values.name }}" - key: "{{ .Values.key }}" + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + configMapKeyRef: + name: "{{ .Values.name }}" + key: "{{ .Values.key }}" asserts: - equal: path: spec.template.spec.containers[0].env @@ -550,11 +710,16 @@ tests: set: name: some_name key: some_key - env: - ENVVAR: - secretKeyRef: - name: "{{ .Values.name }}" - key: "{{ .Values.key }}" + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + name: "{{ .Values.name }}" + key: "{{ .Values.key }}" asserts: - equal: path: spec.template.spec.containers[0].env @@ -578,12 +743,17 @@ tests: - it: should pass with envs defined with valueFrom secretKeyRef with true documentIndex: *deploymentDoc set: - env: - ENVVAR: - secretKeyRef: - name: some_name - key: some_key - optional: true + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + name: some_name + key: some_key + optional: true asserts: - equal: path: spec.template.spec.containers[0].env @@ -608,12 +778,17 @@ tests: - it: should pass with envs defined with valueFrom secretKeyRef with false documentIndex: *deploymentDoc set: - env: - ENVVAR: - secretKeyRef: - name: some_name - key: some_key - optional: false + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + secretKeyRef: + name: some_name + key: some_key + optional: false asserts: - equal: path: spec.template.spec.containers[0].env @@ -644,20 +819,25 @@ tests: key2: some_key2 name3: some_name3 key3: some_key3 - env: - ENVVAR: - configMapKeyRef: - name: "{{ .Values.name }}" - key: "{{ .Values.key }}" - ENVVAR2: - secretKeyRef: - name: "{{ .Values.name2 }}" - key: "{{ .Values.key2 }}" - optional: false - ENVVAR3: - secretKeyRef: - name: "{{ .Values.name3 }}" - key: "{{ .Values.key3 }}" + controllers: + main: + pod: + containers: + main: + env: + ENVVAR: + configMapKeyRef: + name: "{{ .Values.name }}" + key: "{{ .Values.key }}" + ENVVAR2: + secretKeyRef: + name: "{{ .Values.name2 }}" + key: "{{ .Values.key2 }}" + optional: false + ENVVAR3: + secretKeyRef: + name: "{{ .Values.name3 }}" + key: "{{ .Values.key3 }}" asserts: - equal: path: spec.template.spec.containers[0].env diff --git a/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml b/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml index 37f36ede71..47684e8682 100644 --- a/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml +++ b/library/common-test/tests/container_in_deployment/fixedEnv_test.yaml @@ -13,7 +13,12 @@ tests: - it: should fail with empty PUID documentIndex: *deploymentDoc set: - PUID: + controllers: + main: + pod: + containers: + main: + PUID: asserts: - failedTemplate: errorMessage: key cannot be empty. Set a value or remove the key for the default (568) to take effect. @@ -21,7 +26,12 @@ tests: - it: should fail with PUID not-int documentIndex: *deploymentDoc set: - PUID: "1000" + controllers: + main: + pod: + containers: + main: + PUID: "1000" asserts: - failedTemplate: errorMessage: key has value of ("1000"). But must be an int. @@ -29,7 +39,12 @@ tests: - it: should fail with empty UMASK documentIndex: *deploymentDoc set: - UMASK: + controllers: + main: + pod: + containers: + main: + UMASK: asserts: - failedTemplate: errorMessage: key cannot be empty. Set a value or remove the key for the default (002) to take effect. @@ -37,7 +52,12 @@ tests: - it: should fail with UMASK not-string documentIndex: *deploymentDoc set: - UMASK: 2 + controllers: + main: + pod: + containers: + main: + UMASK: 2 asserts: - failedTemplate: errorMessage: key must be a string, so the format is kept intact. @@ -45,7 +65,12 @@ tests: - it: should pass with injectFixedEnvs false documentIndex: *deploymentDoc set: - injectFixedEnvs: false + controllers: + main: + pod: + containers: + main: + injectFixedEnvs: false asserts: - isNull: path: spec.template.spec.containers[0].env @@ -73,12 +98,17 @@ tests: - it: should pass with an env referencing TZ and PUID documentIndex: *deploymentDoc set: - securityContext: - runAsUser: 0 - runAsNonRoot: false - env: - TIMEZONE: "{{ .Values.TZ }}" - APP_USER_ID: "{{ .Values.security.PUID }}" + controllers: + main: + pod: + containers: + main: + securityContext: + runAsUser: 0 + runAsNonRoot: false + env: + TIMEZONE: "{{ .Values.TZ }}" + APP_USER_ID: "{{ .Values.PUID }}" asserts: - equal: path: spec.template.spec.containers[0].env @@ -113,9 +143,14 @@ tests: - it: should pass without S6_READ_ONLY_ROOT documentIndex: *deploymentDoc set: - securityContext: - readOnlyRootFilesystem: false - runAsNonRoot: false + controllers: + main: + pod: + containers: + main: + securityContext: + readOnlyRootFilesystem: false + runAsNonRoot: false asserts: - equal: path: spec.template.spec.containers[0].env @@ -152,9 +187,14 @@ tests: - it: should pass with envs changed because run as user root documentIndex: *deploymentDoc set: - securityContext: - runAsUser: 0 - runAsNonRoot: false + controllers: + main: + pod: + containers: + main: + securityContext: + runAsUser: 0 + runAsNonRoot: false asserts: - equal: path: spec.template.spec.containers[0].env @@ -185,9 +225,14 @@ tests: - it: should pass with envs changed because run as group root documentIndex: *deploymentDoc set: - securityContext: - runAsGroup: 0 - runAsNonRoot: false + controllers: + main: + pod: + containers: + main: + securityContext: + runAsGroup: 0 + runAsNonRoot: false asserts: - equal: path: spec.template.spec.containers[0].env @@ -218,10 +263,15 @@ tests: - it: should pass with envs changed because run as user root and PUID 0 documentIndex: *deploymentDoc set: - securityContext: - runAsUser: 0 - runAsNonRoot: false - PUID: 0 + controllers: + main: + pod: + containers: + main: + securityContext: + runAsUser: 0 + runAsNonRoot: false + PUID: 0 asserts: - equal: path: spec.template.spec.containers[0].env @@ -252,10 +302,15 @@ tests: - it: should pass with envs changed because run as group root and PUID 0 documentIndex: *deploymentDoc set: - securityContext: - runAsGroup: 0 - runAsNonRoot: false - PUID: 0 + controllers: + main: + pod: + containers: + main: + securityContext: + runAsGroup: 0 + runAsNonRoot: false + PUID: 0 asserts: - equal: path: spec.template.spec.containers[0].env @@ -286,12 +341,17 @@ tests: - it: should pass with envs changed because run as group root and fsGroup 0 and PUID 0 documentIndex: *deploymentDoc set: - podSecurityContext: - fsGroup: 0 - securityContext: - runAsGroup: 0 - runAsNonRoot: false - PUID: 0 + controllers: + main: + pod: + securityContext: + fsGroup: 0 + containers: + main: + securityContext: + runAsGroup: 0 + runAsNonRoot: false + PUID: 0 asserts: - equal: path: spec.template.spec.containers[0].env @@ -342,10 +402,15 @@ tests: - it: should fail with non-unique nvidiaCaps documentIndex: *deploymentDoc set: - nvidiaCaps: - - compute - - compute - - utility + controllers: + main: + pod: + containers: + main: + nvidiaCaps: + - compute + - compute + - utility asserts: - failedTemplate: errorMessage: ([compute compute utility]) are must have unique values only @@ -353,10 +418,15 @@ tests: - it: should fail with invalid nvidiaCaps value documentIndex: *deploymentDoc set: - nvidiaCaps: - - invalid - - compute - - utility + controllers: + main: + pod: + containers: + main: + nvidiaCaps: + - invalid + - compute + - utility asserts: - failedTemplate: errorMessage: Invalid options in (invalid). Valid options are compute, utility, all, graphics, video @@ -366,9 +436,14 @@ tests: set: scaleGPU: gpu.intel.com/i915: "1" - nvidiaCaps: - - compute - - utility + controllers: + main: + pod: + containers: + main: + nvidiaCaps: + - compute + - utility asserts: - equal: path: spec.template.spec.containers[0].env diff --git a/library/common-test/tests/container_in_deployment/image_test.yaml b/library/common-test/tests/container_in_deployment/image_test.yaml index d825cd9753..09cd5d21ec 100644 --- a/library/common-test/tests/container_in_deployment/image_test.yaml +++ b/library/common-test/tests/container_in_deployment/image_test.yaml @@ -66,7 +66,12 @@ tests: repository: some_repo tag: some_tag pullPolicy: invalid_policy - imageSelector: imageY + controllers: + main: + pod: + containers: + main: + imageSelector: imageY asserts: - failedTemplate: errorMessage: Selected image (imageY) does not exist in values @@ -77,7 +82,12 @@ tests: betaImage: repository: some_other_repo tag: some_other_tag - imageSelector: betaImage + controllers: + main: + pod: + containers: + main: + imageSelector: betaImage asserts: - equal: path: spec.template.spec.containers[0].image @@ -90,7 +100,12 @@ tests: repository: some_other_repo tag: some_other_tag pullPolicy: Never - imageSelector: betaImage + controllers: + main: + pod: + containers: + main: + imageSelector: betaImage asserts: - equal: path: spec.template.spec.containers[0].image @@ -104,7 +119,12 @@ tests: betaImage: repository: "" tag: some_other_tag - imageSelector: betaImage + controllers: + main: + pod: + containers: + main: + imageSelector: betaImage asserts: - failedTemplate: errorMessage: Image is required @@ -114,7 +134,12 @@ tests: betaImage: repository: some_other_repo tag: "" - imageSelector: betaImage + controllers: + main: + pod: + containers: + main: + imageSelector: betaImage asserts: - failedTemplate: errorMessage: Image is required diff --git a/library/common-test/tests/container_in_deployment/lifecycle_test.yaml b/library/common-test/tests/container_in_deployment/lifecycle_test.yaml index 56aef6d4d3..da81e593cc 100644 --- a/library/common-test/tests/container_in_deployment/lifecycle_test.yaml +++ b/library/common-test/tests/container_in_deployment/lifecycle_test.yaml @@ -14,9 +14,14 @@ tests: - it: should pass with single postStart lifecycle set documentIndex: *deploymentDoc set: - lifecycle: - postStart: - command: some_command + controllers: + main: + pod: + containers: + main: + lifecycle: + postStart: + command: some_command asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -30,9 +35,14 @@ tests: documentIndex: *deploymentDoc set: some_key: some_command - lifecycle: - postStart: - command: "{{ .Values.some_key }}" + controllers: + main: + pod: + containers: + main: + lifecycle: + postStart: + command: "{{ .Values.some_key }}" asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -45,11 +55,16 @@ tests: - it: should pass with postStart lifecycle set documentIndex: *deploymentDoc set: - lifecycle: - postStart: - command: - - /bin/bash - - test + controllers: + main: + pod: + containers: + main: + lifecycle: + postStart: + command: + - /bin/bash + - test asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -64,11 +79,16 @@ tests: documentIndex: *deploymentDoc set: some_key: some_value - lifecycle: - postStart: - command: - - /bin/bash - - "{{ .Values.some_key }}" + controllers: + main: + pod: + containers: + main: + lifecycle: + postStart: + command: + - /bin/bash + - "{{ .Values.some_key }}" asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -82,9 +102,14 @@ tests: - it: should pass with single preStop lifecycle set documentIndex: *deploymentDoc set: - lifecycle: - preStop: - command: some_command + controllers: + main: + pod: + containers: + main: + lifecycle: + preStop: + command: some_command asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -98,9 +123,14 @@ tests: documentIndex: *deploymentDoc set: some_key: some_command - lifecycle: - preStop: - command: "{{ .Values.some_key }}" + controllers: + main: + pod: + containers: + main: + lifecycle: + preStop: + command: "{{ .Values.some_key }}" asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -110,15 +140,19 @@ tests: command: - some_command - - it: should pass with preStop lifecycle set documentIndex: *deploymentDoc set: - lifecycle: - preStop: - command: - - /bin/bash - - test + controllers: + main: + pod: + containers: + main: + lifecycle: + preStop: + command: + - /bin/bash + - test asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -133,11 +167,16 @@ tests: documentIndex: *deploymentDoc set: some_key: some_value - lifecycle: - preStop: - command: - - /bin/bash - - "{{ .Values.some_key }}" + controllers: + main: + pod: + containers: + main: + lifecycle: + preStop: + command: + - /bin/bash + - "{{ .Values.some_key }}" asserts: - equal: path: spec.template.spec.containers[0].lifecycle @@ -150,45 +189,70 @@ tests: - it: should fail with invalid key set: - lifecycle: - preStart: - command: something + controllers: + main: + pod: + containers: + main: + lifecycle: + preStart: + command: something asserts: - failedTemplate: errorMessage: Invalid key (preStart) in lifecycle. Valid keys are preStop and postStart - it: should fail with no command in preStop set: - lifecycle: - preStop: - command: "" + controllers: + main: + pod: + containers: + main: + lifecycle: + preStop: + command: "" asserts: - failedTemplate: errorMessage: No commands were given for preStop lifecycle hook - it: should fail with no command in postStart set: - lifecycle: - postStart: - command: "" + controllers: + main: + pod: + containers: + main: + lifecycle: + postStart: + command: "" asserts: - failedTemplate: errorMessage: No commands were given for postStart lifecycle hook - it: should fail with no command in preStop set: - lifecycle: - preStop: - command: "" + controllers: + main: + pod: + containers: + main: + lifecycle: + preStop: + command: "" asserts: - failedTemplate: errorMessage: No commands were given for preStop lifecycle hook - it: should fail with no command in postStart set: - lifecycle: - postStart: - command: "" + controllers: + main: + pod: + containers: + main: + lifecycle: + postStart: + command: "" asserts: - failedTemplate: errorMessage: No commands were given for postStart lifecycle hook diff --git a/library/common-test/tests/container_in_deployment/port_test.yaml b/library/common-test/tests/container_in_deployment/port_test.yaml index 96308ce14b..a1607b25bf 100644 --- a/library/common-test/tests/container_in_deployment/port_test.yaml +++ b/library/common-test/tests/container_in_deployment/port_test.yaml @@ -143,13 +143,18 @@ tests: port: 443 protocol: UDP targetPort: 8000 - probes: - liveness: - enabled: false - readiness: - enabled: false - startup: - enabled: false + controllers: + main: + pod: + containers: + main: + probes: + liveness: + enabled: false + readiness: + enabled: false + startup: + enabled: false asserts: - equal: path: spec.template.spec.containers[0].ports[0] diff --git a/library/common-test/tests/container_in_deployment/probe_test.yaml b/library/common-test/tests/container_in_deployment/probe_test.yaml index 033f0e2ec7..7324492733 100644 --- a/library/common-test/tests/container_in_deployment/probe_test.yaml +++ b/library/common-test/tests/container_in_deployment/probe_test.yaml @@ -42,8 +42,13 @@ tests: - it: should fail with wrong probe name set: - probes: - invalid_probe_name: + controllers: + main: + pod: + containers: + main: + probes: + invalid_probe_name: asserts: - failedTemplate: errorMessage: Invalid probe name (invalid_probe_name) in (RELEASE-NAME-common-test) container. Valid options are (liveness, readiness, startup) @@ -53,27 +58,42 @@ tests: service: main: enabled: false - probes: - liveness: - type: auto + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: auto asserts: - failedTemplate: errorMessage: probe type in probe (liveness) in (RELEASE-NAME-common-test) container, is only supported for the main container and only if there is at least 1 port enabled - it: should fail with probe type set to UDP set: - probes: - liveness: - type: udp + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: udp asserts: - failedTemplate: errorMessage: Invalid probe type (udp) on probe (liveness) in (RELEASE-NAME-common-test) container. Valid types are tcp, http, https, grpc, exec, auto - it: should fail with probe type auto and port protocol UDP set: - probes: - liveness: - type: auto + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: auto service: main: ports: @@ -86,9 +106,14 @@ tests: - it: should fail without commands on exec probe set: - probes: - liveness: - type: exec + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: exec asserts: - failedTemplate: errorMessage: No commands were defined for type on probe (liveness) in (RELEASE-NAME-common-test) container. @@ -101,10 +126,15 @@ tests: ports: main: enabled: false - probes: - liveness: - path: "/" - type: http + controllers: + main: + pod: + containers: + main: + probes: + liveness: + path: "/" + type: http asserts: - failedTemplate: errorMessage: must be defined for / probe types in probe (liveness) in (RELEASE-NAME-common-test) container. @@ -117,11 +147,16 @@ tests: ports: main: enabled: false - probes: - liveness: - path: "/" - type: https - port: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + path: "/" + type: https + port: asserts: - failedTemplate: errorMessage: must be defined for / probe types in probe (liveness) in (RELEASE-NAME-common-test) container. @@ -134,95 +169,140 @@ tests: ports: main: enabled: false - probes: - liveness: - path: "/" - type: http - port: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + path: "/" + type: http + port: asserts: - failedTemplate: errorMessage: must be defined for / probe types in probe (liveness) in (RELEASE-NAME-common-test) container. - it: should fail without initialDelaySeconds on non-custom probes set: - probes: - liveness: - spec: - initialDelaySeconds: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + spec: + initialDelaySeconds: asserts: - failedTemplate: errorMessage: cannot be empty in probe (liveness) in (RELEASE-NAME-common-test) container - it: should fail without failureThreshold on non-custom probes set: - probes: - liveness: - spec: - failureThreshold: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + spec: + failureThreshold: asserts: - failedTemplate: errorMessage: cannot be empty in probe (liveness) in (RELEASE-NAME-common-test) container - it: should fail without timeoutSeconds on non-custom probes set: - probes: - liveness: - spec: - timeoutSeconds: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + spec: + timeoutSeconds: asserts: - failedTemplate: errorMessage: cannot be empty in probe (liveness) in (RELEASE-NAME-common-test) container - it: should fail without periodSeconds on non-custom probes set: - probes: - liveness: - spec: - periodSeconds: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + spec: + periodSeconds: asserts: - failedTemplate: errorMessage: cannot be empty in probe (liveness) in (RELEASE-NAME-common-test) container - it: should fail with invalid probe type set: - probes: - liveness: - type: not_valid_type + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: not_valid_type asserts: - failedTemplate: errorMessage: Invalid probe type (not_valid_type) on probe (liveness) in (RELEASE-NAME-common-test) container. Valid types are tcp, http, https, grpc, exec, auto - it: should fail with probe path not starting with / set: - probes: - liveness: - type: http - path: a/random/path + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + path: a/random/path asserts: - failedTemplate: errorMessage: Probe in container (RELEASE-NAME-common-test) with path (a/random/path), must start with a forward slash -> / <- - it: should fail with httpHeader value is defined as list set: - probes: - liveness: - type: http - httpHeaders: - some_header: - - list_value - - list_value2 + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + httpHeaders: + some_header: + - list_value + - list_value2 asserts: - failedTemplate: errorMessage: Lists or Dicts are not allowed in httpHeaders on probe (liveness) - it: should fail with httpHeader value is defined as dict set: - probes: - liveness: - type: http - httpHeaders: - some_header: - some_key: + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + httpHeaders: + some_header: + some_key: asserts: - failedTemplate: errorMessage: Lists or Dicts are not allowed in httpHeaders on probe (liveness) @@ -230,10 +310,15 @@ tests: - it: should fail without spec in custom defined probe documentIndex: *deploymentDoc set: - probes: - liveness: - type: custom - spec: {} + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: custom + spec: {} asserts: - failedTemplate: errorMessage: must be defined for probe types in probe (liveness) in (RELEASE-NAME-common-test) container. @@ -241,18 +326,23 @@ tests: - it: should pass with with custom defined liveness probe documentIndex: *deploymentDoc set: - probes: - liveness: - type: custom - spec: - httpGet: - path: /path - scheme: HTTPS - port: 1234 - initialDelaySeconds: 15 - failureThreshold: 10 - timeoutSeconds: 10 - periodSeconds: 15 + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: custom + spec: + httpGet: + path: /path + scheme: HTTPS + port: 1234 + initialDelaySeconds: 15 + failureThreshold: 10 + timeoutSeconds: 10 + periodSeconds: 15 asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -269,18 +359,23 @@ tests: - it: should pass with with custom defined readiness probe documentIndex: *deploymentDoc set: - probes: - readiness: - type: custom - spec: - httpGet: - path: /path - scheme: HTTPS - port: 1234 - initialDelaySeconds: 15 - failureThreshold: 10 - timeoutSeconds: 10 - periodSeconds: 15 + controllers: + main: + pod: + containers: + main: + probes: + readiness: + type: custom + spec: + httpGet: + path: /path + scheme: HTTPS + port: 1234 + initialDelaySeconds: 15 + failureThreshold: 10 + timeoutSeconds: 10 + periodSeconds: 15 asserts: - equal: path: spec.template.spec.containers[0].readinessProbe @@ -297,18 +392,23 @@ tests: - it: should pass with with custom defined startup probe documentIndex: *deploymentDoc set: - probes: - startup: - type: custom - spec: - httpGet: - path: /path - scheme: HTTPS - port: 1234 - initialDelaySeconds: 15 - failureThreshold: 10 - timeoutSeconds: 10 - periodSeconds: 15 + controllers: + main: + pod: + containers: + main: + probes: + startup: + type: custom + spec: + httpGet: + path: /path + scheme: HTTPS + port: 1234 + initialDelaySeconds: 15 + failureThreshold: 10 + timeoutSeconds: 10 + periodSeconds: 15 asserts: - equal: path: spec.template.spec.containers[0].startupProbe @@ -346,9 +446,14 @@ tests: - it: should pass with with probe type TCP and service TCP documentIndex: *deploymentDoc set: - probes: - liveness: - type: tcp + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: tcp asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -368,11 +473,16 @@ tests: ports: main: enabled: false - probes: - liveness: - path: "/" - type: tcp - port: "" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + path: "/" + type: tcp + port: "" asserts: - failedTemplate: errorMessage: must be defined for probe types in probe (liveness) in (RELEASE-NAME-common-test) container. @@ -385,9 +495,14 @@ tests: ports: main: protocol: HTTP - probes: - liveness: - path: /some_path + controllers: + main: + pod: + containers: + main: + probes: + liveness: + path: /some_path asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -409,9 +524,14 @@ tests: ports: main: protocol: HTTP - probes: - liveness: - port: 1234 + controllers: + main: + pod: + containers: + main: + probes: + liveness: + port: 1234 asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -433,10 +553,15 @@ tests: ports: main: protocol: HTTP - probes: - liveness: - httpHeaders: - some_header: 1234 + controllers: + main: + pod: + containers: + main: + probes: + liveness: + httpHeaders: + some_header: 1234 asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -457,11 +582,16 @@ tests: documentIndex: *deploymentDoc set: some_header_value: 1234 - probes: - liveness: - type: http - httpHeaders: - some_header: "{{ .Values.some_header_value }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + httpHeaders: + some_header: "{{ .Values.some_header_value }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -483,12 +613,17 @@ tests: set: some_header_value: 1234 some_header_value2: some_value - probes: - liveness: - type: http - httpHeaders: - some_header: "{{ .Values.some_header_value }}" - some_header2: "{{ .Values.some_header_value2 }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + httpHeaders: + some_header: "{{ .Values.some_header_value }}" + some_header2: "{{ .Values.some_header_value2 }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -511,10 +646,15 @@ tests: documentIndex: *deploymentDoc set: some_path: /ping - probes: - liveness: - type: http - path: "{{ .Values.some_path }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + path: "{{ .Values.some_path }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -532,10 +672,15 @@ tests: documentIndex: *deploymentDoc set: some_port: 1234 - probes: - liveness: - type: http - port: "{{ .Values.some_port }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: http + port: "{{ .Values.some_port }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -553,10 +698,15 @@ tests: documentIndex: *deploymentDoc set: some_port: 1234 - probes: - liveness: - type: tcp - port: "{{ .Values.some_port }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: tcp + port: "{{ .Values.some_port }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -571,14 +721,19 @@ tests: - it: should pass with with changed times documentIndex: *deploymentDoc set: - probes: - liveness: - type: tcp - spec: - initialDelaySeconds: 15 - failureThreshold: 10 - timeoutSeconds: 10 - periodSeconds: 15 + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: tcp + spec: + initialDelaySeconds: 15 + failureThreshold: 10 + timeoutSeconds: 10 + periodSeconds: 15 asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -593,9 +748,14 @@ tests: - it: should pass with with probe type GRPC documentIndex: *deploymentDoc set: - probes: - liveness: - type: grpc + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: grpc asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -615,11 +775,16 @@ tests: ports: main: enabled: false - probes: - liveness: - path: "/" - type: grpc - port: "" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + path: "/" + type: grpc + port: "" asserts: - failedTemplate: errorMessage: must be defined for probe types in probe (liveness) in (RELEASE-NAME-common-test) container. @@ -627,14 +792,19 @@ tests: - it: should pass with with probe type exec with multiline command documentIndex: *deploymentDoc set: - probes: - liveness: - type: exec - command: - - /bin/bash - - -c - - | - echo "probe!" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: exec + command: + - /bin/bash + - -c + - | + echo "probe!" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -654,14 +824,19 @@ tests: documentIndex: *deploymentDoc set: some_msg: probe! - probes: - liveness: - type: exec - command: - - /bin/bash - - -c - - | - echo "{{ .Values.some_msg }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: exec + command: + - /bin/bash + - -c + - | + echo "{{ .Values.some_msg }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -680,10 +855,15 @@ tests: - it: should pass with with probe type exec single command documentIndex: *deploymentDoc set: - probes: - liveness: - type: exec - command: env + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: exec + command: env asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -700,10 +880,15 @@ tests: documentIndex: *deploymentDoc set: some_command: env - probes: - liveness: - type: exec - command: "{{ .Values.some_command }}" + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: exec + command: "{{ .Values.some_command }}" asserts: - equal: path: spec.template.spec.containers[0].livenessProbe @@ -719,15 +904,20 @@ tests: - it: should pass with with probe type exec single command and custom timings documentIndex: *deploymentDoc set: - probes: - liveness: - type: exec - command: env - spec: - initialDelaySeconds: 15 - failureThreshold: 10 - timeoutSeconds: 10 - periodSeconds: 15 + controllers: + main: + pod: + containers: + main: + probes: + liveness: + type: exec + command: env + spec: + initialDelaySeconds: 15 + failureThreshold: 10 + timeoutSeconds: 10 + periodSeconds: 15 asserts: - equal: path: spec.template.spec.containers[0].livenessProbe diff --git a/library/common/1.0.0/templates/class/_service.tpl b/library/common/1.0.0/templates/class/_service.tpl index f0bd77ef1b..62dfcb1213 100644 --- a/library/common/1.0.0/templates/class/_service.tpl +++ b/library/common/1.0.0/templates/class/_service.tpl @@ -34,10 +34,10 @@ metadata: {{- . | nindent 4 }} {{- end -}} {{- $additionalAnnotations := dict -}} - {{- if and $root.Values.addAnnotations.traefik (eq ($primaryPort.protocol | default "") "HTTPS") -}} + {{- if and $root.Values.globalDefaults.addAnnotations.traefik (eq ($primaryPort.protocol | default "") "HTTPS") -}} {{- $_ := set $additionalAnnotations "traefik.ingress.kubernetes.io/service.serversscheme" "https" -}} {{- end -}} - {{- if and $root.Values.addAnnotations.metallb (eq $svcType "LoadBalancer") -}} + {{- if and $root.Values.globalDefaults.addAnnotations.metallb (eq $svcType "LoadBalancer") -}} {{- $sharedLBKey := include "ix.v1.common.names.fullname" $root -}} {{- with $svcValues.metalLBSharedKey -}} {{- $sharedLBKey = tpl . $root -}} diff --git a/library/common/1.0.0/templates/lib/container/_probes.tpl b/library/common/1.0.0/templates/lib/container/_probes.tpl index 3ee3a8c6a0..b6ea7e3ba5 100644 --- a/library/common/1.0.0/templates/lib/container/_probes.tpl +++ b/library/common/1.0.0/templates/lib/container/_probes.tpl @@ -37,7 +37,6 @@ {{- if $probe.type -}} {{- $probeType = $probe.type -}} {{- end -}} - {{- if and (or (not $services) (not $primaryPort)) (eq $probeType "auto") -}} {{- fail (printf " probe type in probe (%s) in (%s) container, is only supported for the main container and only if there is at least 1 port enabled" $probeName $containerName) -}} {{- 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 d806e7cb3b..1f36525f25 100644 --- a/library/common/1.0.0/templates/lib/container/_security.tpl +++ b/library/common/1.0.0/templates/lib/container/_security.tpl @@ -23,7 +23,7 @@ The reason is not splitted, is that on one of the places needs a combo of all va {{- 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 -}} + {{- $returnValue = mustMergeOverwrite $returnValue $root.Values.controllers.main.pod.containers.main.securityContext -}} {{- end -}} {{- end -}} @@ -214,12 +214,11 @@ The reason is not splitted, is that on one of the places needs a combo of all va {{- $secEnvs := .secEnvs -}} {{/* Initialiaze Values */}} - {{- $defaultSecEnvs := (dict "PUID" $root.Values.PUID "UMASK" $root.Values.UMASK ) -}} + {{- $defaultSecEnvs := (dict "PUID" $root.Values.PUID "UMASK" $root.Values.UMASK) -}} {{- $returnValue := (mustDeepCopy $defaultSecEnvs) -}} {{/* Overwrite from values that user/dev passed */}} {{- $returnValue = mustMergeOverwrite $returnValue $secEnvs -}} - {{/* Validate values, as mergeOverwrite also passes null values */}} {{- if not $returnValue.UMASK -}} {{- fail (printf " key cannot be empty. Set a value or remove the key for the default (%v) to take effect." $defaultSecEnvs.UMASK) -}} diff --git a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl index 69d14e2d88..289a9b32a3 100644 --- a/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl +++ b/library/common/1.0.0/templates/lib/container/_volumeMounts.tpl @@ -4,7 +4,7 @@ {{- $root := .root -}} {{- $extraContainerVolMounts := .extraContainerVolMounts -}} - {{- if (mustHas $root.Values.controller.type (list "Job" "CronJob")) -}} + {{- if (mustHas $root.Values.controllers.main.type (list "Job" "CronJob")) -}} {{- $isMainContainer = true -}} {{- end -}} @@ -19,7 +19,7 @@ {{- end -}} {{- end -}} - {{- if eq $root.Values.controller.type "StatefulSet" -}} + {{- if eq $root.Values.controllers.main.type "StatefulSet" -}} {{- range $index, $vct := $root.Values.volumeClaimTemplates -}} {{- include "ix.v1.common.container.volumeMount" (dict "root" $root "item" $vct diff --git a/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl b/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl index d4c93e7532..5a6fbb8685 100644 --- a/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl +++ b/library/common/1.0.0/templates/lib/container/env/_fixedEnvs.tpl @@ -29,7 +29,7 @@ {{- end -}} {{- end -}} - {{- $podSecCont := $root.Values.podSecurityContext -}} + {{- $podSecCont := $root.Values.controllers.main.pod.securityContext -}} {{/* Calculate all security values */}} {{- $securityContext := (include "ix.v1.common.lib.securityContext" (dict "root" $root diff --git a/library/common/1.0.0/templates/lib/general/_names.tpl b/library/common/1.0.0/templates/lib/general/_names.tpl index a32aaa7998..3e755bea67 100644 --- a/library/common/1.0.0/templates/lib/general/_names.tpl +++ b/library/common/1.0.0/templates/lib/general/_names.tpl @@ -14,7 +14,7 @@ nameOverride applies only to the current chart {{- end -}} {{/* Order of preference: global.nameOverride -> nameOverride -> Chart.Name */}} - {{- ($globalNameOverride | default .Values.nameOverride) | default .Chart.Name | trunc 63 | trimSuffix "-" -}} + {{- ($globalNameOverride | default .Values.controllers.main.pod.nameOverride) | default .Chart.Name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{/* Create a default fully qualified app name. */}} @@ -26,8 +26,8 @@ nameOverride applies only to the current chart {{- $globalFullNameOverride = (.Values.global.fullnameOverride | default $globalFullNameOverride) -}} {{- end -}} - {{- if or .Values.fullnameOverride $globalFullNameOverride -}} - {{- $name = $globalFullNameOverride | default .Values.fullnameOverride -}} + {{- if or .Values.controllers.main.pod.fullnameOverride $globalFullNameOverride -}} + {{- $name = $globalFullNameOverride | default .Values.controllers.main.pod.fullnameOverride -}} {{- else -}} {{- if contains $name .Release.Name -}} {{- $name = .Release.Name -}} @@ -56,14 +56,14 @@ nameOverride applies only to the current chart {{/* Return the properly cased version of the controller type */}} {{- define "ix.v1.common.names.controllerType" -}} - {{- if eq .Values.controller.type "deployment" -}} + {{- if eq .Values.controllers.main.type "deployment" -}} {{- print "Deployment" -}} - {{- else if eq .Values.controller.type "daemonset" -}} + {{- else if eq .Values.controllers.main.type "daemonset" -}} {{- print "DaemonSet" -}} - {{- else if eq .Values.controller.type "statefulset" -}} + {{- else if eq .Values.controllers.main.type "statefulset" -}} {{- print "StatefulSet" -}} {{- else -}} - {{- fail (printf "Not a valid controller.type (%s)" .Values.controller.type) -}} + {{- fail (printf "Not a valid controller.type (%s)" .Values.controllers.main.type) -}} {{- end -}} {{- end -}} @@ -302,7 +302,7 @@ nameOverride applies only to the current chart {{- if and (hasKey $jobValues "nameOverride") $jobValues.nameOverride -}} {{- if not (eq $jobValues.nameOverride "-") -}} - {{- if (mustHas $root.Values.controller.type (list "Job" "CronJob")) -}} + {{- if (mustHas $root.Values.controllers.main.type (list "Job" "CronJob")) -}} {{- $jobName = $jobValues.nameOverride -}} {{- else -}} {{- $jobName = printf "%v-%v" $jobName $jobValues.nameOverride -}} diff --git a/library/common/1.0.0/templates/lib/job/_jobPod.tpl b/library/common/1.0.0/templates/lib/job/_jobPod.tpl index a3360da87f..2a0b9401eb 100644 --- a/library/common/1.0.0/templates/lib/job/_jobPod.tpl +++ b/library/common/1.0.0/templates/lib/job/_jobPod.tpl @@ -19,7 +19,7 @@ {{- $schedulerName := "" -}} {{- with $values.schedulerName -}} {{- if eq . $inherit -}} - {{- $schedulerName = (tpl $root.Values.schedulerName $root) -}} + {{- $schedulerName = (tpl $root.Values.controllers.main.pod.schedulerName $root) -}} {{- else -}} {{- $schedulerName = . -}} {{- end -}} @@ -30,7 +30,7 @@ {{- $priorityClassName := "" -}} {{- with $values.priorityClassName -}} {{- if eq . $inherit -}} - {{- $priorityClassName = (tpl $root.Values.priorityClassName $root) -}} + {{- $priorityClassName = (tpl $root.Values.controllers.main.pod.priorityClassName $root) -}} {{- else -}} {{- $priorityClassName = . -}} {{- end -}} @@ -41,7 +41,7 @@ {{- $hostname := "" -}} {{- with $values.hostname -}} {{- if eq . $inherit -}} - {{- $hostname = (tpl $root.Values.hostname $root) -}} + {{- $hostname = (tpl $root.Values.controllers.main.pod.hostname $root) -}} {{- else -}} {{- $hostname = . -}} {{- end -}} @@ -52,11 +52,11 @@ {{- $dnsPolicy := "" -}} {{- with $values.dnsPolicy -}} {{- if eq . $inherit -}} - {{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $root.Values.dnsPolicy "hostNetwork" $root.Values.hostNetwork "root" $root) | trim ) -}} + {{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $root.Values.controllers.main.pod.dnsPolicy "hostNetwork" $root.Values.controllers.main.pod.hostNetwork "root" $root) | trim ) -}} {{- $dnsPolicy = . -}} {{- end -}} {{- else -}} - {{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $values.dnsPolicy "hostNetwork" ($values.hostNetwork | default $root.Values.hostNetwork) "root" $root) | trim ) -}} + {{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $values.dnsPolicy "hostNetwork" ($values.hostNetwork | default false) "root" $root) | trim ) -}} {{- $dnsPolicy = . -}} {{- end -}} {{- end -}} @@ -67,11 +67,11 @@ {{- $dnsConfig := dict -}} {{- with $values.dnsConfig -}} {{- if eq (toString .) $inherit -}} - {{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" $root.Values.dnsPolicy "dnsConfig" $root.Values.dnsConfig "root" $root) | trim ) -}} + {{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" $root.Values.controllers.main.pod.dnsPolicy "dnsConfig" $root.Values.controllers.main.pod.dnsConfig "root" $root) | trim ) -}} {{- $dnsConfig = . -}} {{- end -}} {{- else -}} - {{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" ($dnsPolicy | default $root.Values.dnsPolicy) "dnsConfig" $values.dnsConfig "root" $root) | trim ) -}} + {{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" ($dnsPolicy | default $root.Values.controllers.main.pod.dnsPolicy) "dnsConfig" $values.dnsConfig "root" $root) | trim ) -}} {{- $dnsConfig = . -}} {{- end -}} {{- end -}} @@ -82,7 +82,7 @@ {{- $hostAliases := dict -}} {{- with $values.hostAliases -}} {{- if eq (toString .) $inherit -}} - {{- with (include "ix.v1.common.hostAliases" (dict "hostAliases" $root.Values.hostAliases "root" $root) | trim) -}} + {{- with (include "ix.v1.common.hostAliases" (dict "hostAliases" $root.Values.controllers.main.pod.hostAliases "root" $root) | trim) -}} {{- $hostAliases = . -}} {{- end -}} {{- else -}} @@ -97,7 +97,7 @@ {{- $nodeSelector := "" -}} {{- with $values.nodeSelector -}} {{- if eq (toString .) $inherit -}} - {{- with (include "ix.v1.common.nodeSelector" (dict "nodeSelector" $root.Values.nodeSelector "root" $root) | trim) -}} + {{- with (include "ix.v1.common.nodeSelector" (dict "nodeSelector" $root.Values.controllers.main.pod.nodeSelector "root" $root) | trim) -}} {{- $nodeSelector = . -}} {{- end -}} {{- else -}} @@ -112,7 +112,7 @@ {{- $tolerations := dict -}} {{- with $values.tolerations -}} {{- if eq (toString .) $inherit -}} - {{- with (include "ix.v1.common.tolerations" (dict "tolerations" $root.Values.tolerations "root" $root) | trim) -}} + {{- with (include "ix.v1.common.tolerations" (dict "tolerations" $root.Values.controllers.main.pod.tolerations "root" $root) | trim) -}} {{- $tolerations = . -}} {{- end -}} {{- else -}} @@ -142,14 +142,14 @@ {{- $runtimeClassName := "" -}} {{- with $values.runtimeClassName -}} {{- if eq . $inherit -}} - {{- with (include "ix.v1.common.runtimeClassName" (dict "root" $root "runtime" $root.Values.runtimeClassName) | trim) -}} + {{- with (include "ix.v1.common.runtimeClassName" (dict "root" $root "runtime" $root.Values.controllers.main.pod.runtimeClassName) | trim) -}} {{- $runtimeClassName = . -}} {{- end -}} {{- else -}} {{- $runtimeClassName = . -}} {{- end -}} {{- else -}} - {{- with (include "ix.v1.common.runtimeClassName" (dict "root" $root "runtime" $root.Values.runtimeClassName "isJob" true) | trim) -}} + {{- with (include "ix.v1.common.runtimeClassName" (dict "root" $root "runtime" $root.Values.controllers.main.pod.runtimeClassName "isJob" true) | trim) -}} {{- $runtimeClassName = . -}} {{- end -}} {{- end -}} @@ -157,7 +157,7 @@ {{- $termSeconds := "" -}} {{- with $values.terminationGracePeriodSeconds -}} {{- if eq (toString .) $inherit -}} - {{- with $root.Values.terminationGracePeriodSeconds -}} + {{- with $root.Values.controllers.main.pod.terminationGracePeriodSeconds -}} {{- $termSeconds = . -}} {{- end -}} {{- else -}} @@ -172,7 +172,7 @@ {{- $secCont := dict -}} {{- with $values.podSecurityContext -}} {{- if eq (toString .) $inherit -}} {{/* If inherti is set, use the main podSecCont */}} - {{- with (include "ix.v1.common.container.podSecurityContext" (dict "podSecCont" $root.Values.podSecurityContext "root" $root "isJob" true) | trim) -}} + {{- with (include "ix.v1.common.container.podSecurityContext" (dict "podSecCont" $root.Values.controllers.main.pod.securityContext "root" $root "isJob" true) | trim) -}} {{- $secCont = . -}} {{- end -}} {{- else -}} {{/* Otherwise use the job's podpodSecCont values */}} @@ -189,7 +189,7 @@ {{/* Now render the actual values */}} {{- if hasKey $values "hostNetwork" -}} {{- if eq (toString $values.hostNetwork) $inherit }} -hostNetwork: {{ $root.Values.hostNetwork }} +hostNetwork: {{ $root.Values.controllers.main.pod.hostNetwork }} {{- else if (kindIs "bool" $values.hostNetwork) }} hostNetwork: {{ $values.hostNetwork }} {{- end -}} @@ -199,7 +199,7 @@ hostNetwork: false {{- if hasKey $values "enableServiceLinks" -}} {{- if eq (toString $values.enableServiceLinks) $inherit }} -enableServiceLinks: {{ $root.Values.enableServiceLinks }} +enableServiceLinks: {{ $root.Values.controllers.main.pod.enableServiceLinks }} {{- else if (kindIs "bool" $values.enableServiceLinks) }} enableServiceLinks: {{ $values.enableServiceLinks }} {{- end -}} diff --git a/library/common/1.0.0/templates/lib/job/_jobTemplate.tpl b/library/common/1.0.0/templates/lib/job/_jobTemplate.tpl index ad5c1c2139..b9ab318a4d 100644 --- a/library/common/1.0.0/templates/lib/job/_jobTemplate.tpl +++ b/library/common/1.0.0/templates/lib/job/_jobTemplate.tpl @@ -4,7 +4,7 @@ {{- $job := .job -}} {{- $default := $root.Values.globalDefaults.job -}} - {{- $controllerType := $root.Values.controller.type -}} + {{- $controllerType := $root.Values.controllers.main.type -}} {{- include "ix.v1.common.validate.job" (dict "root" $root "job" $job) -}} 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 9a8df6590b..ed91a78c26 100644 --- a/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl +++ b/library/common/1.0.0/templates/lib/pod/_extraContainers.tpl @@ -53,14 +53,21 @@ args: {{- . | nindent 4 }} {{- end -}} + {{- $secEnvs := dict -}} + {{- if hasKey $container "PUID" -}} + {{- $_ := set $secEnvs "PUID" $container.PUID -}} + {{- end -}} + {{- if hasKey $container "UMASK" -}} + {{- $_ := set $secEnvs "UMASK" $container.UMASK -}} + {{- end -}} {{- with (include "ix.v1.common.container.envVars" (dict "envs" $container.env "envList" $container.envList "containerName" $name "isMainContainer" false - "scaleGPU" $container.scaleGPU + "scaleGPU" $root.Values.scaleGPU "nvidiaCaps" $container.nvidiaCaps "secCont" $container.securityContext - "secEnvs" (dict "PUID" $container.PUID "UMASK" $container.UMASK) + "secEnvs" $secEnvs "injectFixedEnvs" $container.injectFixedEnvs "root" $root) | trim) }} env: 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 6b83a09f51..ea0ef7cf98 100644 --- a/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl +++ b/library/common/1.0.0/templates/lib/pod/_mainContainer.tpl @@ -40,14 +40,21 @@ So it can work on multiple places, like additional containers and not only the m {{- with (include "ix.v1.common.container.termination.messagePolicy" (dict "msgPolicy" $values.termination.messagePolicy "root" $root)) | trim }} terminationMessagePolicy: {{ . }} {{- end -}} + {{- $secEnvs := dict -}} + {{- if hasKey $values "PUID" -}} + {{- $_ := set $secEnvs "PUID" $values.PUID -}} + {{- end -}} + {{- if hasKey $values "UMASK" -}} + {{- $_ := set $secEnvs "UMASK" $values.UMASK -}} + {{- end -}} {{- with (include "ix.v1.common.container.envVars" (dict "envs" $values.env "envList" $values.envList "containerName" $name "isMainContainer" true - "scaleGPU" $values.scaleGPU + "scaleGPU" $root.Values.scaleGPU "nvidiaCaps" $values.nvidiaCaps "secCont" $values.securityContext - "secEnvs" (dict "PUID" $values.PUID "UMASK" $values.UMASK) + "secEnvs" $secEnvs "injectFixedEnvs" $values.injectFixedEnvs "root" $root) | trim) }} env: @@ -57,7 +64,7 @@ So it can work on multiple places, like additional containers and not only the m envFrom: {{- . | nindent 4 }} {{- end -}} - {{- with (include "ix.v1.common.container.ports" (dict "services" $values.service "root" $root) | trim) }} + {{- with (include "ix.v1.common.container.ports" (dict "services" $root.Values.service "root" $root) | trim) }} ports: {{- . | nindent 4 }} {{- end -}} @@ -67,14 +74,14 @@ So it can work on multiple places, like additional containers and not only the m {{- . | nindent 4 }} {{- end -}} {{- with (include "ix.v1.common.container.probes" (dict "probes" $values.probes - "services" $values.service + "services" $root.Values.service "containerName" $name "isMainContainer" true "root" $root) | trim) }} {{- . | nindent 2 }} {{- end -}} {{- with (include "ix.v1.common.container.resources" (dict "resources" $values.resources - "gpu" $values.scaleGPU + "gpu" $root.Values.scaleGPU "isMainContainer" true "root" $root) | trim) }} resources: 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 fd2fbe4700..8fd231e86d 100644 --- a/library/common/1.0.0/templates/lib/pod/_pod.tpl +++ b/library/common/1.0.0/templates/lib/pod/_pod.tpl @@ -3,44 +3,44 @@ {{- $root := . }} {{- $values := fromYaml (tpl ($.Values | toYaml) $) }} serviceAccountName: {{ (include "ix.v1.common.names.serviceAccountName" $root) }} -hostNetwork: {{ $values.hostNetwork }} -enableServiceLinks: {{ $values.enableServiceLinks }} +hostNetwork: {{ $values.controllers.main.pod.hostNetwork }} +enableServiceLinks: {{ $values.controllers.main.pod.enableServiceLinks }} {{- with (include "ix.v1.common.restartPolicy" (dict "restartPolicy" $values.restartPolicy "root" $root) | trim) }} restartPolicy: {{ . }} {{- end -}} -{{- with $values.schedulerName }} +{{- with $values.controllers.main.pod.schedulerName }} schedulerName: {{ . }} {{- end -}} -{{- with $values.priorityClassName }} +{{- with $values.controllers.main.pod.priorityClassName }} priorityClassName: {{ . }} {{- end }} -{{- with $values.hostname }} +{{- with $values.controllers.main.pod.hostname }} hostname: {{ . }} {{- end -}} -{{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $values.dnsPolicy "hostNetwork" $values.hostNetwork "root" $root) | trim ) }} +{{- with (include "ix.v1.common.dnsPolicy" (dict "dnsPolicy" $values.controllers.main.pod.dnsPolicy "hostNetwork" $values.controllers.main.pod.hostNetwork "root" $root) | trim ) }} dnsPolicy: {{ . }} {{- end -}} -{{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" $values.dnsPolicy "dnsConfig" $values.dnsConfig "root" $root) | trim ) }} +{{- with (include "ix.v1.common.dnsConfig" (dict "dnsPolicy" $values.controllers.main.pod.dnsPolicy "dnsConfig" $values.controllers.main.pod.dnsConfig "root" $root) | trim ) }} dnsConfig: {{- . | nindent 2 }} {{- end -}} -{{- with (include "ix.v1.common.hostAliases" (dict "hostAliases" $values.hostAliases "root" $root) | trim) }} +{{- with (include "ix.v1.common.hostAliases" (dict "hostAliases" $values.controllers.main.pod.hostAliases "root" $root) | trim) }} hostAliases: {{- . | nindent 2 }} {{- end -}} -{{- with (include "ix.v1.common.nodeSelector" (dict "nodeSelector" $values.nodeSelector "root" $root) | trim) }} +{{- with (include "ix.v1.common.nodeSelector" (dict "nodeSelector" $values.controllers.main.pod.nodeSelector "root" $root) | trim) }} nodeSelector: {{- . | nindent 2 }} {{- end -}} -{{- with (include "ix.v1.common.tolerations" (dict "tolerations" $values.tolerations "root" $root) | trim) }} +{{- with (include "ix.v1.common.tolerations" (dict "tolerations" $values.controllers.main.pod.tolerations "root" $root) | trim) }} tolerations: {{- . | nindent 2 }} {{- end -}} @@ -50,21 +50,21 @@ imagePullSecrets: {{- . | nindent 2 }} {{- end -}} -{{- with (include "ix.v1.common.runtimeClassName" (dict "root" $root "runtime" $values.runtimeClassName) | trim) }} +{{- with (include "ix.v1.common.runtimeClassName" (dict "root" $root "runtime" $values.controllers.main.pod.runtimeClassName) | trim) }} runtimeClassName: {{ . }} {{- end -}} {{/* TODO: affinity, topologySpreadConstraints, not something critical as of now. */}} -{{- with $values.terminationGracePeriodSeconds }} +{{- with $values.controllers.main.pod.terminationGracePeriodSeconds }} terminationGracePeriodSeconds: {{ . }} {{- end -}} -{{- with (include "ix.v1.common.container.podSecurityContext" (dict "podSecCont" $values.podSecurityContext "root" $root) | trim) }} +{{- with (include "ix.v1.common.container.podSecurityContext" (dict "podSecCont" $values.controllers.main.pod.securityContext "root" $root) | trim) }} securityContext: {{- . | nindent 2 }} {{- end -}} -{{- with (include "ix.v1.common.controller.mainContainer" (dict "values" $values "root" $root) | trim) }} +{{- with (include "ix.v1.common.controller.mainContainer" (dict "values" $values.controllers.main.pod.containers.main "root" $root) | trim) }} containers: {{- . | nindent 2 }} {{- with (include "ix.v1.common.controller.extraContainers" (dict "root" $root "containerList" $values.additionalContainers "type" "additional") | trim) }} diff --git a/library/common/1.0.0/templates/lib/pod/_podAnnotations.tpl b/library/common/1.0.0/templates/lib/pod/_podAnnotations.tpl index cf3a881d63..bbc65fb970 100644 --- a/library/common/1.0.0/templates/lib/pod/_podAnnotations.tpl +++ b/library/common/1.0.0/templates/lib/pod/_podAnnotations.tpl @@ -1,6 +1,6 @@ {{/* Returns Pod annotations */}} {{- define "ix.v1.common.podAnnotations" -}} - {{- with .Values.podAnnotations -}} + {{- with .Values.controllers.main.pod.annotations -}} {{- range $k, $v := . }} {{ $k }}: {{ tpl $v $ }} {{- end }} diff --git a/library/common/1.0.0/templates/lib/pod/_podLabels.tpl b/library/common/1.0.0/templates/lib/pod/_podLabels.tpl index edc792b088..0920edbccf 100644 --- a/library/common/1.0.0/templates/lib/pod/_podLabels.tpl +++ b/library/common/1.0.0/templates/lib/pod/_podLabels.tpl @@ -1,6 +1,6 @@ {{/* Returns Pod labels */}} {{- define "ix.v1.common.podLabels" -}} - {{- with .Values.podLabels -}} + {{- with .Values.controllers.main.pod.labels -}} {{- range $k, $v := . }} {{ $k }}: {{ tpl $v $ }} {{- end }} diff --git a/library/common/1.0.0/templates/lib/pod/_restartPolicy.tpl b/library/common/1.0.0/templates/lib/pod/_restartPolicy.tpl index 5811df8938..45a285815a 100644 --- a/library/common/1.0.0/templates/lib/pod/_restartPolicy.tpl +++ b/library/common/1.0.0/templates/lib/pod/_restartPolicy.tpl @@ -16,7 +16,7 @@ {{- fail (printf "Invalid (%s). Valid options are Always, Never, OnFailure" $policy) -}} {{- end -}} - {{- if and (not $isJob) (mustHas $root.Values.controller.type (list "Deployment" "ReplicaSet" "DaemonSet" "StatefulSet")) -}} + {{- if and (not $isJob) (mustHas $root.Values.controllers.main.type (list "Deployment" "ReplicaSet" "DaemonSet" "StatefulSet")) -}} {{- if and (ne $policy "Always") -}} {{- fail (printf "Invalid