diff --git a/library/common-test/tests/addons/vpn_test.yaml b/library/common-test/tests/addons/vpn_test.yaml index aea8daaa..244efd9e 100644 --- a/library/common-test/tests/addons/vpn_test.yaml +++ b/library/common-test/tests/addons/vpn_test.yaml @@ -13,6 +13,11 @@ tests: env: key: value key1: value1 + envList: + - name: key2 + value: value2 + - name: key3 + value: value3 workload: &workload main: enabled: true @@ -102,6 +107,18 @@ tests: content: name: key1 value: value1 + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].env + content: + name: key2 + value: value2 + - documentIndex: *DeploymentDocument + contains: + path: spec.template.spec.containers[1].env + content: + name: key3 + value: value3 - documentIndex: *DeploymentDocument contains: path: spec.template.spec.containers[1].volumeMounts diff --git a/library/common-test/tests/container/resources_test.yaml b/library/common-test/tests/container/resources_test.yaml index 6dbb6349..a2924eae 100644 --- a/library/common-test/tests/container/resources_test.yaml +++ b/library/common-test/tests/container/resources_test.yaml @@ -628,6 +628,147 @@ tests: cpu: 10m memory: 50Mi + - it: should assign GPU on the selected pod/container with multiple GPUs + set: + image: *image + global: + ixChartContext: + addNvidiaRuntimeClass: true + nvidiaRuntimeClassName: nvidia + scaleGPU: + - gpu: + nvidia.com/gpu: 1 + amd.com/gpu: 0 + targetSelector: + workload-name1: + - container-name1 + - container-name2 + workload: + workload-name1: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + container-name1: + enabled: true + primary: true + imageSelector: image + probes: *probes + container-name2: + enabled: true + primary: false + imageSelector: image + probes: *probes + asserts: + - documentIndex: &deploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *deploymentDoc + isAPIVersion: + of: apps/v1 + - documentIndex: *deploymentDoc + equal: + path: spec.template.spec.runtimeClassName + value: nvidia + - documentIndex: *deploymentDoc + isSubset: + path: spec.template.spec.containers[0] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + nvidia.com/gpu: "1" + requests: + cpu: 10m + memory: 50Mi + - documentIndex: *deploymentDoc + isSubset: + path: spec.template.spec.containers[1] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + nvidia.com/gpu: "1" + requests: + cpu: 10m + memory: 50Mi + + - it: should assign multiple GPU on the selected pod/container with multiple selected GPUs + set: + image: *image + global: + ixChartContext: + addNvidiaRuntimeClass: true + nvidiaRuntimeClassName: nvidia + scaleGPU: + - gpu: + nvidia.com/gpu: 1 + amd.com/gpu: 0 + targetSelector: + workload-name1: + - container-name1 + - gpu: + nvidia.com/gpu: 0 + amd.com/gpu: 1 + targetSelector: + workload-name1: + - container-name2 + workload: + workload-name1: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + container-name1: + enabled: true + primary: true + imageSelector: image + probes: *probes + container-name2: + enabled: true + primary: false + imageSelector: image + probes: *probes + asserts: + - documentIndex: &deploymentDoc 0 + isKind: + of: Deployment + - documentIndex: *deploymentDoc + isAPIVersion: + of: apps/v1 + - documentIndex: *deploymentDoc + equal: + path: spec.template.spec.runtimeClassName + value: nvidia + - documentIndex: *deploymentDoc + isSubset: + path: spec.template.spec.containers[0] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + nvidia.com/gpu: "1" + requests: + cpu: 10m + memory: 50Mi + - documentIndex: *deploymentDoc + isSubset: + path: spec.template.spec.containers[1] + content: + resources: + limits: + cpu: 4000m + memory: 8Gi + amd.com/gpu: "1" + requests: + cpu: 10m + memory: 50Mi + # Failures - it: should fail with empty requests set: @@ -868,3 +1009,28 @@ tests: asserts: - failedTemplate: errorMessage: Container - Expected non-empty + + - it: should fail with no value in gpu + set: + image: *image + scaleGPU: + - gpu: + key: + targetSelector: + workload-name1: + - container-name1 + workload: + workload-name1: + enabled: true + primary: true + type: Deployment + podSpec: + containers: + container-name1: + enabled: true + primary: true + imageSelector: image + probes: *probes + asserts: + - failedTemplate: + errorMessage: Container - Expected non-empty diff --git a/library/common/Chart.yaml b/library/common/Chart.yaml index 6d2b30fe..e8cf746c 100644 --- a/library/common/Chart.yaml +++ b/library/common/Chart.yaml @@ -15,4 +15,4 @@ maintainers: name: common sources: null type: library -version: 12.4.11 +version: 12.4.12 diff --git a/library/common/templates/addons/code-server/_container.tpl b/library/common/templates/addons/code-server/_container.tpl index 7344f880..a66572d2 100644 --- a/library/common/templates/addons/code-server/_container.tpl +++ b/library/common/templates/addons/code-server/_container.tpl @@ -7,12 +7,15 @@ probes: liveness: enabled: true port: {{ .Values.addons.codeserver.service.ports.codeserver.port }} + path: "/" readiness: enabled: true port: {{ .Values.addons.codeserver.service.ports.codeserver.port }} + path: "/" startup: enabled: true port: {{ .Values.addons.codeserver.service.ports.codeserver.port }} + path: "/" imageSelector: "codeserverImage" imagePullPolicy: {{ .Values.codeserverImage.pullPolicy }} securityContext: diff --git a/library/common/templates/addons/vpn/_gluetunContainer.tpl b/library/common/templates/addons/vpn/_gluetunContainer.tpl index 38cfbd03..8958e036 100644 --- a/library/common/templates/addons/vpn/_gluetunContainer.tpl +++ b/library/common/templates/addons/vpn/_gluetunContainer.tpl @@ -27,8 +27,8 @@ securityContext: - NET_RAW - SYS_MODULE -{{- with $.Values.addons.vpn.env }} env: +{{- with $.Values.addons.vpn.env }} {{- . | toYaml | nindent 2 }} {{- end -}} diff --git a/library/common/templates/addons/vpn/_openvpnContainer.tpl b/library/common/templates/addons/vpn/_openvpnContainer.tpl index 8ca3476a..0d976501 100644 --- a/library/common/templates/addons/vpn/_openvpnContainer.tpl +++ b/library/common/templates/addons/vpn/_openvpnContainer.tpl @@ -23,10 +23,11 @@ securityContext: add: - NET_ADMIN - NET_RAW + - MKNOD - SYS_MODULE -{{- with $.Values.addons.vpn.env }} env: +{{- with $.Values.addons.vpn.env }} {{- . | toYaml | nindent 2 }} {{- end }} {{- if and .Values.addons.vpn.openvpn.username .Values.addons.vpn.openvpn.password }} diff --git a/library/common/templates/addons/vpn/_wireguardContainer.tpl b/library/common/templates/addons/vpn/_wireguardContainer.tpl index 7822175f..c30016c9 100644 --- a/library/common/templates/addons/vpn/_wireguardContainer.tpl +++ b/library/common/templates/addons/vpn/_wireguardContainer.tpl @@ -23,10 +23,12 @@ securityContext: add: - NET_ADMIN - NET_RAW + - SETUID + - SETGID - SYS_MODULE -{{- with $.Values.addons.vpn.env }} env: +{{- with $.Values.addons.vpn.env }} {{- . | toYaml | nindent 2 }} {{- end }} SEPARATOR: ";" diff --git a/library/common/templates/lib/container/_resources.tpl b/library/common/templates/lib/container/_resources.tpl index aa0fdc1d..b97de7eb 100644 --- a/library/common/templates/lib/container/_resources.tpl +++ b/library/common/templates/lib/container/_resources.tpl @@ -75,10 +75,12 @@ objectData: The object data to be used to render the container. {{- if not $returnBool -}} {{- range $gpu := $gpuResource -}} {{- range $k, $v := $gpu -}} - {{- if not $v -}} + {{- if or (kindIs "invalid" $v) (eq (toString $v) "") -}} {{- fail "Container - Expected non-empty " -}} - {{- end }} + {{- end -}} {{/* Don't try to schedule 0 GPUs */}} + {{- if gt (int $v) 0 }} {{ $k }}: {{ $v | quote }} + {{- end -}} {{- end -}} {{- end -}} {{- else -}}