sigs.k8s.io/cluster-api-provider-azure@v1.14.3/test/e2e/gpu_operator.go (about) 1 //go:build e2e 2 // +build e2e 3 4 /* 5 Copyright 2023 The Kubernetes Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 */ 19 20 package e2e 21 22 import ( 23 "context" 24 25 . "github.com/onsi/ginkgo/v2" 26 . "github.com/onsi/gomega" 27 corev1 "k8s.io/api/core/v1" 28 "sigs.k8s.io/cluster-api/test/framework" 29 ) 30 31 const ( 32 nvidiaHelmChartRepoURL string = "https://helm.ngc.nvidia.com/nvidia" 33 nvidiaGPUOperatorNamespace string = "default" 34 nvidiaGPUOperatorHelmReleaseName string = "nvidia-gpu-operator" 35 nvidiaGPUOperatorHelmChartName string = "gpu-operator" 36 ) 37 38 // GPUOperatorSpecInput is the input for InstallGPUOperator. 39 type GPUOperatorSpecInput struct { 40 BootstrapClusterProxy framework.ClusterProxy 41 Namespace *corev1.Namespace 42 ClusterName string 43 } 44 45 // InstallGPUOperator installs the official nvidia/gpu-operator helm chart. 46 func InstallGPUOperator(ctx context.Context, inputGetter func() GPUOperatorSpecInput) { 47 var ( 48 specName = "nvidia-gpu-operator" 49 input GPUOperatorSpecInput 50 ) 51 52 Expect(ctx).NotTo(BeNil(), "ctx is required for %s spec", specName) 53 54 input = inputGetter() 55 Expect(input.BootstrapClusterProxy).NotTo(BeNil(), "Invalid argument. input.BootstrapClusterProxy can't be nil when calling %s spec", specName) 56 Expect(input.Namespace).NotTo(BeNil(), "Invalid argument. input.Namespace can't be nil when calling %s spec", specName) 57 Expect(input.ClusterName).NotTo(BeEmpty(), "Invalid argument. input.ClusterName can't be empty when calling %s spec", specName) 58 clusterProxy := input.BootstrapClusterProxy.GetWorkloadCluster(ctx, input.Namespace.Name, input.ClusterName) 59 InstallNvidiaGPUOperatorChart(ctx, clusterProxy) 60 } 61 62 // InstallNvidiaGPUOperatorChart installs the official nvidia/gpu-operator helm chart 63 func InstallNvidiaGPUOperatorChart(ctx context.Context, clusterProxy framework.ClusterProxy) { 64 By("Installing nvidia/gpu-operator via helm") 65 values := &HelmOptions{} 66 InstallHelmChart(ctx, clusterProxy, nvidiaGPUOperatorNamespace, nvidiaHelmChartRepoURL, nvidiaGPUOperatorHelmChartName, nvidiaGPUOperatorHelmReleaseName, values, "") 67 }