From a8cc7de2ebbfcc5be8e24cabe04ca96b9a541778 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Wed, 10 Jul 2024 10:04:42 +0200 Subject: [PATCH] vGPU implementation - follow-up MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- apis/v1beta1/types.go | 6 +++--- docs/gpu-vgpu.md | 5 ++--- internal/webhooks/vspheremachine.go | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apis/v1beta1/types.go b/apis/v1beta1/types.go index 728f26a457..38bf6b5f81 100644 --- a/apis/v1beta1/types.go +++ b/apis/v1beta1/types.go @@ -253,21 +253,21 @@ type PCIDeviceSpec struct { // virtual machine is cloned. // Mutually exclusive with VGPUProfile as VGPUProfile and DeviceID + VendorID // are two independent ways to define PCI devices. - // +kubebuilder:validation:Required + // +optional DeviceID *int32 `json:"deviceId,omitempty"` // VendorId is the vendor ID of a virtual machine's PCI, in integer. // Defaults to the eponymous property value in the template from which the // virtual machine is cloned. // Mutually exclusive with VGPUProfile as VGPUProfile and DeviceID + VendorID // are two independent ways to define PCI devices. - // +kubebuilder:validation:Required + // +optional VendorID *int32 `json:"vendorId,omitempty"` // VGPUProfile is the profile name of a virtual machine's vGPU, in string. // Defaults to the eponymous property value in the template from which the // virtual machine is cloned. // Mutually exclusive with DeviceID and VendorID as VGPUProfile and DeviceID + VendorID // are two independent ways to define PCI devices. - // +kubebuilder:validation:Required + // +optional VGPUProfile string `json:"vGPUProfile,omitempty"` // CustomLabel is the hardware label of a virtual machine's PCI device. // Defaults to the eponymous property value in the template from which the diff --git a/docs/gpu-vgpu.md b/docs/gpu-vgpu.md index 81d1ea19d1..e5663e2ab3 100644 --- a/docs/gpu-vgpu.md +++ b/docs/gpu-vgpu.md @@ -55,11 +55,10 @@ We are using NVIDIA Tesla V100 32GB cards for this example and will use the `gri ### Create the cluster template ```shell -$ make dev-flavors -go run ./packaging/flavorgen --output-dir /home/user/.cluster-api/overrides/infrastructure-vsphere/v0.0.0 +$ make release-flavors ``` -Edit the generated Cluster template (`cluster-template.yaml`) to set the values for the `pciDevices` array. Here we are editing the VSphereMachineTemplate object for the worker nodes. This will create a worker node with a single NVIDIA 16GB vGPU device attached to the VM. +Edit the generated Cluster template (e.g. `out/cluster-template.yaml`) to set the values for the `pciDevices` array. Here we are editing the VSphereMachineTemplate object for the worker nodes. This will create a worker node with a single NVIDIA 16GB vGPU device attached to the VM. ```yaml --- diff --git a/internal/webhooks/vspheremachine.go b/internal/webhooks/vspheremachine.go index 328c7c1361..d039f4a8ac 100644 --- a/internal/webhooks/vspheremachine.go +++ b/internal/webhooks/vspheremachine.go @@ -175,7 +175,7 @@ func validatePCIDevices(devices []infrav1.PCIDeviceSpec) field.ErrorList { // Valid case for PCI Passthrough. continue } - allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "template", "spec", "pciDevices", fmt.Sprintf("%d", i)), device, "should have either deviceId + vendorId or vGPUProfile set")) + allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "template", "spec", "pciDevices").Index(i), device, "should have either deviceId + vendorId or vGPUProfile set")) } return allErrs }