From 5a5f00fd0966f45c4a3466a55283ba54e6a69124 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Thu, 15 Feb 2024 11:46:54 +0100 Subject: [PATCH 1/4] Fix spec naming conventions Signed-off-by: Carlos Eduardo Arango Gutierrez --- api/holodeck/v1alpha1/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/holodeck/v1alpha1/types.go b/api/holodeck/v1alpha1/types.go index 2eabe5fd..40e95290 100644 --- a/api/holodeck/v1alpha1/types.go +++ b/api/holodeck/v1alpha1/types.go @@ -30,11 +30,11 @@ type EnvironmentSpec struct { Instance `json:"instance"` // +optional - NVDriver NVDriver `json:"nvDriver"` + NVDriver NVDriver `json:"nvidiaDriver"` // +optional ContainerRuntime ContainerRuntime `json:"containerRuntime"` // +optional - NVContainerToolKit NVContainerToolKit `json:"nvContainerToolKit"` + NVContainerToolkit NVContainerToolkit `json:"nvidiaContainerToolkit"` // +optional Kubernetes Kubernetes `json:"kubernetes"` } From fb86a83a30825ade348247fe5a4c917c987495a5 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Thu, 15 Feb 2024 11:48:02 +0100 Subject: [PATCH 2/4] Update bolierplate date Signed-off-by: Carlos Eduardo Arango Gutierrez --- hack/boilerplate.go.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hack/boilerplate.go.txt b/hack/boilerplate.go.txt index df22b8f8..b64c426a 100644 --- a/hack/boilerplate.go.txt +++ b/hack/boilerplate.go.txt @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 5e006c70129ffb28638f54ca20923660cb335d43 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Thu, 15 Feb 2024 11:48:23 +0100 Subject: [PATCH 3/4] Bump controllergen to v0.14 Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/go.yml | 8 ++++-- Makefile | 2 +- api/holodeck/v1alpha1/types.go | 2 +- .../v1alpha1/zz_generated.deepcopy.go | 28 ++++++++++++++----- pkg/provisioner/dependency.go | 4 +-- 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index ce949986..ddab1ca7 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -5,9 +5,13 @@ name: Go on: push: - branches: [ "main" ] + branches: + - main + - release-* pull_request: - branches: [ "main" ] + branches: + - main + - release-* jobs: diff --git a/Makefile b/Makefile index bd3534db..57ed5f08 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ generate: controller-gen CONTROLLER_GEN = $(PROJECT_DIR)/bin/controller-gen .PHONY: controller-gen controller-gen: ## Download controller-gen locally if necessary. - @GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.12.1 + @GOBIN=$(PROJECT_DIR)/bin GO111MODULE=on $(GO_CMD) install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0 # Generate manifests e.g. CRD, RBAC etc. .PHONY: manifests diff --git a/api/holodeck/v1alpha1/types.go b/api/holodeck/v1alpha1/types.go index 40e95290..ab9d1b83 100644 --- a/api/holodeck/v1alpha1/types.go +++ b/api/holodeck/v1alpha1/types.go @@ -189,7 +189,7 @@ type ExtraPortMapping struct { HostPort int `json:"hostPort"` } -type NVContainerToolKit struct { +type NVContainerToolkit struct { Install bool `json:"install"` // If not set the latest stable version will be used // +optional diff --git a/api/holodeck/v1alpha1/zz_generated.deepcopy.go b/api/holodeck/v1alpha1/zz_generated.deepcopy.go index 5af5b56c..b3063808 100644 --- a/api/holodeck/v1alpha1/zz_generated.deepcopy.go +++ b/api/holodeck/v1alpha1/zz_generated.deepcopy.go @@ -1,8 +1,7 @@ //go:build !ignore_autogenerated -// +build !ignore_autogenerated /* - * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -122,7 +121,7 @@ func (in *EnvironmentSpec) DeepCopyInto(out *EnvironmentSpec) { in.Instance.DeepCopyInto(&out.Instance) out.NVDriver = in.NVDriver out.ContainerRuntime = in.ContainerRuntime - out.NVContainerToolKit = in.NVContainerToolKit + out.NVContainerToolkit = in.NVContainerToolkit in.Kubernetes.DeepCopyInto(&out.Kubernetes) } @@ -163,6 +162,21 @@ func (in *EnvironmentStatus) DeepCopy() *EnvironmentStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ExtraPortMapping) DeepCopyInto(out *ExtraPortMapping) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExtraPortMapping. +func (in *ExtraPortMapping) DeepCopy() *ExtraPortMapping { + if in == nil { + return nil + } + out := new(ExtraPortMapping) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Image) DeepCopyInto(out *Image) { *out = *in @@ -255,16 +269,16 @@ func (in *Kubernetes) DeepCopy() *Kubernetes { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NVContainerToolKit) DeepCopyInto(out *NVContainerToolKit) { +func (in *NVContainerToolkit) DeepCopyInto(out *NVContainerToolkit) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVContainerToolKit. -func (in *NVContainerToolKit) DeepCopy() *NVContainerToolKit { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVContainerToolkit. +func (in *NVContainerToolkit) DeepCopy() *NVContainerToolkit { if in == nil { return nil } - out := new(NVContainerToolKit) + out := new(NVContainerToolkit) in.DeepCopyInto(out) return out } diff --git a/pkg/provisioner/dependency.go b/pkg/provisioner/dependency.go index 316aea0c..5f9f2805 100644 --- a/pkg/provisioner/dependency.go +++ b/pkg/provisioner/dependency.go @@ -62,7 +62,7 @@ func buildDependencyGraph(env v1alpha1.Environment) ([]ProvisionFunc, error) { } // if container toolkit is enabled then add container toolkit and nvdriver to kubeadm - if env.Spec.NVContainerToolKit.Install { + if env.Spec.NVContainerToolkit.Install { graph["kubeadm"] = append(graph["kubeadm"], "containerToolkit") graph["kubeadm"] = append(graph["kubeadm"], "nvdriver") @@ -107,7 +107,7 @@ func buildDependencyGraph(env v1alpha1.Environment) ([]ProvisionFunc, error) { } // If no kubernetes is requested, we move to container-toolkit - if env.Spec.NVContainerToolKit.Install { + if env.Spec.NVContainerToolkit.Install { for _, f := range graph["containerToolkit"] { ordered = append(ordered, functions[f]) } From d9a07222112af8c6b457ab2adcc5895692efb1c6 Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Thu, 15 Feb 2024 12:06:41 +0100 Subject: [PATCH 4/4] Add release Makefile target Signed-off-by: Carlos Eduardo Arango Gutierrez --- Makefile | 14 +++++++++++-- api/holodeck/v1alpha1/types.go | 8 ++++---- .../v1alpha1/zz_generated.deepcopy.go | 20 +++++++++---------- pkg/provisioner/dependency.go | 8 ++++---- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index 57ed5f08..27e68ebb 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -.PHONY: build fmt verify +.PHONY: build fmt verify release GO_CMD ?= go GO_FMT ?= gofmt @@ -40,6 +40,16 @@ verify: exit 1; \ fi +release: + @rm -rf bin + @mkdir -p bin + @for os in linux darwin; do \ + for arch in amd64 arm64; do \ + echo "Building $$os-$$arch"; \ + GOOS=$$os GOARCH=$$arch $(GO_CMD) build -o bin/$(BINARY_NAME)-$$os-$$arch cmd/main.go; \ + done; \ + done + .PHONY: generate generate: controller-gen $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." @@ -52,4 +62,4 @@ controller-gen: ## Download controller-gen locally if necessary. # Generate manifests e.g. CRD, RBAC etc. .PHONY: manifests manifests: controller-gen - $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases \ No newline at end of file + $(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases diff --git a/api/holodeck/v1alpha1/types.go b/api/holodeck/v1alpha1/types.go index ab9d1b83..fec7bf50 100644 --- a/api/holodeck/v1alpha1/types.go +++ b/api/holodeck/v1alpha1/types.go @@ -30,11 +30,11 @@ type EnvironmentSpec struct { Instance `json:"instance"` // +optional - NVDriver NVDriver `json:"nvidiaDriver"` + NVIDIADriver NVIDIADriver `json:"nvidiaDriver"` // +optional ContainerRuntime ContainerRuntime `json:"containerRuntime"` // +optional - NVContainerToolkit NVContainerToolkit `json:"nvidiaContainerToolkit"` + NVIDIAContainerToolkit NVIDIAContainerToolkit `json:"nvidiaContainerToolkit"` // +optional Kubernetes Kubernetes `json:"kubernetes"` } @@ -134,7 +134,7 @@ type Auth struct { PrivateKey string `json:"privateKey"` } -type NVDriver struct { +type NVIDIADriver struct { Install bool `json:"install"` // If not set the latest stable version will be used // +optional @@ -189,7 +189,7 @@ type ExtraPortMapping struct { HostPort int `json:"hostPort"` } -type NVContainerToolkit struct { +type NVIDIAContainerToolkit struct { Install bool `json:"install"` // If not set the latest stable version will be used // +optional diff --git a/api/holodeck/v1alpha1/zz_generated.deepcopy.go b/api/holodeck/v1alpha1/zz_generated.deepcopy.go index b3063808..2c5f56b6 100644 --- a/api/holodeck/v1alpha1/zz_generated.deepcopy.go +++ b/api/holodeck/v1alpha1/zz_generated.deepcopy.go @@ -119,9 +119,9 @@ func (in *EnvironmentSpec) DeepCopyInto(out *EnvironmentSpec) { *out = *in out.Auth = in.Auth in.Instance.DeepCopyInto(&out.Instance) - out.NVDriver = in.NVDriver + out.NVIDIADriver = in.NVIDIADriver out.ContainerRuntime = in.ContainerRuntime - out.NVContainerToolkit = in.NVContainerToolkit + out.NVIDIAContainerToolkit = in.NVIDIAContainerToolkit in.Kubernetes.DeepCopyInto(&out.Kubernetes) } @@ -269,31 +269,31 @@ func (in *Kubernetes) DeepCopy() *Kubernetes { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NVContainerToolkit) DeepCopyInto(out *NVContainerToolkit) { +func (in *NVIDIAContainerToolkit) DeepCopyInto(out *NVIDIAContainerToolkit) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVContainerToolkit. -func (in *NVContainerToolkit) DeepCopy() *NVContainerToolkit { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVIDIAContainerToolkit. +func (in *NVIDIAContainerToolkit) DeepCopy() *NVIDIAContainerToolkit { if in == nil { return nil } - out := new(NVContainerToolkit) + out := new(NVIDIAContainerToolkit) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NVDriver) DeepCopyInto(out *NVDriver) { +func (in *NVIDIADriver) DeepCopyInto(out *NVIDIADriver) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVDriver. -func (in *NVDriver) DeepCopy() *NVDriver { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVIDIADriver. +func (in *NVIDIADriver) DeepCopy() *NVIDIADriver { if in == nil { return nil } - out := new(NVDriver) + out := new(NVIDIADriver) in.DeepCopyInto(out) return out } diff --git a/pkg/provisioner/dependency.go b/pkg/provisioner/dependency.go index 5f9f2805..3a690eaa 100644 --- a/pkg/provisioner/dependency.go +++ b/pkg/provisioner/dependency.go @@ -62,7 +62,7 @@ func buildDependencyGraph(env v1alpha1.Environment) ([]ProvisionFunc, error) { } // if container toolkit is enabled then add container toolkit and nvdriver to kubeadm - if env.Spec.NVContainerToolkit.Install { + if env.Spec.NVIDIAContainerToolkit.Install { graph["kubeadm"] = append(graph["kubeadm"], "containerToolkit") graph["kubeadm"] = append(graph["kubeadm"], "nvdriver") @@ -81,7 +81,7 @@ func buildDependencyGraph(env v1alpha1.Environment) ([]ProvisionFunc, error) { graph["containerToolkit"] = append(graph["containerToolkit"], "containerToolkit") // user might request to install container toolkit without nvdriver for testing purpose - if env.Spec.NVDriver.Install { + if env.Spec.NVIDIADriver.Install { graph["containerToolkit"] = append(graph["containerToolkit"], "nvdriver") } } @@ -107,7 +107,7 @@ func buildDependencyGraph(env v1alpha1.Environment) ([]ProvisionFunc, error) { } // If no kubernetes is requested, we move to container-toolkit - if env.Spec.NVContainerToolkit.Install { + if env.Spec.NVIDIAContainerToolkit.Install { for _, f := range graph["containerToolkit"] { ordered = append(ordered, functions[f]) } @@ -134,7 +134,7 @@ func buildDependencyGraph(env v1alpha1.Environment) ([]ProvisionFunc, error) { } // If no container-runtime is requested, we move to nvdriver - if env.Spec.NVDriver.Install { + if env.Spec.NVIDIADriver.Install { ordered = append(ordered, functions["nvdriver"]) return ordered, nil }