diff --git a/packages/core/platform/templates/_helpers.tpl b/packages/core/platform/templates/_helpers.tpl index 03ca23fb4..728f82c47 100644 --- a/packages/core/platform/templates/_helpers.tpl +++ b/packages/core/platform/templates/_helpers.tpl @@ -448,3 +448,18 @@ sliced into /24s ever allowed. {{- end -}} {{- end -}} {{- end }} + +{{/* +Prints "true" when gpu-operator serves GPUs to VirtualMachines: the iaas +bundle emits it and its variant is default or vgpu. The container variant +serves GPUs to pods only, which no GPUClass describes. +*/}} +{{- define "cozystack.platform.gpu.vmEnabled" -}} +{{- $name := "cozystack.gpu-operator" -}} +{{- $bundles := .Values.bundles -}} +{{- $iaas := and $bundles.system.enabled $bundles.iaas.enabled (has $bundles.system.variant (list "isp-full" "isp-full-generic")) -}} +{{- $enabled := and $iaas (has $name (default (list) $bundles.enabledPackages)) (not (has $name (default (list) $bundles.disabledPackages))) -}} +{{- if and $enabled (has ($bundles.iaas.gpuOperatorVariant | default "default") (list "default" "vgpu")) -}} +true +{{- end -}} +{{- end }} diff --git a/packages/core/platform/templates/bundles/system.yaml b/packages/core/platform/templates/bundles/system.yaml index f747210cc..432bcea8e 100644 --- a/packages/core/platform/templates/bundles/system.yaml +++ b/packages/core/platform/templates/bundles/system.yaml @@ -256,6 +256,9 @@ {{- if .Values.telemetry.disabled -}} {{- $_ := set $controllerValues "disableTelemetry" true -}} {{- end -}} +{{- if eq (include "cozystack.platform.gpu.vmEnabled" $) "true" -}} +{{- $_ := set $controllerValues "gpu" (dict "enabled" true) -}} +{{- end -}} {{- /* EndpointAttachment's method: WholeIP|PortList modes render the Service contract cozy-proxy implements. A proxy skips a Service delegated to a name it does not claim while the load balancer still attracts the diff --git a/packages/core/platform/tests/bundles_gpu_controller_wiring_test.yaml b/packages/core/platform/tests/bundles_gpu_controller_wiring_test.yaml new file mode 100644 index 000000000..dcd7976d4 --- /dev/null +++ b/packages/core/platform/tests/bundles_gpu_controller_wiring_test.yaml @@ -0,0 +1,118 @@ +suite: GPU controllers follow gpu-operator's VM variants +templates: + - templates/bundles/system.yaml +release: + name: cozystack + namespace: cozy-system +tests: + - it: enables the GPU controllers when gpu-operator serves GPUs to VMs + set: + bundles: + system: + enabled: true + variant: isp-full + iaas: + enabled: true + gpuOperatorVariant: vgpu + enabledPackages: + - cozystack.gpu-operator + telemetry: + disabled: true + documentSelector: + path: metadata.name + value: cozystack.cozystack-engine + asserts: + - equal: + path: spec.components.cozystack-controller.values.cozystackController + value: + disableTelemetry: true + endpointAttachments: + allocateLoadBalancerNodePorts: false + cozyProxyContractImplemented: true + gpu: + enabled: true + + - it: enables them for the default variant on isp-full-generic + set: + bundles: + system: + enabled: true + variant: isp-full-generic + iaas: + enabled: true + enabledPackages: + - cozystack.gpu-operator + documentSelector: + path: metadata.name + value: cozystack.cozystack-engine + asserts: + - equal: + path: spec.components.cozystack-controller.values.cozystackController.gpu.enabled + value: true + + - it: leaves them off for the container variant + set: + bundles: + system: + enabled: true + variant: isp-full + iaas: + enabled: true + gpuOperatorVariant: container + enabledPackages: + - cozystack.gpu-operator + documentSelector: + path: metadata.name + value: cozystack.cozystack-engine + asserts: + - notExists: + path: spec.components.cozystack-controller.values.cozystackController.gpu + + - it: leaves them off when gpu-operator is disabled + set: + bundles: + system: + enabled: true + variant: isp-full + iaas: + enabled: true + enabledPackages: + - cozystack.gpu-operator + disabledPackages: + - cozystack.gpu-operator + documentSelector: + path: metadata.name + value: cozystack.cozystack-engine + asserts: + - notExists: + path: spec.components.cozystack-controller.values.cozystackController.gpu + + - it: leaves them off without the iaas bundle + set: + bundles: + system: + enabled: true + variant: isp-full + enabledPackages: + - cozystack.gpu-operator + documentSelector: + path: metadata.name + value: cozystack.cozystack-engine + asserts: + - notExists: + path: spec.components.cozystack-controller.values.cozystackController.gpu + + - it: leaves them off on an iaas cluster without gpu-operator + set: + bundles: + system: + enabled: true + variant: isp-full + iaas: + enabled: true + documentSelector: + path: metadata.name + value: cozystack.cozystack-engine + asserts: + - notExists: + path: spec.components.cozystack-controller.values.cozystackController.gpu