diff --git a/.common-ci.yml b/.common-ci.yml index 3d5c64c5e3..76c9768676 100644 --- a/.common-ci.yml +++ b/.common-ci.yml @@ -32,6 +32,8 @@ stages: # https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines workflow: rules: + - if: $CI_COMMIT_TAG =~ /^api\/v/ + when: never - if: $CI_PIPELINE_SOURCE == 'merge_request_event' - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 87eb58cb39..f4df6564fa 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,7 +5,9 @@ version: 2 updates: - package-ecosystem: "gomod" target-branch: main - directory: "/" + directories: + - "/" + - "/api" schedule: interval: "daily" cooldown: @@ -20,6 +22,10 @@ updates: - k8s.io/* exclude-patterns: - k8s.io/klog/* + cross-directory: + patterns: + - "*" + group-by: dependency-name - package-ecosystem: "gomod" target-branch: main diff --git a/.github/workflows/api-post-tag-validation.yaml b/.github/workflows/api-post-tag-validation.yaml new file mode 100644 index 0000000000..8136111cb4 --- /dev/null +++ b/.github/workflows/api-post-tag-validation.yaml @@ -0,0 +1,56 @@ +# Copyright NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +name: API Post-Tag Validation + +on: + push: + tags: + - "v[0-9]*.[0-9]*.[0-9]*" + workflow_dispatch: + inputs: + operator_tag: + description: "Operator tag to validate" + required: true + type: string + +permissions: + contents: read + +jobs: + validate-api-module: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Checkout tagged code + uses: actions/checkout@v7 + with: + ref: ${{ github.event.inputs.operator_tag || github.ref }} + fetch-depth: 0 + persist-credentials: false + + - name: Get Golang version + run: | + GOLANG_VERSION=$(grep "GOLANG_VERSION ?=" versions.mk) + echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> "${GITHUB_ENV}" + + - name: Install Go + uses: actions/setup-go@v7 + with: + go-version: ${{ env.GOLANG_VERSION }} + + - name: Validate published API module + env: + OPERATOR_TAG: ${{ github.event.inputs.operator_tag || github.ref_name }} + run: make validate-published-api-module OPERATOR_TAG="${OPERATOR_TAG}" diff --git a/.github/workflows/api-release-checks.yaml b/.github/workflows/api-release-checks.yaml new file mode 100644 index 0000000000..d91ecf6e39 --- /dev/null +++ b/.github/workflows/api-release-checks.yaml @@ -0,0 +1,53 @@ +# Copyright NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +name: API Release Checks + +on: + pull_request: + types: + - opened + - synchronize + - reopened + - edited + +permissions: + contents: read + +jobs: + api-version-unpublished: + if: | + contains(github.event.pull_request.title, 'operator') && + contains(github.event.pull_request.title, 'version') && + contains(github.event.pull_request.title, 'bump') + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Checkout code + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Get Golang version + run: | + GOLANG_VERSION=$(grep "GOLANG_VERSION ?=" versions.mk) + echo "GOLANG_VERSION=${GOLANG_VERSION##GOLANG_VERSION ?= }" >> "${GITHUB_ENV}" + + - name: Install Go + uses: actions/setup-go@v7 + with: + go-version: ${{ env.GOLANG_VERSION }} + + - name: Check that API version is unpublished + run: make validate-api-version-unpublished diff --git a/.golangci.yml b/.golangci.yml index bbc2e95ec9..c7ac5fd5ce 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,12 +26,7 @@ linters: rules: - linters: - staticcheck - path: (.+)\.go$ - text: 'SA1019: \(github.com/NVIDIA/gpu-operator/api/nvidia/v1.DriverLicensingConfigSpec\).ConfigMapName is deprecated(.+)' - - linters: - - staticcheck - path: (.+)\.go$ - text: 'SA1019: \(github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1.DriverLicensingConfigSpec\).Name is deprecated(.+)' + text: 'SA1019: .*\.(ConfigMapName|Name) is deprecated: ConfigMapName has been deprecated in favour of SecretName(.+)' formatters: enable: - gofmt diff --git a/.nvidia-ci.yml b/.nvidia-ci.yml index 040c897bbd..c32ae1de45 100644 --- a/.nvidia-ci.yml +++ b/.nvidia-ci.yml @@ -154,6 +154,8 @@ update-nspect: extends: - .update-nspect rules: + - if: $CI_COMMIT_TAG =~ /^api\/v/ + when: never - if: $CI_COMMIT_TAG variables: OSRB_BUG_ID: "${OSRB_BUG_ID}" @@ -180,6 +182,8 @@ ngc-image-publish: extends: - .publish-images rules: + - if: $CI_COMMIT_TAG =~ /^api\/v/ + when: never - if: $CI_COMMIT_TAG needs: - job: update-nspect diff --git a/Makefile b/Makefile index 4d5faf5cb5..bd44862b7b 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,8 @@ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) include $(CURDIR)/versions.mk MODULE := github.com/NVIDIA/gpu-operator +API_DIR := $(PROJECT_DIR)/api +API_MODULE := $(MODULE)/api GOPROXY ?= https://proxy.golang.org,direct ifeq ($(IMAGE_NAME),) @@ -103,20 +105,23 @@ undeploy: $(KUSTOMIZE) build config/default | kubectl delete -f - # Generate manifests e.g. CRD, RBAC etc. +.PHONY: manifests manifests: install-tools @echo "- Generating CRDs from the codebase" - $(CONTROLLER_GEN) rbac:roleName=gpu-operator-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases + $(CONTROLLER_GEN) rbac:roleName=gpu-operator-role webhook paths="./..." + cd $(API_DIR) && $(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=$(PROJECT_DIR)/config/crd/bases # Generate code +.PHONY: generate generate-clientset generate: install-tools - $(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..." + cd $(API_DIR) && $(CONTROLLER_GEN) object:headerFile="$(PROJECT_DIR)/hack/boilerplate.go.txt" paths="./..." generate-clientset: install-tools - $(CLIENT_GEN) --go-header-file=$(CURDIR)/hack/boilerplate.go.txt \ + cd $(API_DIR) && $(CLIENT_GEN) --go-header-file=$(CURDIR)/hack/boilerplate.go.txt \ --clientset-name "versioned" \ - --output-dir $(CURDIR)/api \ - --output-pkg $(MODULE)/api \ - --input-base $(CURDIR)/api \ + --output-dir $(API_DIR) \ + --output-pkg $(API_MODULE) \ + --input-base $(API_DIR) \ --input nvidia/v1,nvidia/v1alpha1 # Generate bundle manifests and metadata, then validate generated files. @@ -144,7 +149,7 @@ push-bundle-image: build-bundle-image CMDS := $(patsubst ./cmd/%/,%,$(sort $(dir $(wildcard ./cmd/*/)))) CMD_TARGETS := $(patsubst %,cmd-%, $(CMDS)) -CHECK_TARGETS := lint license-check validate-modules validate-generated-assets +CHECK_TARGETS := lint license-check validate-shared-dependencies validate-modules validate-generated-assets MAKE_TARGETS := build check coverage cmds $(CMD_TARGETS) $(CHECK_TARGETS) DOCKER_TARGETS := $(patsubst %,docker-%, $(MAKE_TARGETS)) .PHONY: $(MAKE_TARGETS) $(DOCKER_TARGETS) @@ -207,6 +212,8 @@ check-third-party-notices: third-party-notices fmt: go list -f '{{.Dir}}' $(MODULE)/... \ | xargs gofmt -s -l -d + go -C $(API_DIR) list -f '{{.Dir}}' ./... \ + | xargs gofmt -s -l -d # Apply goimports -local github.com/NVIDIA/gpu-operator to the codebase goimports: @@ -215,10 +222,12 @@ goimports: lint: golangci-lint run ./... + cd $(API_DIR) && golangci-lint run --config $(PROJECT_DIR)/.golangci.yml ./... BUILD_FLAGS = -ldflags "-s -w -X $(VERSION_PKG).gitCommit=$(GIT_COMMIT) -X $(VERSION_PKG).version=$(VERSION)" build: go build $(BUILD_FLAGS) ./... + go -C $(API_DIR) build ./... cmds: $(CMD_TARGETS) $(CMD_TARGETS): cmd-%: @@ -232,7 +241,22 @@ sync-crds: TOOLS_DIR := $(PROJECT_DIR)/tools E2E_TESTS_DIR := $(PROJECT_DIR)/tests/e2e + +validate-shared-dependencies: + @bash hack/validate-shared-dependencies.sh + +validate-api-version-unpublished: + @bash hack/validate-api-version-unpublished.sh + +validate-published-api-module: + @bash hack/validate-published-api-module.sh "$(OPERATOR_TAG)" + validate-modules: + @echo "- [api] Verifying that the dependencies have expected content..." + go -C $(API_DIR) mod verify + @echo "- [api] Checking for any unused/missing packages in go.mod..." + go -C $(API_DIR) mod tidy + @git diff --exit-code -- $(API_DIR)/go.sum $(API_DIR)/go.mod @echo "- Verifying that the dependencies have expected content..." go mod verify @echo "- Checking for any unused/missing packages in go.mod..." @@ -278,10 +302,14 @@ COVERAGE_FILE := coverage.out unit-test: build go list -f {{.Dir}} $(MODULE)/... | grep -v /tests/e2e \ | xargs go test -v -coverprofile=$(COVERAGE_FILE) + go -C $(API_DIR) test -v -coverprofile=$(PROJECT_DIR)/$(COVERAGE_FILE).api ./... + { head -n1 $(COVERAGE_FILE); tail -n+2 $(COVERAGE_FILE); tail -n+2 $(COVERAGE_FILE).api; } > $(COVERAGE_FILE).tmp + mv $(COVERAGE_FILE).tmp $(COVERAGE_FILE) + rm -f $(COVERAGE_FILE).api coverage: unit-test cat $(COVERAGE_FILE) | grep -v "_mock.go" > $(COVERAGE_FILE).no-mocks - go tool cover -func=$(COVERAGE_FILE).no-mocks + GOFLAGS=-mod=readonly go tool cover -func=$(COVERAGE_FILE).no-mocks cov-report: coverage install-tools $(GCOV2LCOV) -infile $(COVERAGE_FILE) -outfile lcov.info diff --git a/api/go.mod b/api/go.mod new file mode 100644 index 0000000000..a74cc464e7 --- /dev/null +++ b/api/go.mod @@ -0,0 +1,62 @@ +module github.com/NVIDIA/gpu-operator/api + +go 1.26.3 + +require ( + github.com/NVIDIA/k8s-kata-manager v0.2.3 + github.com/NVIDIA/k8s-operator-libs v0.0.0-20260629200812-d720f2557494 + github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.93.1 + github.com/regclient/regclient v0.11.5 + github.com/stretchr/testify v1.12.0 + golang.org/x/mod v0.40.0 + k8s.io/api v0.36.4 + k8s.io/apimachinery v0.36.4 + k8s.io/client-go v0.36.4 + k8s.io/utils v0.0.0-20260507154919-ff6756f316d2 +) + +require ( + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.13.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.2 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.25.4 // indirect + github.com/go-openapi/swag/cmdutils v0.25.4 // indirect + github.com/go-openapi/swag/conv v0.25.4 // indirect + github.com/go-openapi/swag/fileutils v0.25.4 // indirect + github.com/go-openapi/swag/jsonname v0.25.4 // indirect + github.com/go-openapi/swag/jsonutils v0.25.4 // indirect + github.com/go-openapi/swag/loading v0.25.4 // indirect + github.com/go-openapi/swag/mangling v0.25.4 // indirect + github.com/go-openapi/swag/netutils v0.25.4 // indirect + github.com/go-openapi/swag/stringutils v0.25.4 // indirect + github.com/go-openapi/swag/typeutils v0.25.4 // indirect + github.com/go-openapi/swag/yamlutils v0.25.4 // indirect + github.com/google/gnostic-models v0.7.0 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/x448/float16 v0.8.4 // indirect + go.yaml.in/yaml/v2 v2.4.4 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect + golang.org/x/net v0.56.0 // indirect + golang.org/x/oauth2 v0.34.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/term v0.44.0 // indirect + golang.org/x/text v0.39.0 // indirect + golang.org/x/time v0.14.0 // indirect + google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect + gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/klog/v2 v2.140.0 // indirect + k8s.io/kube-openapi v0.0.0-20260603220949-865597e52e25 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.4.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect +) diff --git a/api/go.sum b/api/go.sum new file mode 100644 index 0000000000..52340caef1 --- /dev/null +++ b/api/go.sum @@ -0,0 +1,151 @@ +github.com/NVIDIA/k8s-kata-manager v0.2.3 h1:d5+gRFqU5el/fKMXhHUaPY7haj+dbHL4nDsO/q05LBo= +github.com/NVIDIA/k8s-kata-manager v0.2.3/go.mod h1:xx5OUiMsHyKbyX0JjKHqAftvqS8vx00LFn/5EaMdtB4= +github.com/NVIDIA/k8s-operator-libs v0.0.0-20260629200812-d720f2557494 h1:j+tWK79l9AouBulQps7rxILLhy2fWYcEhH4zgYjth/o= +github.com/NVIDIA/k8s-operator-libs v0.0.0-20260629200812-d720f2557494/go.mod h1:L+aiCiTKN63AX9SWz/F8pv9Jw9FIfI+dAEr7VA+KowE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= +github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/fxamacker/cbor/v2 v2.9.2 h1:X4Ksno9+x3cz0TZv69ec1hxP/+tymuR8PXQJyDwfh78= +github.com/fxamacker/cbor/v2 v2.9.2/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-openapi/swag v0.25.4 h1:OyUPUFYDPDBMkqyxOTkqDYFnrhuhi9NR6QVUvIochMU= +github.com/go-openapi/swag v0.25.4/go.mod h1:zNfJ9WZABGHCFg2RnY0S4IOkAcVTzJ6z2Bi+Q4i6qFQ= +github.com/go-openapi/swag/cmdutils v0.25.4 h1:8rYhB5n6WawR192/BfUu2iVlxqVR9aRgGJP6WaBoW+4= +github.com/go-openapi/swag/cmdutils v0.25.4/go.mod h1:pdae/AFo6WxLl5L0rq87eRzVPm/XRHM3MoYgRMvG4A0= +github.com/go-openapi/swag/conv v0.25.4 h1:/Dd7p0LZXczgUcC/Ikm1+YqVzkEeCc9LnOWjfkpkfe4= +github.com/go-openapi/swag/conv v0.25.4/go.mod h1:3LXfie/lwoAv0NHoEuY1hjoFAYkvlqI/Bn5EQDD3PPU= +github.com/go-openapi/swag/fileutils v0.25.4 h1:2oI0XNW5y6UWZTC7vAxC8hmsK/tOkWXHJQH4lKjqw+Y= +github.com/go-openapi/swag/fileutils v0.25.4/go.mod h1:cdOT/PKbwcysVQ9Tpr0q20lQKH7MGhOEb6EwmHOirUk= +github.com/go-openapi/swag/jsonname v0.25.4 h1:bZH0+MsS03MbnwBXYhuTttMOqk+5KcQ9869Vye1bNHI= +github.com/go-openapi/swag/jsonname v0.25.4/go.mod h1:GPVEk9CWVhNvWhZgrnvRA6utbAltopbKwDu8mXNUMag= +github.com/go-openapi/swag/jsonutils v0.25.4 h1:VSchfbGhD4UTf4vCdR2F4TLBdLwHyUDTd1/q4i+jGZA= +github.com/go-openapi/swag/jsonutils v0.25.4/go.mod h1:7OYGXpvVFPn4PpaSdPHJBtF0iGnbEaTk8AvBkoWnaAY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4 h1:IACsSvBhiNJwlDix7wq39SS2Fh7lUOCJRmx/4SN4sVo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.4/go.mod h1:Mt0Ost9l3cUzVv4OEZG+WSeoHwjWLnarzMePNDAOBiM= +github.com/go-openapi/swag/loading v0.25.4 h1:jN4MvLj0X6yhCDduRsxDDw1aHe+ZWoLjW+9ZQWIKn2s= +github.com/go-openapi/swag/loading v0.25.4/go.mod h1:rpUM1ZiyEP9+mNLIQUdMiD7dCETXvkkC30z53i+ftTE= +github.com/go-openapi/swag/mangling v0.25.4 h1:2b9kBJk9JvPgxr36V23FxJLdwBrpijI26Bx5JH4Hp48= +github.com/go-openapi/swag/mangling v0.25.4/go.mod h1:6dxwu6QyORHpIIApsdZgb6wBk/DPU15MdyYj/ikn0Hg= +github.com/go-openapi/swag/netutils v0.25.4 h1:Gqe6K71bGRb3ZQLusdI8p/y1KLgV4M/k+/HzVSqT8H0= +github.com/go-openapi/swag/netutils v0.25.4/go.mod h1:m2W8dtdaoX7oj9rEttLyTeEFFEBvnAx9qHd5nJEBzYg= +github.com/go-openapi/swag/stringutils v0.25.4 h1:O6dU1Rd8bej4HPA3/CLPciNBBDwZj9HiEpdVsb8B5A8= +github.com/go-openapi/swag/stringutils v0.25.4/go.mod h1:GTsRvhJW5xM5gkgiFe0fV3PUlFm0dr8vki6/VSRaZK0= +github.com/go-openapi/swag/typeutils v0.25.4 h1:1/fbZOUN472NTc39zpa+YGHn3jzHWhv42wAJSN91wRw= +github.com/go-openapi/swag/typeutils v0.25.4/go.mod h1:Ou7g//Wx8tTLS9vG0UmzfCsjZjKhpjxayRKTHXf2pTE= +github.com/go-openapi/swag/yamlutils v0.25.4 h1:6jdaeSItEUb7ioS9lFoCZ65Cne1/RZtPBZ9A56h92Sw= +github.com/go-openapi/swag/yamlutils v0.25.4/go.mod h1:MNzq1ulQu+yd8Kl7wPOut/YHAAU/H6hL91fF+E2RFwc= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2 h1:0+Y41Pz1NkbTHz8NngxTuAXxEodtNSI1WG1c/m5Akw4= +github.com/go-openapi/testify/enable/yaml/v2 v2.0.2/go.mod h1:kme83333GCtJQHXQ8UKX3IBZu6z8T5Dvy5+CW3NLUUg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFdJifH4BDsTlE89Zl93FEloxaWZfGcifgq8= +github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.93.1 h1:RP+/GISMkna7VpDx3wa52oYIyIjNU+iQxV6sDnY2uCA= +github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.93.1/go.mod h1:rZ+wRKDneCC/jJk24Mdb+6bAc6y/UjRliuMz6U20s6Y= +github.com/regclient/regclient v0.11.5 h1:OHRsXO0F3qHGfa4HEUv+EkMH9NXNcCTBKjNzyC/UhIA= +github.com/regclient/regclient v0.11.5/go.mod h1:DZUOfIT14WFTK2Pj4vjd93avy9O4Fdpjrf9ir23TbRE= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/objx v0.5.3 h1:jmXUvGomnU1o3W/V5h2VEradbpJDwGrzugQQvL0POH4= +github.com/stretchr/objx v0.5.3/go.mod h1:rDQraq+vQZU7Fde9LOZLr8Tax6zZvy4kuNKF+QYS+U0= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.12.0 h1:K6Mr6jO9JICuend/5xzTM03ydSV3vdNRYAdPSukj8uI= +github.com/stretchr/testify v1.12.0/go.mod h1:bOYBZb5qJ00vPzWfIqBUZPaxK8jWiXc6d3ErP4Ca9Gw= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +go.yaml.in/yaml/v2 v2.4.4 h1:tuyd0P+2Ont/d6e2rl3be67goVK4R6deVxCUX5vyPaQ= +go.yaml.in/yaml/v2 v2.4.4/go.mod h1:gMZqIpDtDqOfM0uNfy0SkpRhvUryYH0Z6wdMYcacYXQ= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/mod v0.40.0 h1:hUv+3cXcdRHz08UmSiOob7sadHig73uo5bkXxQ/tvUs= +golang.org/x/mod v0.40.0/go.mod h1:0/weTWkPWGBikyTWAX3dkjVztMmBA5hM0DH6BElSupE= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= +golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= +golang.org/x/text v0.39.0 h1:UbZz4pLOvn600D6Oh6GGEI6VAmndrEBLv8/6BEXzyus= +golang.org/x/text v0.39.0/go.mod h1:3UwRclnC2g0TU9x8PZiyfOajCd1zaUNHF9cvqcQZ+ZM= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.13.0 h1:czT3CmqEaQ1aanPc5SdlgQrrEIb8w/wwCvWWnfEbYzo= +gopkg.in/evanphx/json-patch.v4 v4.13.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.36.4 h1:RxrvqCL6vgH5/+UnTeu1IIFqYmGfy0hnyrod1rn35Oo= +k8s.io/api v0.36.4/go.mod h1:S2B3orCFBDhrgyWbLeuKcT2QdHIpQesBkCYSlWtwUOw= +k8s.io/apimachinery v0.36.4 h1:PT2UzkupGuAx/+xT5XjiMJ1WGpY3fn9/hdAvjweRet4= +k8s.io/apimachinery v0.36.4/go.mod h1:p2I2dipt7JHG+quVwQ1d02d28O4GdDi77RByQ13MTpk= +k8s.io/client-go v0.36.4 h1:MDvfDNvMSt0Br94SK8neviVlwL9qifw9B26hJCpD1K0= +k8s.io/client-go v0.36.4/go.mod h1:pNK4WKELbwlEDvtbE8l22lEZL5THYF61H5EealokZmA= +k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= +k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= +k8s.io/kube-openapi v0.0.0-20260603220949-865597e52e25 h1:mPMaPMpBij2V1Wv/fR+HW124vVGXXvOSS9ver/9yjWs= +k8s.io/kube-openapi v0.0.0-20260603220949-865597e52e25/go.mod h1:V/QaCUYDa+0QpcHhVVc5l99Uz56wEMEXBSj9oCDkNDY= +k8s.io/utils v0.0.0-20260507154919-ff6756f316d2 h1:wU4tMEhLGgIbLvXQb1cfN+EcM0wf7zC6CPF+C79jroc= +k8s.io/utils v0.0.0-20260507154919-ff6756f316d2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= +sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= +sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= +sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/structured-merge-diff/v6 v6.4.0 h1:qmp2e3ZfFi1/jJbDGpD4mt3wyp6PE1NfKHCYLqgNQJo= +sigs.k8s.io/structured-merge-diff/v6 v6.4.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= +sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= +sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/internal/image/image.go b/api/image/image.go similarity index 100% rename from internal/image/image.go rename to api/image/image.go diff --git a/internal/image/imagepath_validation_test.go b/api/image/imagepath_validation_test.go similarity index 100% rename from internal/image/imagepath_validation_test.go rename to api/image/imagepath_validation_test.go diff --git a/api/nvidia/v1alpha1/nvidiadriver_types.go b/api/nvidia/v1alpha1/nvidiadriver_types.go index 70aa59b0ff..425f9ce809 100644 --- a/api/nvidia/v1alpha1/nvidiadriver_types.go +++ b/api/nvidia/v1alpha1/nvidiadriver_types.go @@ -28,12 +28,17 @@ import ( upgrade_v1alpha1 "github.com/NVIDIA/k8s-operator-libs/api/upgrade/v1alpha1" - "github.com/NVIDIA/gpu-operator/internal/consts" - "github.com/NVIDIA/gpu-operator/internal/image" + "github.com/NVIDIA/gpu-operator/api/image" ) const ( NVIDIADriverCRDName = "NVIDIADriver" + + // NVIDIADriverOwnerLabel is an operator-managed node label used to route each GPU node to one NVIDIADriver. + NVIDIADriverOwnerLabel = "nvidia.com/gpu-operator.driver.owner" + + // MinimumGDSVersionForOpenRM indicates the minimum GDS version that is supported only with OpenRM driver + MinimumGDSVersionForOpenRM = "v2.17.5" ) // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! @@ -560,8 +565,8 @@ func (d *NVIDIADriver) ValidateNodeSelector() error { if d.IsDefault() && len(d.Spec.NodeSelector) > 0 { return fmt.Errorf("default NVIDIADriver %q cannot use nodeSelector", d.Name) } - if _, ok := d.Spec.NodeSelector[consts.NVIDIADriverOwnerLabel]; ok { - return fmt.Errorf("NVIDIADriver %q nodeSelector cannot use reserved label %q", d.Name, consts.NVIDIADriverOwnerLabel) + if _, ok := d.Spec.NodeSelector[NVIDIADriverOwnerLabel]; ok { + return fmt.Errorf("NVIDIADriver %q nodeSelector cannot use reserved label %q", d.Name, NVIDIADriverOwnerLabel) } return nil } @@ -734,7 +739,7 @@ func (d *NVIDIADriverSpec) IsOpenKernelModulesRequired() bool { if !strings.HasPrefix(gdsVersion, "v") { gdsVersion = fmt.Sprintf("v%s", gdsVersion) } - if semver.Compare(gdsVersion, consts.MinimumGDSVersionForOpenRM) >= 0 { + if semver.Compare(gdsVersion, MinimumGDSVersionForOpenRM) >= 0 { return true } return false diff --git a/controllers/clusterpolicy_controller.go b/controllers/clusterpolicy_controller.go index b6fde47516..89f67c0ac6 100644 --- a/controllers/clusterpolicy_controller.go +++ b/controllers/clusterpolicy_controller.go @@ -46,7 +46,6 @@ import ( gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" "github.com/NVIDIA/gpu-operator/internal/conditions" - "github.com/NVIDIA/gpu-operator/internal/consts" ) const ( @@ -289,7 +288,7 @@ func clusterPolicyNotReadyMessage(statesNotReady, notReadyReasons []string) stri // nvidiaDriverUpgradeIncomplete reports whether any NVIDIADriver-owned Node has a pending, active, or failed upgrade. func (r *ClusterPolicyReconciler) nvidiaDriverUpgradeIncomplete(ctx context.Context) (bool, error) { nodes := &corev1.NodeList{} - if err := r.List(ctx, nodes, client.HasLabels{consts.NVIDIADriverOwnerLabel}); err != nil { + if err := r.List(ctx, nodes, client.HasLabels{nvidiav1alpha1.NVIDIADriverOwnerLabel}); err != nil { return false, fmt.Errorf("failed to list nodes for NVIDIADriver upgrade state: %w", err) } @@ -432,7 +431,7 @@ func addWatchNewGPUNode(r *ClusterPolicyReconciler, c controller.Controller, mgr // driverUpgradeLabelsChanged reports Node label changes that affect aggregate // NVIDIADriver rollout status. func driverUpgradeLabelsChanged(oldLabels, newLabels map[string]string) (bool, bool, bool) { - return oldLabels[consts.NVIDIADriverOwnerLabel] != newLabels[consts.NVIDIADriverOwnerLabel], + return oldLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel] != newLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel], oldLabels[upgrade.GetUpgradeStateLabelKey()] != newLabels[upgrade.GetUpgradeStateLabelKey()], oldLabels[upgrade.GetUpgradeSkipNodeLabelKey()] != newLabels[upgrade.GetUpgradeSkipNodeLabelKey()] } @@ -441,7 +440,7 @@ func driverUpgradeLabelsChanged(oldLabels, newLabels map[string]string) (bool, b // can affect ClusterPolicy rendering or aggregate NVIDIADriver upgrade status. func shouldReconcileClusterPolicyOnNodeDeletion(labels map[string]string) bool { _, hasOSTreeLabel := labels[nfdOSTreeVersionLabelKey] - return (hasGPULabels(labels) && hasOSTreeLabel) || labels[consts.NVIDIADriverOwnerLabel] != "" + return (hasGPULabels(labels) && hasOSTreeLabel) || labels[nvidiav1alpha1.NVIDIADriverOwnerLabel] != "" } // SetupWithManager sets up the controller with the Manager. diff --git a/controllers/clusterpolicy_controller_test.go b/controllers/clusterpolicy_controller_test.go index da81bcfc61..db417d4026 100644 --- a/controllers/clusterpolicy_controller_test.go +++ b/controllers/clusterpolicy_controller_test.go @@ -35,7 +35,6 @@ import ( gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" - gpuconsts "github.com/NVIDIA/gpu-operator/internal/consts" ) func TestIsIncompleteDriverUpgradeState(t *testing.T) { @@ -138,8 +137,8 @@ func TestNVIDIADriverUpgradeIncomplete(t *testing.T) { name: "active upgrade state on NVIDIADriver-owned node", nodes: []client.Object{ nodeWithLabels("gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "default", - upgradeStateLabel: upgrade.UpgradeStatePodRestartRequired, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "default", + upgradeStateLabel: upgrade.UpgradeStatePodRestartRequired, }), }, expected: true, @@ -148,12 +147,12 @@ func TestNVIDIADriverUpgradeIncomplete(t *testing.T) { name: "pending upgrade keeps rollout in progress after another node completes", nodes: []client.Object{ nodeWithLabels("upgraded-gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "default", - upgradeStateLabel: upgrade.UpgradeStateDone, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "default", + upgradeStateLabel: upgrade.UpgradeStateDone, }), nodeWithLabels("pending-gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "default", - upgradeStateLabel: upgrade.UpgradeStateUpgradeRequired, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "default", + upgradeStateLabel: upgrade.UpgradeStateUpgradeRequired, }), }, expected: true, @@ -171,8 +170,8 @@ func TestNVIDIADriverUpgradeIncomplete(t *testing.T) { name: "failed upgrade state keeps rollout incomplete", nodes: []client.Object{ nodeWithLabels("gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "default", - upgradeStateLabel: upgrade.UpgradeStateFailed, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "default", + upgradeStateLabel: upgrade.UpgradeStateFailed, }), }, expected: true, @@ -181,8 +180,8 @@ func TestNVIDIADriverUpgradeIncomplete(t *testing.T) { name: "completed upgrade state is not treated as in progress", nodes: []client.Object{ nodeWithLabels("gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "default", - upgradeStateLabel: upgrade.UpgradeStateDone, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "default", + upgradeStateLabel: upgrade.UpgradeStateDone, }), }, expected: false, @@ -191,9 +190,9 @@ func TestNVIDIADriverUpgradeIncomplete(t *testing.T) { name: "skipped node is excluded from the upgrade aggregate", nodes: []client.Object{ nodeWithLabels("skipped-gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "default", - upgradeStateLabel: upgrade.UpgradeStateUpgradeRequired, - upgrade.GetUpgradeSkipNodeLabelKey(): "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "default", + upgradeStateLabel: upgrade.UpgradeStateUpgradeRequired, + upgrade.GetUpgradeSkipNodeLabelKey(): "true", }), }, expected: false, @@ -237,8 +236,8 @@ func TestDriverUpgradeLabelsChanged(t *testing.T) { }{ { name: "driver ownership changes", - oldLabels: map[string]string{gpuconsts.NVIDIADriverOwnerLabel: "old-driver"}, - newLabels: map[string]string{gpuconsts.NVIDIADriverOwnerLabel: "new-driver"}, + oldLabels: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "old-driver"}, + newLabels: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "new-driver"}, ownerChanged: true, }, { @@ -274,7 +273,7 @@ func TestShouldReconcileClusterPolicyOnNodeDeletion(t *testing.T) { { name: "NVIDIADriver-owned node", labels: map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "driver-a", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", }, expected: true, }, @@ -298,8 +297,8 @@ func TestClusterPolicyReconcileDriverUpgradeTransitions(t *testing.T) { upgradeStateLabel := upgrade.GetUpgradeStateLabelKey() cp := clusterPolicyForUpgradeTest(true) node := nodeWithLabels("gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "driver-a", - upgradeStateLabel: upgrade.UpgradeStateDone, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + upgradeStateLabel: upgrade.UpgradeStateDone, }) r, c, _ := newClusterPolicyUpgradeTestReconciler(t, cp, node) @@ -349,8 +348,8 @@ func TestClusterPolicyReconcileBecomesReadyAfterIncompleteNodeDeletion(t *testin upgradeStateLabel := upgrade.GetUpgradeStateLabelKey() cp := clusterPolicyForUpgradeTest(true) node := nodeWithLabels("failed-gpu-node", map[string]string{ - gpuconsts.NVIDIADriverOwnerLabel: "driver-a", - upgradeStateLabel: upgrade.UpgradeStateFailed, + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + upgradeStateLabel: upgrade.UpgradeStateFailed, }) r, c, _ := newClusterPolicyUpgradeTestReconciler(t, cp, node) request := ctrl.Request{NamespacedName: client.ObjectKeyFromObject(cp)} @@ -372,8 +371,8 @@ func TestClusterPolicyReconcileDriverUpgradeFailureCases(t *testing.T) { t.Run("one failed driver among multiple drivers keeps ClusterPolicy not ready", func(t *testing.T) { cp := clusterPolicyForUpgradeTest(true) r, c, _ := newClusterPolicyUpgradeTestReconciler(t, cp, - nodeWithLabels("completed", map[string]string{gpuconsts.NVIDIADriverOwnerLabel: "driver-a", upgradeStateLabel: upgrade.UpgradeStateDone}), - nodeWithLabels("failed", map[string]string{gpuconsts.NVIDIADriverOwnerLabel: "driver-b", upgradeStateLabel: upgrade.UpgradeStateFailed}), + nodeWithLabels("completed", map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", upgradeStateLabel: upgrade.UpgradeStateDone}), + nodeWithLabels("failed", map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-b", upgradeStateLabel: upgrade.UpgradeStateFailed}), ) result, err := r.Reconcile(t.Context(), ctrl.Request{NamespacedName: client.ObjectKeyFromObject(cp)}) @@ -385,7 +384,7 @@ func TestClusterPolicyReconcileDriverUpgradeFailureCases(t *testing.T) { t.Run("legacy driver management ignores upgrade labels", func(t *testing.T) { cp := clusterPolicyForUpgradeTest(false) r, c, _ := newClusterPolicyUpgradeTestReconciler(t, cp, - nodeWithLabels("failed", map[string]string{gpuconsts.NVIDIADriverOwnerLabel: "driver-a", upgradeStateLabel: upgrade.UpgradeStateFailed}), + nodeWithLabels("failed", map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", upgradeStateLabel: upgrade.UpgradeStateFailed}), ) _, err := r.Reconcile(t.Context(), ctrl.Request{NamespacedName: client.ObjectKeyFromObject(cp)}) @@ -397,7 +396,7 @@ func TestClusterPolicyReconcileDriverUpgradeFailureCases(t *testing.T) { cp := clusterPolicyForUpgradeTest(true) calls := 0 r, _, metrics := newClusterPolicyUpgradeTestReconciler(t, cp, - nodeWithLabels("failed", map[string]string{gpuconsts.NVIDIADriverOwnerLabel: "driver-a", upgradeStateLabel: upgrade.UpgradeStateFailed}), + nodeWithLabels("failed", map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", upgradeStateLabel: upgrade.UpgradeStateFailed}), ) clusterPolicyCtrl.controls = []controlFunc{{func(ClusterPolicyController) (gpuv1.State, error) { calls++ diff --git a/controllers/nodelabeling_controller.go b/controllers/nodelabeling_controller.go index 7b40b398b8..0f96567cdd 100644 --- a/controllers/nodelabeling_controller.go +++ b/controllers/nodelabeling_controller.go @@ -121,7 +121,7 @@ func getNodeLabelUpdateReasons(oldLabels, newLabels map[string]string) nodeLabel gpuWorkloadConfigChanged: oldGPUWorkloadConfig != newGPUWorkloadConfig, migCapableLabelChanged: hasMIGCapableGPU(oldLabels) != hasMIGCapableGPU(newLabels), osTreeLabelChanged: oldLabels[nfdOSTreeVersionLabelKey] != newLabels[nfdOSTreeVersionLabelKey], - nvidiaDriverOwnerLabelChange: oldLabels[consts.NVIDIADriverOwnerLabel] != newLabels[consts.NVIDIADriverOwnerLabel], + nvidiaDriverOwnerLabelChange: oldLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel] != newLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel], } } @@ -499,7 +499,7 @@ func (nlc *nodeLabelingController) applyDriverAutoUpgradeAnnotationForNVD(ctx co for _, nvd := range nvidiaDriverList.Items { nodeList := &corev1.NodeList{} - if err := nlc.client.List(ctx, nodeList, client.MatchingLabels{consts.NVIDIADriverOwnerLabel: nvd.Name}); err != nil { + if err := nlc.client.List(ctx, nodeList, client.MatchingLabels{nvidiav1alpha1.NVIDIADriverOwnerLabel: nvd.Name}); err != nil { nlc.logger.Error(err, "Failed to list nodes for NVIDIADriver", "name", nvd.Name) return err } @@ -571,14 +571,14 @@ func (nlc *nodeLabelingController) labelNodesWithOrphanedDriverPods(ctx context. // nodeOwnedByNVIDIADriver returns true when the node has an owner label matching a live NVIDIADriver. func nodeOwnedByNVIDIADriver(node *corev1.Node, nvidiaDrivers []nvidiav1alpha1.NVIDIADriver) bool { - if node.Labels == nil || node.Labels[consts.NVIDIADriverOwnerLabel] == "" { + if node.Labels == nil || node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel] == "" { return false } for _, nvidiaDriver := range nvidiaDrivers { if nvidiaDriver.HasDeletionTimestamp() { continue } - if node.Labels[consts.NVIDIADriverOwnerLabel] == nvidiaDriver.Name { + if node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel] == nvidiaDriver.Name { return true } } @@ -693,8 +693,8 @@ func (r *NodeLabelingReconciler) SetupWithManager(ctx context.Context, mgr ctrl. // When an NVIDIADriver daemonset pod is running on the node, check if any // label which is configured in the NVIDIADriver's node selector has changed. nvidiaDriverNodeSelectorLabelChanged := false - if !needsUpdate && newLabels[consts.NVIDIADriverOwnerLabel] != "" { - name := newLabels[consts.NVIDIADriverOwnerLabel] + if !needsUpdate && newLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel] != "" { + name := newLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel] nvidiaDriver := &nvidiav1alpha1.NVIDIADriver{} err := r.Get(ctx, types.NamespacedName{Name: name}, nvidiaDriver) if err != nil { diff --git a/controllers/nodelabeling_controller_test.go b/controllers/nodelabeling_controller_test.go index affe51fe5a..5fa23dfd60 100644 --- a/controllers/nodelabeling_controller_test.go +++ b/controllers/nodelabeling_controller_test.go @@ -104,14 +104,14 @@ func TestNodeLabelingReconcileDefersDependentOperationsAfterGPULabelChanges(t *t updatedNode := &corev1.Node{} require.NoError(t, fakeClient.Get(ctx, types.NamespacedName{Name: "gpu-node"}, updatedNode)) assert.Equal(t, commonGPULabelValue, updatedNode.Labels[commonGPULabelKey]) - assert.NotContains(t, updatedNode.Labels, consts.NVIDIADriverOwnerLabel) + assert.NotContains(t, updatedNode.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) result, err = reconciler.Reconcile(ctx, reconcile.Request{}) require.NoError(t, err) assert.Zero(t, result.RequeueAfter) require.NoError(t, fakeClient.Get(ctx, types.NamespacedName{Name: "gpu-node"}, updatedNode)) - assert.Equal(t, consts.DefaultNVIDIADriverName, updatedNode.Labels[consts.NVIDIADriverOwnerLabel]) + assert.Equal(t, consts.DefaultNVIDIADriverName, updatedNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestNodeLabelingReconcileDoesNotDeferDependentOperationsForStateLabelChanges(t *testing.T) { @@ -162,7 +162,7 @@ func TestNodeLabelingReconcileDoesNotDeferDependentOperationsForStateLabelChange updatedNode := &corev1.Node{} require.NoError(t, fakeClient.Get(ctx, types.NamespacedName{Name: "gpu-node"}, updatedNode)) assert.Equal(t, "true", updatedNode.Labels["nvidia.com/gpu.deploy.driver"]) - assert.Equal(t, consts.DefaultNVIDIADriverName, updatedNode.Labels[consts.NVIDIADriverOwnerLabel]) + assert.Equal(t, consts.DefaultNVIDIADriverName, updatedNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestNodeLabelUpdateReasonsDetectsLabelChanges(t *testing.T) { @@ -902,7 +902,7 @@ func TestApplyDriverAutoUpgradeAnnotationNoClusterPolicy(t *testing.T) { } owned := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "owned-node", - Labels: map[string]string{consts.NVIDIADriverOwnerLabel: "gpu-driver"}, + Labels: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "gpu-driver"}, }} unowned := &corev1.Node{ObjectMeta: metav1.ObjectMeta{Name: "unowned-node"}} @@ -934,7 +934,7 @@ func TestLabelNodesWithOrphanedDriverPods(t *testing.T) { // ownedNode returns a node that carries the NVIDIADriverOwnerLabel for driverName // and optionally an upgrade state label. ownedNode := func(name, upgradeState string) *corev1.Node { - labels := map[string]string{consts.NVIDIADriverOwnerLabel: driverName} + labels := map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: driverName} if upgradeState != "" { labels[upgradeStateLabel] = upgradeState } diff --git a/controllers/object_controls_test.go b/controllers/object_controls_test.go index 9c1bc9c7dd..a5a7509fc9 100644 --- a/controllers/object_controls_test.go +++ b/controllers/object_controls_test.go @@ -52,7 +52,6 @@ import ( gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" - "github.com/NVIDIA/gpu-operator/internal/consts" ) const ( @@ -337,8 +336,8 @@ func TestLabelNodesWithOrphanedDriverPodsRequestsUpgradeOnlyForOwnedAllowedState ObjectMeta: metav1.ObjectMeta{ Name: "node-without-upgrade-state", Labels: map[string]string{ - "gpu": "true", - consts.NVIDIADriverOwnerLabel: driverName, + "gpu": "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: driverName, }, }, } @@ -346,9 +345,9 @@ func TestLabelNodesWithOrphanedDriverPodsRequestsUpgradeOnlyForOwnedAllowedState ObjectMeta: metav1.ObjectMeta{ Name: "node-with-done-state", Labels: map[string]string{ - "gpu": "true", - consts.NVIDIADriverOwnerLabel: driverName, - upgradeStateLabel: upgrade.UpgradeStateDone, + "gpu": "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: driverName, + upgradeStateLabel: upgrade.UpgradeStateDone, }, }, } @@ -356,9 +355,9 @@ func TestLabelNodesWithOrphanedDriverPodsRequestsUpgradeOnlyForOwnedAllowedState ObjectMeta: metav1.ObjectMeta{ Name: "node-with-active-state", Labels: map[string]string{ - "gpu": "true", - consts.NVIDIADriverOwnerLabel: driverName, - upgradeStateLabel: upgrade.UpgradeStatePodRestartRequired, + "gpu": "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: driverName, + upgradeStateLabel: upgrade.UpgradeStatePodRestartRequired, }, }, } @@ -366,9 +365,9 @@ func TestLabelNodesWithOrphanedDriverPodsRequestsUpgradeOnlyForOwnedAllowedState ObjectMeta: metav1.ObjectMeta{ Name: "node-with-failed-state", Labels: map[string]string{ - "gpu": "true", - consts.NVIDIADriverOwnerLabel: driverName, - upgradeStateLabel: upgrade.UpgradeStateFailed, + "gpu": "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: driverName, + upgradeStateLabel: upgrade.UpgradeStateFailed, }, }, } @@ -427,7 +426,7 @@ func TestLabelNodesWithOrphanedDriverPodsReturnsPatchError(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "node-with-orphaned-pod", Labels: map[string]string{ - consts.NVIDIADriverOwnerLabel: driverName, + nvidiav1alpha1.NVIDIADriverOwnerLabel: driverName, }, }, } diff --git a/controllers/upgrade_controller.go b/controllers/upgrade_controller.go index ee67882059..15ba4fe89f 100644 --- a/controllers/upgrade_controller.go +++ b/controllers/upgrade_controller.go @@ -45,7 +45,6 @@ import ( gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" - gpuconsts "github.com/NVIDIA/gpu-operator/internal/consts" ) // UpgradeReconciler reconciles Driver Daemon Sets for upgrade @@ -240,7 +239,7 @@ func (r *UpgradeReconciler) reconcileNVIDIADriverUpgrades(ctx context.Context, r statesByNVD := make(map[string]*upgrade.ClusterUpgradeState) for stateKey, nodeStates := range clusterState.NodeStates { for _, nodeState := range nodeStates { - ownerName := nodeState.Node.Labels[gpuconsts.NVIDIADriverOwnerLabel] + ownerName := nodeState.Node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel] if ownerName == "" { reqLogger.V(consts.LogLevelInfo).Info("Node does not have nvidia.com/gpu-operator.driver.owner label, skipping ...", "NodeName", nodeState.Node.Name) continue @@ -355,7 +354,7 @@ func (r *UpgradeReconciler) removeNodeUpgradeStateLabelsForNVD(ctx context.Conte r.Log.Info("Resetting node upgrade labels for NVIDIADriver", "name", nvdName) nodeList := &corev1.NodeList{} - if err := r.List(ctx, nodeList, client.MatchingLabels{gpuconsts.NVIDIADriverOwnerLabel: nvdName}); err != nil { + if err := r.List(ctx, nodeList, client.MatchingLabels{nvidiav1alpha1.NVIDIADriverOwnerLabel: nvdName}); err != nil { r.Log.Error(err, "Failed to list nodes for NVIDIADriver", "name", nvdName) return err } diff --git a/controllers/upgrade_controller_test.go b/controllers/upgrade_controller_test.go index 07c8ed8aba..08a2ff23c7 100644 --- a/controllers/upgrade_controller_test.go +++ b/controllers/upgrade_controller_test.go @@ -38,7 +38,6 @@ import ( gpuv1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" - gpuconsts "github.com/NVIDIA/gpu-operator/internal/consts" ) func TestSetDrainSpecPodSelector(t *testing.T) { @@ -219,7 +218,7 @@ func nodeWithUpgradeState(name, owner string) *corev1.Node { Labels: map[string]string{upgrade.GetUpgradeStateLabelKey(): "upgrade-required"}, }} if owner != "" { - node.Labels[gpuconsts.NVIDIADriverOwnerLabel] = owner + node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel] = owner } return node } diff --git a/go.mod b/go.mod index ad0bebe8b7..5692a8be09 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.26.3 require ( github.com/Masterminds/sprig/v3 v3.3.0 github.com/NVIDIA/go-nvlib v0.12.0 - github.com/NVIDIA/k8s-kata-manager v0.2.3 + github.com/NVIDIA/gpu-operator/api v0.2603.3 github.com/NVIDIA/k8s-operator-libs v0.0.0-20260629200812-d720f2557494 github.com/NVIDIA/nvidia-container-toolkit v1.20.0 github.com/cyphar/filepath-securejoin v0.7.0 @@ -44,6 +44,7 @@ require ( github.com/Masterminds/goutils v1.1.1 // indirect github.com/Masterminds/semver/v3 v3.5.0 // indirect github.com/Mellanox/maintenance-operator/api v0.3.0 // indirect + github.com/NVIDIA/k8s-kata-manager v0.2.3 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -131,3 +132,5 @@ require ( sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v6 v6.4.0 // indirect ) + +replace github.com/NVIDIA/gpu-operator/api => ./api diff --git a/hack/validate-api-version-unpublished.sh b/hack/validate-api-version-unpublished.sh new file mode 100644 index 0000000000..56e87aaa3e --- /dev/null +++ b/hack/validate-api-version-unpublished.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +# Copyright NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +set -euo pipefail + +API_MODULE="github.com/NVIDIA/gpu-operator/api" +UPSTREAM_REPOSITORY="${1:-https://github.com/NVIDIA/gpu-operator.git}" + +api_version="$(go list -m -f '{{.Version}}' "${API_MODULE}")" +if [[ ! "${api_version}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-].*)?$ ]]; then + printf 'ERROR: %s has invalid version %q in go.mod\n' \ + "${API_MODULE}" "${api_version}" >&2 + exit 1 +fi + +api_tag="api/${api_version}" +if output="$(git ls-remote --exit-code --tags "${UPSTREAM_REPOSITORY}" "refs/tags/${api_tag}" 2>&1)"; then + printf 'ERROR: release PR references existing API tag %s\n' "${api_tag}" >&2 + [[ -n "${output}" ]] && printf '%s\n' "${output}" >&2 + exit 1 +else + status=$? + if (( status != 2 )); then + printf 'ERROR: could not query %s for tag %s\n%s\n' \ + "${UPSTREAM_REPOSITORY}" "${api_tag}" "${output}" >&2 + exit "${status}" + fi +fi + +printf 'API version %s is available for release\n' "${api_version}" diff --git a/hack/validate-published-api-module.sh b/hack/validate-published-api-module.sh new file mode 100644 index 0000000000..b0bf5fae7a --- /dev/null +++ b/hack/validate-published-api-module.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +# Copyright NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +set -euo pipefail + +API_MODULE="github.com/NVIDIA/gpu-operator/api" +OPERATOR_TAG="${1:-${GITHUB_REF_NAME:-}}" +UPSTREAM_REPOSITORY="${2:-https://github.com/NVIDIA/gpu-operator.git}" + +if [[ ! "${OPERATOR_TAG}" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then + printf 'ERROR: operator tag %q does not match vX.Y.Z\n' "${OPERATOR_TAG}" >&2 + exit 1 +fi + +operator_major="${BASH_REMATCH[1]}" +operator_minor="$((10#${BASH_REMATCH[2]}))" +operator_patch="${BASH_REMATCH[3]}" +printf -v expected_api_version 'v0.%s%02d.%s' \ + "${operator_major}" "${operator_minor}" "${operator_patch}" + +required_api_version="$(go list -m -f '{{.Version}}' "${API_MODULE}")" +if [[ "${required_api_version}" != "${expected_api_version}" ]]; then + printf 'ERROR: %s maps to %s, but go.mod requires %s\n' \ + "${OPERATOR_TAG}" "${expected_api_version}" "${required_api_version}" >&2 + exit 1 +fi + +operator_commit="$(git rev-parse HEAD)" +operator_tag_commit="$(git rev-parse "${OPERATOR_TAG}^{commit}")" +if [[ "${operator_tag_commit}" != "${operator_commit}" ]]; then + printf 'ERROR: %s points to %s, but HEAD is %s\n' \ + "${OPERATOR_TAG}" "${operator_tag_commit}" "${operator_commit}" >&2 + exit 1 +fi + +api_tag="api/${expected_api_version}" +tag_refs="$(git ls-remote --tags "${UPSTREAM_REPOSITORY}" \ + "refs/tags/${api_tag}" "refs/tags/${api_tag}^{}")" +if [[ -z "${tag_refs}" ]]; then + printf 'ERROR: API tag %s does not exist in %s\n' \ + "${api_tag}" "${UPSTREAM_REPOSITORY}" >&2 + exit 1 +fi + +api_commit="$(awk ' + /\^\{\}$/ { + print $1 + found = 1 + exit + } + !found { + commit = $1 + } + END { + if (!found) print commit + } +' <<< "${tag_refs}")" +if [[ "${api_commit}" != "${operator_commit}" ]]; then + printf 'ERROR: %s points to %s, but %s points to %s\n' \ + "${api_tag}" "${api_commit}" "${OPERATOR_TAG}" "${operator_commit}" >&2 + exit 1 +fi + +tmpdir="$(mktemp -d)" +trap 'rm -rf "${tmpdir}"' EXIT + +( + cd "${tmpdir}" + go mod init module-validation >/dev/null + resolved_version="$( + GOPROXY=direct GONOSUMDB="${API_MODULE}" \ + go list -m -f '{{.Version}}' "${API_MODULE}@${expected_api_version}" + )" + if [[ "${resolved_version}" != "${expected_api_version}" ]]; then + printf 'ERROR: downloaded API module resolved to %s instead of %s\n' \ + "${resolved_version}" "${expected_api_version}" >&2 + exit 1 + fi +) + +binary="${tmpdir}/gpu-operator" +CGO_ENABLED=0 GOOS=linux go build -o "${binary}" ./cmd/gpu-operator +metadata="$(go version -m "${binary}")" + +if ! awk -v module="${API_MODULE}" -v version="${expected_api_version}" ' + $1 == "dep" && $2 == module && $3 == version { + found = 1 + } + END { + exit !found + } +' <<< "${metadata}"; then + printf 'ERROR: operator binary does not record %s %s\n%s\n' \ + "${API_MODULE}" "${expected_api_version}" "${metadata}" >&2 + exit 1 +fi + +if ! grep -Fq "vcs.revision=${operator_commit}" <<< "${metadata}"; then + printf 'ERROR: operator binary does not record release commit %s\n%s\n' \ + "${operator_commit}" "${metadata}" >&2 + exit 1 +fi + +printf '%s and %s are published from %s with valid module metadata\n' \ + "${OPERATOR_TAG}" "${api_tag}" "${operator_commit}" diff --git a/hack/validate-shared-dependencies.sh b/hack/validate-shared-dependencies.sh new file mode 100644 index 0000000000..c15b595524 --- /dev/null +++ b/hack/validate-shared-dependencies.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash +# Copyright NVIDIA CORPORATION +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. + +set -euo pipefail + +export LC_ALL=C + +ROOT_MODFILE="${1:-go.mod}" +API_MODFILE="${2:-api/go.mod}" + +for modfile in "${ROOT_MODFILE}" "${API_MODFILE}"; do + if [[ ! -f "${modfile}" ]]; then + printf 'ERROR: module file %s does not exist\n' "${modfile}" >&2 + exit 1 + fi +done + +tmpdir="$(mktemp -d)" +trap 'rm -rf "${tmpdir}"' EXIT + +direct_requirements() { + awk ' + $1 == "require" && $2 == "(" { + in_require = 1 + next + } + in_require && $1 == ")" { + in_require = 0 + next + } + in_require && $0 !~ /\/\/ indirect/ { + print $1, $2 + next + } + $1 == "require" && $2 != "(" && $0 !~ /\/\/ indirect/ { + print $2, $3 + } + ' "$1" | LC_ALL=C sort +} + +direct_requirements "${ROOT_MODFILE}" > "${tmpdir}/root" +direct_requirements "${API_MODFILE}" > "${tmpdir}/api" +join "${tmpdir}/root" "${tmpdir}/api" > "${tmpdir}/shared" + +shared_count=0 +mismatch_count=0 +while read -r module root_version api_version; do + [[ -z "${module}" ]] && continue + shared_count=$((shared_count + 1)) + if [[ "${root_version}" != "${api_version}" ]]; then + printf 'ERROR: %s has different direct dependency versions: root=%s api=%s\n' \ + "${module}" "${root_version}" "${api_version}" >&2 + mismatch_count=$((mismatch_count + 1)) + fi +done < "${tmpdir}/shared" + +if (( shared_count == 0 )); then + printf 'ERROR: root and API modules have no shared direct dependencies\n' >&2 + exit 1 +fi + +if (( mismatch_count > 0 )); then + printf 'ERROR: %d shared direct dependency version(s) are out of sync\n' \ + "${mismatch_count}" >&2 + exit 1 +fi + +printf 'All %d shared direct dependencies are in sync\n' "${shared_count}" diff --git a/internal/consts/consts.go b/internal/consts/consts.go index f28c507942..5bb61c2e26 100644 --- a/internal/consts/consts.go +++ b/internal/consts/consts.go @@ -67,9 +67,4 @@ const ( // DefaultNVIDIADriverName is the Helm-managed fallback NVIDIADriver. DefaultNVIDIADriverName = "default" - // NVIDIADriverOwnerLabel is an operator-managed node label used to route each GPU node to one NVIDIADriver. - NVIDIADriverOwnerLabel = "nvidia.com/gpu-operator.driver.owner" - - // MinimumGDSVersionForOpenRM indicates the minimum GDS version that is supported only with OpenRM driver - MinimumGDSVersionForOpenRM = "v2.17.5" ) diff --git a/internal/nvidiadriver/nvidiadriver.go b/internal/nvidiadriver/nvidiadriver.go index 06fa8ab6cf..349c3d6438 100644 --- a/internal/nvidiadriver/nvidiadriver.go +++ b/internal/nvidiadriver/nvidiadriver.go @@ -79,12 +79,12 @@ func AssignOwners(ctx context.Context, c client.Client) (bool, error) { originalNode := node.DeepCopy() if desiredOwner == "" { - delete(node.Labels, consts.NVIDIADriverOwnerLabel) + delete(node.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) } else { if node.Labels == nil { node.Labels = map[string]string{} } - node.Labels[consts.NVIDIADriverOwnerLabel] = desiredOwner + node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel] = desiredOwner } if err := c.Patch(ctx, node, client.MergeFrom(originalNode)); err != nil { @@ -151,7 +151,7 @@ func desiredOwnerForNode( // ownerLabelNeedsUpdate reports whether the node owner label differs from the desired owner. func ownerLabelNeedsUpdate(nodeLabels map[string]string, desiredOwner string) bool { - currentOwner, hasOwnerLabel := nodeLabels[consts.NVIDIADriverOwnerLabel] + currentOwner, hasOwnerLabel := nodeLabels[nvidiav1alpha1.NVIDIADriverOwnerLabel] if desiredOwner == "" { return hasOwnerLabel } diff --git a/internal/nvidiadriver/nvidiadriver_errors_test.go b/internal/nvidiadriver/nvidiadriver_errors_test.go index 98f6f11751..7901f4e80e 100644 --- a/internal/nvidiadriver/nvidiadriver_errors_test.go +++ b/internal/nvidiadriver/nvidiadriver_errors_test.go @@ -122,7 +122,7 @@ func TestAssignOwnersReturnsErrorWhenOwnerLabelUpdateFails(t *testing.T) { // With no drivers present, a node carrying an owner label must have it cleared, // which drives the removal (desiredOwner == "") patch branch. func TestAssignOwnersReturnsErrorWhenOwnerLabelRemovalFails(t *testing.T) { - node := gpuNode("gpu-node", map[string]string{consts.NVIDIADriverOwnerLabel: "stale-driver"}) + node := gpuNode("gpu-node", map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "stale-driver"}) c := fake.NewClientBuilder(). WithScheme(assignOwnersScheme(t)). diff --git a/internal/nvidiadriver/nvidiadriver_test.go b/internal/nvidiadriver/nvidiadriver_test.go index 8e7c50eda2..8c83d3bc9e 100644 --- a/internal/nvidiadriver/nvidiadriver_test.go +++ b/internal/nvidiadriver/nvidiadriver_test.go @@ -89,9 +89,9 @@ func TestNodeMatchesSelector(t *testing.T) { { description: "existing owner label does not affect user selector matching", nodeLabels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "old-driver", - "region": "us-east-1", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "old-driver", + "region": "us-east-1", }, selector: map[string]string{"region": "us-east-1"}, expected: true, @@ -99,19 +99,19 @@ func TestNodeMatchesSelector(t *testing.T) { { description: "reserved owner selector follows exact label matching", nodeLabels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "demo-gold", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "demo-gold", }, - selector: map[string]string{consts.NVIDIADriverOwnerLabel: "demo-gold"}, + selector: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "demo-gold"}, expected: true, }, { description: "reserved owner selector does not match a different owner", nodeLabels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "demo-silver", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "demo-silver", }, - selector: map[string]string{consts.NVIDIADriverOwnerLabel: "demo-gold"}, + selector: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "demo-gold"}, expected: false, }, } @@ -155,8 +155,8 @@ func TestAssignNVIDIADriverOwnersGivesSpecificDriversPrecedence(t *testing.T) { require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "default-node"}, defaultNode)) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "specific-node"}, specificNode)) - require.Equal(t, consts.DefaultNVIDIADriverName, defaultNode.Labels[consts.NVIDIADriverOwnerLabel]) - require.Equal(t, "h100-driver", specificNode.Labels[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, consts.DefaultNVIDIADriverName, defaultNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) + require.Equal(t, "h100-driver", specificNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestAssignNVIDIADriverOwnersAllowsMissingDefaultDriver(t *testing.T) { @@ -172,7 +172,7 @@ func TestAssignNVIDIADriverOwnersAllowsMissingDefaultDriver(t *testing.T) { } unmatchedNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "unmatched-node", - Labels: map[string]string{consts.GPUPresentLabel: "true", consts.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName}, + Labels: map[string]string{consts.GPUPresentLabel: "true", nvidiav1alpha1.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName}, }} specificNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "specific-node", @@ -187,8 +187,8 @@ func TestAssignNVIDIADriverOwnersAllowsMissingDefaultDriver(t *testing.T) { require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "unmatched-node"}, unmatchedNode)) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "specific-node"}, specificNode)) - require.NotContains(t, unmatchedNode.Labels, consts.NVIDIADriverOwnerLabel) - require.Equal(t, "h100-driver", specificNode.Labels[consts.NVIDIADriverOwnerLabel]) + require.NotContains(t, unmatchedNode.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) + require.Equal(t, "h100-driver", specificNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestAssignNVIDIADriverOwnersIgnoresDeletingDrivers(t *testing.T) { @@ -210,9 +210,9 @@ func TestAssignNVIDIADriverOwnersIgnoresDeletingDrivers(t *testing.T) { node := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "gpu-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "demo-gold", - "nodepool": "gold", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "demo-gold", + "nodepool": "gold", }, }} @@ -223,7 +223,7 @@ func TestAssignNVIDIADriverOwnersIgnoresDeletingDrivers(t *testing.T) { require.True(t, changed) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "gpu-node"}, node)) - require.NotContains(t, node.Labels, consts.NVIDIADriverOwnerLabel) + require.NotContains(t, node.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) } func TestAssignNVIDIADriverOwnersUsesDefaultDriverWithArbitraryName(t *testing.T) { @@ -247,7 +247,7 @@ func TestAssignNVIDIADriverOwnersUsesDefaultDriverWithArbitraryName(t *testing.T require.True(t, changed) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "gpu-node"}, node)) - require.Equal(t, "fallback-driver", node.Labels[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, "fallback-driver", node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestAssignNVIDIADriverOwnersReturnsFalseWhenOwnersAreCurrent(t *testing.T) { @@ -268,16 +268,16 @@ func TestAssignNVIDIADriverOwnersReturnsFalseWhenOwnersAreCurrent(t *testing.T) defaultNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "default-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName, + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName, }, }} specificNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "specific-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "h100-driver", - "nodepool": "h100", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "h100-driver", + "nodepool": "h100", }, }} @@ -314,7 +314,7 @@ func TestAssignNVIDIADriverOwnersErrorsOnMultipleDefaultDrivers(t *testing.T) { require.Contains(t, err.Error(), "multiple default NVIDIADrivers found") require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "gpu-node"}, node)) - require.NotContains(t, node.Labels, consts.NVIDIADriverOwnerLabel) + require.NotContains(t, node.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) } func TestAssignNVIDIADriverOwnersRejectsReservedOwnerLabelSelector(t *testing.T) { @@ -325,14 +325,14 @@ func TestAssignNVIDIADriverOwnersRejectsReservedOwnerLabelSelector(t *testing.T) driver := &nvidiav1alpha1.NVIDIADriver{ ObjectMeta: metav1.ObjectMeta{Name: "bad-driver"}, Spec: nvidiav1alpha1.NVIDIADriverSpec{ - NodeSelector: map[string]string{consts.NVIDIADriverOwnerLabel: "other-driver"}, + NodeSelector: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "other-driver"}, }, } node := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "gpu-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "existing-driver", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "existing-driver", }, }} @@ -342,10 +342,10 @@ func TestAssignNVIDIADriverOwnersRejectsReservedOwnerLabelSelector(t *testing.T) require.Error(t, err) require.False(t, changed) require.Contains(t, err.Error(), "reserved label") - require.Contains(t, err.Error(), consts.NVIDIADriverOwnerLabel) + require.Contains(t, err.Error(), nvidiav1alpha1.NVIDIADriverOwnerLabel) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "gpu-node"}, node)) - require.Equal(t, "existing-driver", node.Labels[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, "existing-driver", node.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestAssignNVIDIADriverOwnersRejectsDefaultDriverNodeSelector(t *testing.T) { @@ -372,7 +372,7 @@ func TestAssignNVIDIADriverOwnersRejectsDefaultDriverNodeSelector(t *testing.T) }} unmatchedNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "unmatched-node", - Labels: map[string]string{consts.GPUPresentLabel: "true", consts.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName}, + Labels: map[string]string{consts.GPUPresentLabel: "true", nvidiav1alpha1.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName}, }} specificNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "specific-node", @@ -390,9 +390,9 @@ func TestAssignNVIDIADriverOwnersRejectsDefaultDriverNodeSelector(t *testing.T) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "default-node"}, defaultNode)) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "unmatched-node"}, unmatchedNode)) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "specific-node"}, specificNode)) - require.NotContains(t, defaultNode.Labels, consts.NVIDIADriverOwnerLabel) - require.Equal(t, consts.DefaultNVIDIADriverName, unmatchedNode.Labels[consts.NVIDIADriverOwnerLabel]) - require.NotContains(t, specificNode.Labels, consts.NVIDIADriverOwnerLabel) + require.NotContains(t, defaultNode.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) + require.Equal(t, consts.DefaultNVIDIADriverName, unmatchedNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) + require.NotContains(t, specificNode.Labels, nvidiav1alpha1.NVIDIADriverOwnerLabel) } func TestAssignNVIDIADriverOwnersDoesNotFallbackToDefaultOnUserDriverConflict(t *testing.T) { @@ -419,9 +419,9 @@ func TestAssignNVIDIADriverOwnersDoesNotFallbackToDefaultOnUserDriverConflict(t conflictedNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "conflicted-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - "nodepool": "shared", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + "nodepool": "shared", }, }} @@ -433,7 +433,7 @@ func TestAssignNVIDIADriverOwnersDoesNotFallbackToDefaultOnUserDriverConflict(t require.Contains(t, err.Error(), "multiple NVIDIADrivers match the same node") require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "conflicted-node"}, conflictedNode)) - require.Equal(t, "driver-a", conflictedNode.Labels[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, "driver-a", conflictedNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestAssignNVIDIADriverOwnersDoesNotChangeOwnersWhenAnyUserDriverConflicts(t *testing.T) { @@ -457,17 +457,17 @@ func TestAssignNVIDIADriverOwnersDoesNotChangeOwnersWhenAnyUserDriverConflicts(t goldNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "gold-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "demo-gold", - "region": "us-east-1", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "demo-gold", + "region": "us-east-1", }, }} defaultNode := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "default-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName, - "region": "us-east-2", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: consts.DefaultNVIDIADriverName, + "region": "us-east-2", }, }} @@ -480,6 +480,6 @@ func TestAssignNVIDIADriverOwnersDoesNotChangeOwnersWhenAnyUserDriverConflicts(t require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "gold-node"}, goldNode)) require.NoError(t, k8sClient.Get(context.Background(), client.ObjectKey{Name: "default-node"}, defaultNode)) - require.Equal(t, "demo-gold", goldNode.Labels[consts.NVIDIADriverOwnerLabel]) - require.Equal(t, consts.DefaultNVIDIADriverName, defaultNode.Labels[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, "demo-gold", goldNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) + require.Equal(t, consts.DefaultNVIDIADriverName, defaultNode.Labels[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } diff --git a/internal/state/configurable_state.go b/internal/state/configurable_state.go index dd2039b643..572b770e22 100644 --- a/internal/state/configurable_state.go +++ b/internal/state/configurable_state.go @@ -22,8 +22,8 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "github.com/NVIDIA/gpu-operator/api/image" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" - "github.com/NVIDIA/gpu-operator/internal/image" ) // configurableState is a State implementation shared by the GPUCluster operands diff --git a/internal/state/dra_driver.go b/internal/state/dra_driver.go index 85159953d4..90fa4419cf 100644 --- a/internal/state/dra_driver.go +++ b/internal/state/dra_driver.go @@ -25,9 +25,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" + "github.com/NVIDIA/gpu-operator/api/image" nvidiav1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" - "github.com/NVIDIA/gpu-operator/internal/image" ) const ( diff --git a/internal/state/driver.go b/internal/state/driver.go index 2046bbf815..137bf189ac 100644 --- a/internal/state/driver.go +++ b/internal/state/driver.go @@ -40,11 +40,11 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/source" + "github.com/NVIDIA/gpu-operator/api/image" nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" "github.com/NVIDIA/gpu-operator/controllers/clusterinfo" driverconfig "github.com/NVIDIA/gpu-operator/internal/config" "github.com/NVIDIA/gpu-operator/internal/consts" - "github.com/NVIDIA/gpu-operator/internal/image" "github.com/NVIDIA/gpu-operator/internal/render" "github.com/NVIDIA/gpu-operator/internal/utils" ) diff --git a/internal/state/driver_test.go b/internal/state/driver_test.go index 92907fb62c..90469c6a95 100644 --- a/internal/state/driver_test.go +++ b/internal/state/driver_test.go @@ -875,17 +875,17 @@ func TestGetNodePoolsDoesNotAllowSelectorToOverrideOwnerLabel(t *testing.T) { node := &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "gpu-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "ubuntu", - nfdOSVersionIDLabelKey: "22.04", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "ubuntu", + nfdOSVersionIDLabelKey: "22.04", }, }} k8sClient := fake.NewClientBuilder().WithScheme(scheme.Scheme).WithObjects(node).Build() driver := &nvidiav1alpha1.NVIDIADriver{ ObjectMeta: metav1.ObjectMeta{Name: "driver-a"}, Spec: nvidiav1alpha1.NVIDIADriverSpec{ - NodeSelector: map[string]string{consts.NVIDIADriverOwnerLabel: "driver-b"}, + NodeSelector: map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-b"}, }, } @@ -893,7 +893,7 @@ func TestGetNodePoolsDoesNotAllowSelectorToOverrideOwnerLabel(t *testing.T) { require.NoError(t, err) require.Len(t, nodePools, 1) - require.Equal(t, "driver-a", nodePools[0].nodeSelector[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, "driver-a", nodePools[0].nodeSelector[nvidiav1alpha1.NVIDIADriverOwnerLabel]) } func TestDriverPrecompiled(t *testing.T) { diff --git a/internal/state/nodepool.go b/internal/state/nodepool.go index be42d25bed..86b39651f7 100644 --- a/internal/state/nodepool.go +++ b/internal/state/nodepool.go @@ -65,7 +65,7 @@ func getNodePools(ctx context.Context, k8sClient client.Client, cr *nvidiav1alph nodeSelector := map[string]string{} maps.Copy(nodeSelector, cr.Spec.NodeSelector) nodeSelector[consts.GPUPresentLabel] = "true" - nodeSelector[consts.NVIDIADriverOwnerLabel] = cr.Name + nodeSelector[nvidiav1alpha1.NVIDIADriverOwnerLabel] = cr.Name nodeList := &corev1.NodeList{} err := k8sClient.List(ctx, nodeList, client.MatchingLabels(nodeSelector)) diff --git a/internal/state/nodepool_test.go b/internal/state/nodepool_test.go index 5583b8c1ed..74ae8fa15d 100644 --- a/internal/state/nodepool_test.go +++ b/internal/state/nodepool_test.go @@ -121,45 +121,45 @@ func TestGetNodePoolsGroupsNodesByOSTag(t *testing.T) { &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "rhel9.4-node", Labels: map[string]string{ - "pool": "gold", - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "rhel", - nfdOSVersionIDLabelKey: "9.4", - nfdOSVersionIDMajorLabelKey: "9", + "pool": "gold", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "rhel", + nfdOSVersionIDLabelKey: "9.4", + nfdOSVersionIDMajorLabelKey: "9", }, }}, &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "rhel9.5-node", Labels: map[string]string{ - "pool": "gold", - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "rhel", - nfdOSVersionIDLabelKey: "9.5", - nfdOSVersionIDMajorLabelKey: "9", + "pool": "gold", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "rhel", + nfdOSVersionIDLabelKey: "9.5", + nfdOSVersionIDMajorLabelKey: "9", }, }}, &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "ubuntu-node", Labels: map[string]string{ - "pool": "gold", - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "ubuntu", - nfdOSVersionIDLabelKey: "22.04", - nfdOSVersionIDMajorLabelKey: "22", + "pool": "gold", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "ubuntu", + nfdOSVersionIDLabelKey: "22.04", + nfdOSVersionIDMajorLabelKey: "22", }, }}, &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "other-pool-node", Labels: map[string]string{ - "pool": "silver", - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "ubuntu", - nfdOSVersionIDLabelKey: "20.04", - nfdOSVersionIDMajorLabelKey: "20", + "pool": "silver", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "ubuntu", + nfdOSVersionIDLabelKey: "20.04", + nfdOSVersionIDMajorLabelKey: "20", }, }}, ). @@ -180,7 +180,7 @@ func TestGetNodePoolsGroupsNodesByOSTag(t *testing.T) { require.Contains(t, poolsByName, "rhel9") require.Equal(t, "rhel", poolsByName["rhel9"].osRelease) require.Equal(t, "gold", poolsByName["rhel9"].nodeSelector["pool"]) - require.Equal(t, "driver-a", poolsByName["rhel9"].nodeSelector[consts.NVIDIADriverOwnerLabel]) + require.Equal(t, "driver-a", poolsByName["rhel9"].nodeSelector[nvidiav1alpha1.NVIDIADriverOwnerLabel]) require.Equal(t, "", poolsByName["rhel9"].nodeSelector[nfdOSVersionIDLabelKey]) require.Equal(t, "9", poolsByName["rhel9"].nodeSelector[nfdOSVersionIDMajorLabelKey]) @@ -200,17 +200,17 @@ func TestGetNodePoolsSkipsNodesMissingNFDOSLabels(t *testing.T) { &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "missing-os-release", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSVersionIDLabelKey: "9.4", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSVersionIDLabelKey: "9.4", }, }}, &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "missing-os-version", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "rhel", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "rhel", }, }}, ). @@ -234,22 +234,22 @@ func TestGetNodePoolsPartitionsPrecompiledNodesByKernel(t *testing.T) { &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "kernel-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "ubuntu", - nfdOSVersionIDLabelKey: "22.04", - nfdOSVersionIDMajorLabelKey: "22", - nfdKernelLabelKey: "5.15.0-70-generic_x86_64", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "ubuntu", + nfdOSVersionIDLabelKey: "22.04", + nfdOSVersionIDMajorLabelKey: "22", + nfdKernelLabelKey: "5.15.0-70-generic_x86_64", }, }}, &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "missing-kernel-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "ubuntu", - nfdOSVersionIDLabelKey: "22.04", - nfdOSVersionIDMajorLabelKey: "22", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "ubuntu", + nfdOSVersionIDLabelKey: "22.04", + nfdOSVersionIDMajorLabelKey: "22", }, }}, ). @@ -279,22 +279,22 @@ func TestGetNodePoolsPartitionsOpenShiftNodesByRHCOSVersion(t *testing.T) { &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "rhcos-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "rhcos", - nfdOSVersionIDLabelKey: "4.14", - nfdOSVersionIDMajorLabelKey: "4", - nfdOSTreeVersionLabelKey: "414.92.202309282257", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "rhcos", + nfdOSVersionIDLabelKey: "4.14", + nfdOSVersionIDMajorLabelKey: "4", + nfdOSTreeVersionLabelKey: "414.92.202309282257", }, }}, &corev1.Node{ObjectMeta: metav1.ObjectMeta{ Name: "missing-rhcos-node", Labels: map[string]string{ - consts.GPUPresentLabel: "true", - consts.NVIDIADriverOwnerLabel: "driver-a", - nfdOSReleaseIDLabelKey: "rhcos", - nfdOSVersionIDLabelKey: "4.14", - nfdOSVersionIDMajorLabelKey: "4", + consts.GPUPresentLabel: "true", + nvidiav1alpha1.NVIDIADriverOwnerLabel: "driver-a", + nfdOSReleaseIDLabelKey: "rhcos", + nfdOSVersionIDLabelKey: "4.14", + nfdOSVersionIDMajorLabelKey: "4", }, }}, ). diff --git a/internal/validator/validator_test.go b/internal/validator/validator_test.go index 32913f4d24..ce3d8b3cde 100644 --- a/internal/validator/validator_test.go +++ b/internal/validator/validator_test.go @@ -163,7 +163,7 @@ func TestCheckNodeSelectorIgnoresDeletingDefaultDriver(t *testing.T) { } func TestCheckNodeSelectorRejectsReservedOwnerLabel(t *testing.T) { - driver := makeTestDriver("", map[string]string{consts.NVIDIADriverOwnerLabel: "other-driver"}, false) + driver := makeTestDriver("", map[string]string{nvidiav1alpha1.NVIDIADriverOwnerLabel: "other-driver"}, false) s := scheme.Scheme err := nvidiav1alpha1.AddToScheme(s) @@ -178,7 +178,7 @@ func TestCheckNodeSelectorRejectsReservedOwnerLabel(t *testing.T) { err = nsv.Validate(context.Background(), driver) assert.Error(t, err) assert.Contains(t, err.Error(), "reserved label") - assert.Contains(t, err.Error(), consts.NVIDIADriverOwnerLabel) + assert.Contains(t, err.Error(), nvidiav1alpha1.NVIDIADriverOwnerLabel) } func TestCheckNodeSelectorRejectsDefaultDriverNodeSelector(t *testing.T) { diff --git a/tools/generate-third-party-notices.sh b/tools/generate-third-party-notices.sh index cca33a7a30..11bf1e4f1b 100755 --- a/tools/generate-third-party-notices.sh +++ b/tools/generate-third-party-notices.sh @@ -186,7 +186,7 @@ collapse_index() { # the notices identify dependencies and their licenses, not an exact build. # Longest prefix wins: a license may sit below the module root. annotate_modules() { - awk -v modfile="${MODULES_TXT}" ' + awk -v modfile="${MODULES_TXT}" -v localmod="${LOCAL_MODULE}" ' BEGIN { FS = OFS = "," while ((getline line < modfile) > 0) { @@ -197,6 +197,9 @@ annotate_modules() { if (f[4] == "=>" || f[3] == "=>") { r = (f[4] == "=>") ? 5 : 4 if (f[r + 1] == "") { + # Nested modules from this repository are first-party + # and are already excluded by go-licenses. + if (f[2] == localmod || index(f[2], localmod "/") == 1) continue print "ERROR: " modfile " replaces " f[2] " with a local path;" > "/dev/stderr" print "teach tools/generate-third-party-notices.sh how to attribute it." > "/dev/stderr" exit 1 diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/image/image.go b/vendor/github.com/NVIDIA/gpu-operator/api/image/image.go new file mode 100644 index 0000000000..9712f36894 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/image/image.go @@ -0,0 +1,57 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +package image + +import ( + "fmt" + "os" + "strings" +) + +func ImagePath(repository string, image string, version string, imagePathEnvName string) (string, error) { + // ImagePath is obtained using following priority + // 1. CR (i.e through repository/image/path variables in CRD) + var crdImagePath string + if repository == "" && version == "" { + if image != "" { + // this is useful for tools like kbld(carvel) which transform templates into image as path@digest + crdImagePath = image + } + } else { + if repository == "" || image == "" || version == "" { + return "", fmt.Errorf("invalid image specification: repository, image and version must all be set (repository=%s, image=%s, version=%s)", repository, image, version) + } + // use @ if image digest is specified instead of tag + if strings.HasPrefix(version, "sha256:") { + crdImagePath = repository + "/" + image + "@" + version + } else { + crdImagePath = repository + "/" + image + ":" + version + } + } + if crdImagePath != "" { + return crdImagePath, nil + } + + // 2. Env passed to GPU Operator Pod (eg OLM) + envImagePath := os.Getenv(imagePathEnvName) + if envImagePath != "" { + return envImagePath, nil + } + + // 3. If both are not set, error out + return "", fmt.Errorf("empty image path provided through both CR and ENV %s", imagePathEnvName) +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/clusterpolicy_types.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/clusterpolicy_types.go new file mode 100644 index 0000000000..234b5eba36 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/clusterpolicy_types.go @@ -0,0 +1,2529 @@ +/* +Copyright 2021. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +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. +*/ + +package v1 + +import ( + "fmt" + "os" + "strings" + + kata_v1alpha1 "github.com/NVIDIA/k8s-kata-manager/api/v1alpha1/config" + upgrade_v1alpha1 "github.com/NVIDIA/k8s-operator-libs/api/upgrade/v1alpha1" + promv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +const ( + ClusterPolicyCRDName = "ClusterPolicy" + // DefaultDCGMJobMappingDir is the default directory for DCGM Exporter HPC job mapping files + DefaultDCGMJobMappingDir = "/var/lib/dcgm-exporter/job-mapping" +) + +// ClusterPolicySpec defines the desired state of ClusterPolicy +type ClusterPolicySpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Operator component spec + Operator OperatorSpec `json:"operator"` + // Daemonset defines common configuration for all Daemonsets + Daemonsets DaemonsetsSpec `json:"daemonsets"` + // Driver component spec + Driver DriverSpec `json:"driver"` + // Toolkit component spec + Toolkit ToolkitSpec `json:"toolkit"` + // DevicePlugin component spec + DevicePlugin DevicePluginSpec `json:"devicePlugin"` + // DCGMExporter spec + DCGMExporter DCGMExporterSpec `json:"dcgmExporter"` + // DCGM component spec + DCGM DCGMSpec `json:"dcgm"` + // NodeStatusExporter spec + NodeStatusExporter NodeStatusExporterSpec `json:"nodeStatusExporter"` + // GPUFeatureDiscovery spec + GPUFeatureDiscovery GPUFeatureDiscoverySpec `json:"gfd"` + // MIG spec + MIG MIGSpec `json:"mig,omitempty"` + // MIGManager for configuration to deploy MIG Manager + MIGManager MIGManagerSpec `json:"migManager,omitempty"` + // Deprecated: Pod Security Policies are no longer supported. Please use PodSecurityAdmission instead + // PSP defines spec for handling PodSecurityPolicies + PSP PSPSpec `json:"psp,omitempty"` + // PSA defines spec for PodSecurityAdmission configuration + PSA PSASpec `json:"psa,omitempty"` + // Validator defines the spec for operator-validator daemonset + Validator ValidatorSpec `json:"validator,omitempty"` + // GPUDirectStorage defines the spec for GDS components(Experimental) + GPUDirectStorage *GPUDirectStorageSpec `json:"gds,omitempty"` + // GDRCopy component spec + GDRCopy *GDRCopySpec `json:"gdrcopy,omitempty"` + // SandboxWorkloads defines the spec for handling sandbox workloads (i.e. Virtual Machines) + SandboxWorkloads SandboxWorkloadsSpec `json:"sandboxWorkloads,omitempty"` + // VFIOManager for configuration to deploy VFIO-PCI Manager + VFIOManager VFIOManagerSpec `json:"vfioManager,omitempty"` + // SandboxDevicePlugin component spec + SandboxDevicePlugin SandboxDevicePluginSpec `json:"sandboxDevicePlugin,omitempty"` + // VGPUManager component spec + VGPUManager VGPUManagerSpec `json:"vgpuManager,omitempty"` + // VGPUDeviceManager spec + VGPUDeviceManager VGPUDeviceManagerSpec `json:"vgpuDeviceManager,omitempty"` + // CDI configures how the Container Device Interface is used in the cluster + CDI CDIConfigSpec `json:"cdi,omitempty"` + // Deprecated: This field is no longer honored by the GPU Operator. All values under this field are ignored. + // KataManager component spec + KataManager KataManagerSpec `json:"kataManager,omitempty"` + // CCManager component spec + CCManager CCManagerSpec `json:"ccManager,omitempty"` + // HostPaths defines various paths on the host needed by GPU Operator components + HostPaths HostPathsSpec `json:"hostPaths,omitempty"` + // KataSandboxDevicePlugin component spec + KataSandboxDevicePlugin KataDevicePluginSpec `json:"kataSandboxDevicePlugin,omitempty"` +} + +// Runtime defines container runtime type +type Runtime string + +// RuntimeClass defines the runtime class to use for GPU-enabled pods +type RuntimeClass string + +const ( + // Docker runtime + Docker Runtime = "docker" + // CRIO runtime + CRIO Runtime = "crio" + // Containerd runtime + Containerd Runtime = "containerd" +) + +func (r Runtime) String() string { + switch r { + case Docker: + return "docker" + case CRIO: + return "crio" + case Containerd: + return "containerd" + default: + return "" + } +} + +// SandboxWorkloadsMode defines the mode for sandbox workloads +type SandboxWorkloadsMode string + +const ( + // KubeVirt is the SandboxWorkloadsMode value for enabling KubeVirt based workloads + KubeVirt SandboxWorkloadsMode = "kubevirt" + // Kata is the SandboxWorkloadsMode value for enabling Kata Container based workloads + Kata SandboxWorkloadsMode = "kata" +) + +// ServiceMonitorConfig defines configuration options for the ServiceMonitor +// deployed for NVIDIA GPU Operator resources +type ServiceMonitorConfig struct { + // Enabled indicates if ServiceMonitor is deployed + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable deployment of ServiceMonitor" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Interval at which metrics should be scraped. If not specified, Prometheus’ global scrape interval is used. + // Supported units: y, w, d, h, m, s, ms + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Interval at which metrics should be scraped" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Interval promv1.Duration `json:"interval,omitempty"` + + // ScrapeTimeout to use when scraping metrics. Must not be greater than Interval. + // If not specified, Prometheus' global scrape timeout is used. + // Supported units: y, w, d, h, m, s, ms + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Scrape timeout" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + ScrapeTimeout promv1.Duration `json:"scrapeTimeout,omitempty"` + + // HonorLabels chooses the metric’s labels on collisions with target labels. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Choose the metric's label on collisions with target labels" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HonorLabels *bool `json:"honorLabels,omitempty"` + + // AdditionalLabels to add to ServiceMonitor instance + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Additional labels to add to ServiceMonitor instance" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + AdditionalLabels map[string]string `json:"additionalLabels,omitempty"` + + // Relabelings allows to rewrite labels on metric sets + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Relabelings allows to rewrite labels on metric sets" + Relabelings []*promv1.RelabelConfig `json:"relabelings,omitempty"` +} + +// The Alias for backward compatibility +// This points the old name to the new struct definition +type DCGMExporterServiceMonitorConfig = ServiceMonitorConfig + +// OperatorSpec describes configuration options for the operator +type OperatorSpec struct { + // Deprecated: DefaultRuntime is no longer used by the gpu-operator. This is instead, detected at runtime. + // +optional + DefaultRuntime Runtime `json:"defaultRuntime,omitempty"` + // +kubebuilder:default=nvidia + RuntimeClass string `json:"runtimeClass,omitempty"` + InitContainer InitContainerSpec `json:"initContainer,omitempty"` + + // Optional: Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. May match selectors of replication controllers + // and services. + Labels map[string]string `json:"labels,omitempty"` + + // Optional: Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + Annotations map[string]string `json:"annotations,omitempty"` + + // Metrics configuration for NVIDIA GPU Operator + Metrics OperatorMetricsSpec `json:"metrics,omitempty"` + + // UseOpenShiftDriverToolkit indicates if DriverToolkit image should be used on OpenShift to build and install driver modules + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="On OpenShift, enable DriverToolkit image to build and install driver modules" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + UseOpenShiftDriverToolkit *bool `json:"use_ocp_driver_toolkit,omitempty"` +} + +type OperatorMetricsSpec struct { + // Optional: ServiceMonitor configuration for NVIDIA GPU Operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ServiceMonitor configuration for NVIDIA GPU Operator" + ServiceMonitor *ServiceMonitorConfig `json:"serviceMonitor,omitempty"` +} + +// HostPathsSpec defines various paths on the host needed by GPU Operator components +type HostPathsSpec struct { + // RootFS represents the path to the root filesystem of the host. + // This is used by components that need to interact with the host filesystem + // and as such this must be a chroot-able filesystem. + // Examples include the MIG Manager and Toolkit Container which may need to + // stop, start, or restart systemd services. + RootFS string `json:"rootFS,omitempty"` + + // DriverInstallDir represents the root at which driver files including libraries, + // config files, and executables can be found. + DriverInstallDir string `json:"driverInstallDir,omitempty"` + + // KubeletRootDir represents the location of the kubelet root directory. + // If empty, it will default to "/var/lib/kubelet". + // +kubebuilder:default="/var/lib/kubelet" + KubeletRootDir string `json:"kubeletRootDir,omitempty"` +} + +// EnvVar represents an environment variable present in a Container. +type EnvVar struct { + // Name of the environment variable. + Name string `json:"name"` + + // Value of the environment variable. + Value string `json:"value,omitempty"` +} + +// ResourceRequirements describes the compute resource requirements. +type ResourceRequirements struct { + // Limits describes the maximum amount of compute resources allowed. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + Limits corev1.ResourceList `json:"limits,omitempty"` + // Requests describes the minimum amount of compute resources required. + // If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + // otherwise to an implementation-defined value. Requests cannot exceed Limits. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + Requests corev1.ResourceList `json:"requests,omitempty"` +} + +// SandboxWorkloadsSpec describes configuration for handling sandbox workloads (i.e. Virtual Machines) +type SandboxWorkloadsSpec struct { + // Enabled indicates if the GPU Operator should manage additional operands required + // for sandbox workloads (i.e. VFIO Manager, vGPU Manager, and additional device plugins) + Enabled *bool `json:"enabled,omitempty"` + // DefaultWorkload indicates the default GPU workload type to configure + // worker nodes in the cluster for + // +kubebuilder:validation:Enum=container;vm-passthrough;vm-vgpu + // +kubebuilder:default=container + DefaultWorkload string `json:"defaultWorkload,omitempty"` + // Mode indicates the sandbox mode. Accepted values are "kubevirt" + // and "kata". The default value is "kubevirt". + // +kubebuilder:validation:Enum=kubevirt;kata + // +kubebuilder:default=kubevirt + Mode string `json:"mode,omitempty"` +} + +// PSPSpec describes configuration for PodSecurityPolicies to apply for all Pods +type PSPSpec struct { + // Enabled indicates if PodSecurityPolicies needs to be enabled for all Pods + Enabled *bool `json:"enabled,omitempty"` +} + +// PSASpec describes configuration for PodSecurityAdmission to apply for all Pods +type PSASpec struct { + // Enabled indicates if PodSecurityAdmission configuration needs to be enabled for all Pods + Enabled *bool `json:"enabled,omitempty"` +} + +// DaemonsetsSpec indicates common configuration for all Daemonsets managed by GPU Operator +type DaemonsetsSpec struct { + // Optional: Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. May match selectors of replication controllers + // and services. + Labels map[string]string `json:"labels,omitempty"` + + // Optional: Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + Annotations map[string]string `json:"annotations,omitempty"` + + // Optional: Set tolerations + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Tolerations" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:io.kubernetes:Tolerations" + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="PriorityClassName" + PriorityClassName string `json:"priorityClassName,omitempty"` + + // +kubebuilder:validation:Optional + // +kubebuilder:default=RollingUpdate + // +kubebuilder:validation:Enum=RollingUpdate;OnDelete + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="UpdateStrategy for all Daemonsets" + UpdateStrategy string `json:"updateStrategy,omitempty"` + + // Optional: Configuration for rolling update of all DaemonSet pods + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Rolling update configuration for all DaemonSet pods" + RollingUpdate *RollingUpdateSpec `json:"rollingUpdate,omitempty"` + + // Optional: Set pod-level security context for all DaemonSet pods (applies as defaults to all containers) + PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` +} + +// Deprecated: InitContainerSpec describes configuration for initContainer image used with all components +type InitContainerSpec struct { + // Repository represents image repository path + Repository string `json:"repository,omitempty"` + + // Image represents image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // Version represents image tag(version) + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` +} + +// ValidatorSpec describes configuration options for validation pod +type ValidatorSpec struct { + // Plugin validator spec + Plugin PluginValidatorSpec `json:"plugin,omitempty"` + + // Toolkit validator spec + Toolkit ToolkitValidatorSpec `json:"toolkit,omitempty"` + + // Toolkit validator spec + Driver DriverValidatorSpec `json:"driver,omitempty"` + + // CUDA validator spec + CUDA CUDAValidatorSpec `json:"cuda,omitempty"` + + // VfioPCI validator spec + VFIOPCI VFIOPCIValidatorSpec `json:"vfioPCI,omitempty"` + + // VGPUManager validator spec + VGPUManager VGPUManagerValidatorSpec `json:"vgpuManager,omitempty"` + + // VGPUDevices validator spec + VGPUDevices VGPUDevicesValidatorSpec `json:"vgpuDevices,omitempty"` + + // Validator image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // Validator image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // Validator image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // HostNetwork indicates whether the Validator pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Operator Validator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// PluginValidatorSpec defines validator spec for NVIDIA Device Plugin +type PluginValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// ToolkitValidatorSpec defines validator spec for NVIDIA Container Toolkit +type ToolkitValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// DriverValidatorSpec defines validator spec for NVIDIA Driver validation +type DriverValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// CUDAValidatorSpec defines validator spec for CUDA validation workload pod +type CUDAValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// VFIOPCIValidatorSpec defines validator spec for NVIDIA VFIO-PCI device validation +type VFIOPCIValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// VGPUManagerValidatorSpec defines validator spec for NVIDIA vGPU Manager +type VGPUManagerValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// VGPUDevicesValidatorSpec defines validator spec for NVIDIA vGPU device validator +type VGPUDevicesValidatorSpec struct { + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// MIGSpec defines the configuration for MIG support +type MIGSpec struct { + // Optional: MIGStrategy to apply for GFD and NVIDIA Device Plugin + // +kubebuilder:validation:Enum=none;single;mixed + Strategy MIGStrategy `json:"strategy,omitempty"` +} + +// DriverManagerSpec describes configuration for NVIDIA Driver Manager(initContainer) +type DriverManagerSpec struct { + // Repository represents Driver Managerrepository path + Repository string `json:"repository,omitempty"` + + // Image represents NVIDIA Driver Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // Version represents NVIDIA Driver Manager image tag(version) + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// ContainerProbeSpec defines the properties for configuring container probes +type ContainerProbeSpec struct { + // Number of seconds after the container has started before liveness probes are initiated. + // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + // +kubebuilder:validation:Optional + InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"` + // Number of seconds after which the probe times out. + // Defaults to 1 second. Minimum value is 1. + // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"` + // How often (in seconds) to perform the probe. + // Default to 10 seconds. Minimum value is 1. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + PeriodSeconds int32 `json:"periodSeconds,omitempty"` + // Minimum consecutive successes for the probe to be considered successful after having failed. + // Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + SuccessThreshold int32 `json:"successThreshold,omitempty"` + // Minimum consecutive failures for the probe to be considered failed after having succeeded. + // Defaults to 3. Minimum value is 1. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + FailureThreshold int32 `json:"failureThreshold,omitempty"` +} + +// DriverSpec defines the properties for NVIDIA Driver deployment +type DriverSpec struct { + // UseNvidiaDriverCRD indicates if the deployment of NVIDIA Driver is managed by the NVIDIADriver CRD type + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Driver deployment through NVIDIADriver CRD type" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + UseNvidiaDriverCRD *bool `json:"useNvidiaDriverCRD,omitempty"` + + // UsePrecompiled indicates if deployment of NVIDIA Driver using pre-compiled modules is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Driver deployment using pre-compiled modules" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + UsePrecompiled *bool `json:"usePrecompiled,omitempty"` + + // Deprecated: This field is no longer honored by the gpu-operator. Please use KernelModuleType instead. + // UseOpenKernelModules indicates if the open GPU kernel modules should be used + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable use of open GPU kernel modules" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch,urn:alm:descriptor:com.tectonic.ui:hidden" + UseOpenKernelModules *bool `json:"useOpenKernelModules,omitempty"` + + // KernelModuleType represents the type of driver kernel modules to be used when installing the GPU driver. + // Accepted values are auto, proprietary and open. NOTE: If auto is chosen, it means that the recommended kernel module + // type is chosen based on the GPU devices on the host and the driver branch used + // +kubebuilder:validation:Enum=auto;open;proprietary + // +kubebuilder:default=auto + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Kernel Module Type" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.description="Kernel Module Type" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:select:auto,urn:alm:descriptor:com.tectonic.ui:select:open,urn:alm:descriptor:com.tectonic.ui:select:proprietary" + KernelModuleType string `json:"kernelModuleType,omitempty"` + + // Enabled indicates if deployment of NVIDIA Driver through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Driver deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA Driver container startup probe settings + StartupProbe *ContainerProbeSpec `json:"startupProbe,omitempty"` + + // NVIDIA Driver container liveness probe settings + LivenessProbe *ContainerProbeSpec `json:"livenessProbe,omitempty"` + + // NVIDIA Driver container readiness probe settings + ReadinessProbe *ContainerProbeSpec `json:"readinessProbe,omitempty"` + + GPUDirectRDMA *GPUDirectRDMASpec `json:"rdma,omitempty"` + + // Driver auto-upgrade settings + UpgradePolicy *upgrade_v1alpha1.DriverUpgradePolicySpec `json:"upgradePolicy,omitempty"` + + // NVIDIA Driver image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA Driver image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA Driver image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Manager represents configuration for NVIDIA Driver Manager initContainer + Manager DriverManagerSpec `json:"manager,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Optional: Custom repo configuration for NVIDIA Driver container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Repo Configuration For NVIDIA Driver Container" + RepoConfig *DriverRepoConfigSpec `json:"repoConfig,omitempty"` + + // Optional: Custom certificates configuration for NVIDIA Driver container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Certificates Configuration For NVIDIA Driver Container" + CertConfig *DriverCertConfigSpec `json:"certConfig,omitempty"` + + // Optional: Licensing configuration for NVIDIA vGPU licensing + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Licensing Configuration For NVIDIA vGPU Driver Container" + LicensingConfig *DriverLicensingConfigSpec `json:"licensingConfig,omitempty"` + + // Optional: Virtual Topology Daemon configuration for NVIDIA vGPU drivers + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Virtual Topology Daemon Configuration For vGPU Driver Container" + VirtualTopology *VirtualTopologyConfigSpec `json:"virtualTopology,omitempty"` + + // Optional: Kernel module configuration parameters for the NVIDIA Driver + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Kernel module configuration parameters for the NVIDIA driver" + KernelModuleConfig *KernelModuleConfigSpec `json:"kernelModuleConfig,omitempty"` + + // Optional: SecretEnv represents the name of the Kubernetes Secret with secret environment variables for the NVIDIA Driver + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Name of the Kubernetes Secret with secret environment variables for the NVIDIA Driver" + SecretEnv string `json:"secretEnv,omitempty"` + + // HostNetwork indicates whether the Driver pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Driver" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// VGPUManagerSpec defines the properties for the NVIDIA vGPU Manager deployment +type VGPUManagerSpec struct { + // Enabled indicates if deployment of NVIDIA vGPU Manager through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable vgpu host driver deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA vGPU Manager image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA vGPU Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA vGPU Manager image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // DriverManager represents configuration for NVIDIA Driver Manager initContainer + DriverManager DriverManagerSpec `json:"driverManager,omitempty"` + + // Optional: Kernel module configuration parameters for the vGPU manager + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Kernel module configuration parameters for the vGPU manager" + KernelModuleConfig *KernelModuleConfigSpec `json:"kernelModuleConfig,omitempty"` + + // HostNetwork indicates whether the vGPU Manager pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA vGPU Manager" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// ToolkitSpec defines the properties for NVIDIA Container Toolkit deployment +type ToolkitSpec struct { + // Enabled indicates if deployment of NVIDIA Container Toolkit through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Container Toolkit deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA Container Toolkit image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA Container Toolkit image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA Container Toolkit image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Toolkit install directory on the host + // +kubebuilder:validation:Optional + // +kubebuilder:default=/usr/local/nvidia + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Toolkit install directory on the host" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + InstallDir string `json:"installDir,omitempty"` + + // HostNetwork indicates whether the Container Toolkit pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Container Toolkit" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// DevicePluginSpec defines the properties for NVIDIA Device Plugin deployment +type DevicePluginSpec struct { + // Enabled indicates if deployment of NVIDIA Device Plugin through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Device Plugin deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA Device Plugin image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA Device Plugin image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA Device Plugin image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Optional: Configuration for the NVIDIA Device Plugin via the ConfigMap + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Configuration for the NVIDIA Device Plugin via the ConfigMap" + Config *DevicePluginConfig `json:"config,omitempty"` + + // Optional: MPS related configuration for the NVIDIA Device Plugin + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="MPS related configuration for the NVIDIA Device Plugin" + MPS *MPSConfig `json:"mps,omitempty"` + + // HostNetwork indicates whether the Device Plugin pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Device Plugin" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// DevicePluginConfig defines ConfigMap name for NVIDIA Device Plugin config +type DevicePluginConfig struct { + // ConfigMap name for NVIDIA Device Plugin config including shared config between plugin and GFD + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap name for NVIDIA Device Plugin including shared config between plugin and GFD" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` + // Default config name within the ConfigMap for the NVIDIA Device Plugin config + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Default config name within the ConfigMap for the NVIDIA Device Plugin config" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Default string `json:"default,omitempty"` +} + +// MPSConfig defines MPS related configuration for the NVIDIA Device Plugin +type MPSConfig struct { + // Root defines the MPS root path on the host + // +kubebuilder:validation:Optional + // +kubebuilder:default=/run/nvidia/mps + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="MPS root path on the host" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Root string `json:"root,omitempty"` +} + +// SandboxDevicePluginSpec defines the properties for the NVIDIA Sandbox Device Plugin deployment +type SandboxDevicePluginSpec struct { + // Enabled indicates if deployment of NVIDIA Sandbox Device Plugin through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Sandbox Device Plugin deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA Sandbox Device Plugin image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA Sandbox Device Plugin image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA Sandbox Device Plugin image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // HostNetwork indicates whether the Sandbox Device Plugin pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Sandbox Device Plugin" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// DCGMExporterSpec defines the properties for NVIDIA DCGM Exporter deployment +type DCGMExporterSpec struct { + // Enabled indicates if deployment of NVIDIA DCGM Exporter through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA DCGM Exporter deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA DCGM Exporter image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA DCGM Exporter image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA DCGM Exporter image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + Annotations map[string]string `json:"annotations,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Optional: Custom metrics configuration for NVIDIA DCGM Exporter + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Metrics Configuration For DCGM Exporter" + MetricsConfig *DCGMExporterMetricsConfig `json:"config,omitempty"` + + // Optional: ServiceMonitor configuration for NVIDIA DCGM Exporter + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ServiceMonitor configuration for NVIDIA DCGM Exporter" + ServiceMonitor *ServiceMonitorConfig `json:"serviceMonitor,omitempty"` + + // Optional: Service configuration for NVIDIA DCGM Exporter + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Service configuration for NVIDIA DCGM Exporter" + ServiceSpec *DCGMExporterServiceConfig `json:"service,omitempty"` + + // HostPID allows the DCGM-Exporter daemon set to access the host's PID namespace + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostPID for NVIDIA DCGM Exporter" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostPID *bool `json:"hostPID,omitempty"` + + // HostNetwork allows the DCGM-Exporter daemon set to expose metrics port on the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA DCGM Exporter" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` + + // Optional: HPC job mapping configuration for NVIDIA DCGM Exporter + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="HPC Job Mapping Configuration" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced" + HPCJobMapping *DCGMExporterHPCJobMappingConfig `json:"hpcJobMapping,omitempty"` + + // Enable Kubernetes pod labels as Prometheus label dimensions in DCGM exporter metrics. + // (Requires cluster-level read access to pods.) + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable pod-label enrichment" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + EnablePodLabels *bool `json:"enablePodLabels,omitempty"` + + // Enable Kubernetes pod UID as a Prometheus label dimension in DCGM exporter metrics. + // (Requires cluster-level read access to pods.) + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable pod-UID enrichment" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + EnablePodUID *bool `json:"enablePodUID,omitempty"` + + // Regex list for filtering which Kubernetes pod labels are included in DCGM exporter metrics. + // Empty means all pod labels are included. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Pod label allowlist regex" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + PodLabelAllowlistRegex []string `json:"podLabelAllowlistRegex,omitempty"` +} + +// DCGMExporterHPCJobMappingConfig defines HPC job mapping configuration for NVIDIA DCGM Exporter +type DCGMExporterHPCJobMappingConfig struct { + // Enable HPC job mapping for DCGM Exporter + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable HPC Job Mapping" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Directory path where HPC job mapping files are created by the workload manager + // Defaults to /var/lib/dcgm-exporter/job-mapping if not specified + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Job Mapping Directory" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Directory string `json:"directory,omitempty"` +} + +// DCGMExporterMetricsConfig defines metrics to be collected by NVIDIA DCGM Exporter +type DCGMExporterMetricsConfig struct { + // ConfigMap name with file dcgm-metrics.csv for metrics to be collected by NVIDIA DCGM Exporter + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap name with file dcgm-metrics.csv" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// DCGMExporterServiceConfig defines the configuration options for the Kubernetes Service deployed for DCGM Exporter +type DCGMExporterServiceConfig struct { + // Type represents the ServiceType which describes ingress methods for a service + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ServiceType for the DCGM Exporter K8s Service" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Type corev1.ServiceType `json:"type,omitempty"` + + // InternalTrafficPolicy describes how nodes distribute service traffic they receive on the ClusterIP. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Internal Traffic Policy for the DCGM Exporter K8s Service" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + InternalTrafficPolicy *corev1.ServiceInternalTrafficPolicy `json:"internalTrafficPolicy,omitempty"` +} + +// DCGMSpec defines the properties for NVIDIA DCGM deployment +type DCGMSpec struct { + // Enabled indicates if deployment of NVIDIA DCGM Hostengine as a separate pod is enabled. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA DCGM hostengine as a separate Pod" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA DCGM image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA DCGM image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA DCGM image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Deprecated: HostPort represents host port that needs to be bound for DCGM engine (Default: 5555) + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Host port to bind for DCGM engine" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:number" + HostPort int32 `json:"hostPort,omitempty"` + + // HostNetwork indicates whether the DCGM pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA DCGM" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// NodeStatusExporterSpec defines the properties for node-status-exporter state +type NodeStatusExporterSpec struct { + // Enabled indicates if deployment of Node Status Exporter is enabled. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable Node Status Exporter deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Node Status Exporterimage repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // Node Status Exporter image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // Node Status Exporterimage tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // HostNetwork indicates whether the Node Status Exporter pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Node Status Exporter" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// DriverRepoConfigSpec defines custom repo configuration for NVIDIA Driver container +type DriverRepoConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + ConfigMapName string `json:"configMapName,omitempty"` +} + +// DriverCertConfigSpec defines custom certificates configuration for NVIDIA Driver container +type DriverCertConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// DriverLicensingConfigSpec defines licensing server configuration for NVIDIA Driver container +type DriverLicensingConfigSpec struct { + // Deprecated: ConfigMapName has been deprecated in favour of SecretName. Please use secrets to handle the licensing server configuration more securely + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + ConfigMapName string `json:"configMapName,omitempty"` + + // SecretName indicates the name of the secret containing the licensing token + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Secret Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + SecretName string `json:"secretName,omitempty"` + + // NLSEnabled indicates if NVIDIA Licensing System is used for licensing. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Licensing System licensing" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + NLSEnabled *bool `json:"nlsEnabled,omitempty"` +} + +// VirtualTopologyConfigSpec defines virtual topology daemon configuration with NVIDIA vGPU +type VirtualTopologyConfigSpec struct { + // Optional: Config name representing virtual topology daemon configuration file nvidia-topologyd.conf + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Config string `json:"config,omitempty"` +} + +// KernelModuleConfigSpec defines custom configuration parameters for the NVIDIA Driver +type KernelModuleConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// RollingUpdateSpec defines configuration for the rolling update of all DaemonSet pods +type RollingUpdateSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Maximum number of nodes to simultaneously apply Daemonset pod updates on. Default 1" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + MaxUnavailable string `json:"maxUnavailable,omitempty"` +} + +// GPUFeatureDiscoverySpec defines the properties for GPU Feature Discovery Plugin +type GPUFeatureDiscoverySpec struct { + // Enabled indicates if deployment of GPU Feature Discovery Plugin is enabled. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GPU Feature Discovery Plugin deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // GFD image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // GFD image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // GFD image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // HostNetwork indicates whether the GPU Feature Discovery pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for GPU Feature Discovery" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// MIGManagerSpec defines the properties for deploying NVIDIA MIG Manager +type MIGManagerSpec struct { + // Enabled indicates if deployment of NVIDIA MIG Manager is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA MIG Manager deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA MIG Manager image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA MIG Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA MIG Manager image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Optional: Custom mig-parted configuration for NVIDIA MIG Manager container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom mig-parted configuration for NVIDIA MIG Manager container" + Config *MIGPartedConfigSpec `json:"config,omitempty"` + + // Optional: Custom gpu-clients configuration for NVIDIA MIG Manager container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom gpu-clients configuration for NVIDIA MIG Manager container" + GPUClientsConfig *MIGGPUClientsConfigSpec `json:"gpuClientsConfig,omitempty"` + + // HostNetwork indicates whether the MIG Manager pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA MIG Manager" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// GPUDirectRDMASpec defines the properties for nvidia-peermem deployment +type GPUDirectRDMASpec struct { + // Enabled indicates if GPUDirect RDMA is enabled through GPU operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GPUDirect RDMA through GPU operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + // UseHostMOFED indicates to use MOFED drivers directly installed on the host to enable GPUDirect RDMA + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Use MOFED drivers directly installed on the host to enable GPUDirect RDMA" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + UseHostMOFED *bool `json:"useHostMofed,omitempty"` +} + +// GPUDirectStorageSpec defines the properties for NVIDIA GPUDirect Storage Driver deployment(Experimental) +type GPUDirectStorageSpec struct { + // Enabled indicates if GPUDirect Storage is enabled through GPU operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GPUDirect Storage through GPU operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA GPUDirect Storage Driver image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA GPUDirect Storage Driver image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA GPUDirect Storage Driver image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// GDRCopySpec defines the properties for NVIDIA GDRCopy driver (gdrdrv) deployment +type GDRCopySpec struct { + // Enabled indicates if GDRCopy is enabled through GPU Operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GDRCopy through GPU operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA GDRCopy driver image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA GDRCopy driver image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA GDRCopy driver image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// MIGPartedConfigSpec defines custom mig-parted config for NVIDIA MIG Manager container +type MIGPartedConfigSpec struct { + // ConfigMap name. If not specified, MIG configuration will be dynamically generated from hardware. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` + // Default MIG config to be applied on the node, when there is no config specified with the node label nvidia.com/mig.config + // +kubebuilder:validation:Optional + // +kubebuilder:default=all-disabled + // +kubebuilder:validation:Enum=all-disabled;"" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Default MIG config" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Default string `json:"default,omitempty"` +} + +// MIGGPUClientsConfigSpec defines custom gpu-clients config for NVIDIA MIG Manager container +type MIGGPUClientsConfigSpec struct { + // ConfigMap name + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// ImageSpec defines shared fields for component images +type ImageSpec struct { + // NVIDIA component image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA component image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA component image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` +} + +// ComponentCommonSpec defines shared fields for components +type ComponentCommonSpec struct { + // Enabled indicates if deployment of NVIDIA component through operator is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA component deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// KataDevicePluginSpec defines attributes for the kata device plugin. +// The Kata device plugin is deployed when SandboxWorkloads is enabled, SandboxWorkloads.Mode is "kata", and Enabled is true. +type KataDevicePluginSpec struct { + ImageSpec `json:",inline"` + ComponentCommonSpec `json:",inline"` + + // HostNetwork indicates whether the Kata Sandbox Device Plugin pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Kata Sandbox Device Plugin" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// KataManagerSpec defines the configuration for the kata-manager which prepares NVIDIA-specific kata runtimes +type KataManagerSpec struct { + // Enabled indicates if deployment of Kata Manager is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable Kata Manager deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Kata Manager config + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Kata Manager configuration" + Config *kata_v1alpha1.Config `json:"config,omitempty"` + + // Kata Manager image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // Kata Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // Kata Manager image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // HostNetwork indicates whether the Kata Manager pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Kata Manager" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// CCManagerSpec defines the properties for deploying Confidential Containers (CC) manager +type CCManagerSpec struct { + // Enabled indicates if deployment of CC Manager is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable CC Manager deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Default CC mode setting for compatible GPUs on the node + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Default CC mode setting for all CC-capable GPUs" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + // +kubebuilder:validation:Enum=on;off;devtools + DefaultMode string `json:"defaultMode,omitempty"` + + // CC Manager image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // CC Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // CC Manager image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // HostNetwork indicates whether the CC Manager pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA CC Manager" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// VFIOManagerSpec defines the properties for deploying VFIO-PCI manager +type VFIOManagerSpec struct { + // Enabled indicates if deployment of VFIO Manager is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable VFIO Manager deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // VFIO Manager image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // VFIO Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // VFIO Manager image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // DriverManager represents configuration for NVIDIA Driver Manager + DriverManager DriverManagerSpec `json:"driverManager,omitempty"` + + // HostNetwork indicates whether the VFIO Manager pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA VFIO Manager" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// VGPUDeviceManagerSpec defines the properties for deploying NVIDIA vGPU Device Manager +type VGPUDeviceManagerSpec struct { + // Enabled indicates if deployment of NVIDIA vGPU Device Manager is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA vGPU Device Manager deployment through GPU Operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA vGPU Device Manager image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA vGPU Device Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA vGPU Device Manager image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // NVIDIA vGPU devices configuration for NVIDIA vGPU Device Manager container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="NVIDIA vGPU devices configuration for NVIDIA vGPU Device Manager container" + Config *VGPUDevicesConfigSpec `json:"config,omitempty"` + + // HostNetwork indicates whether the vGPU Device Manager pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA vGPU Device Manager" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// VGPUDevicesConfigSpec defines vGPU devices configuration for NVIDIA vGPU Device Manager container +type VGPUDevicesConfigSpec struct { + // ConfigMap name + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` + // Default config name within the ConfigMap + // +kubebuilder:validation:Optional + // +kubebuilder:default=default + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Default config name within the ConfigMap for the NVIDIA vGPU devices config" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Default string `json:"default,omitempty"` +} + +// CDIConfigSpec defines how the Container Device Interface is used in the cluster. +type CDIConfigSpec struct { + // Enabled indicates whether the Container Device Interface (CDI) should be used as the mechanism for making GPUs accessible to containers. + // +kubebuilder:validation:Optional + // +kubebuilder:default=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable CDI as the mechanism for making GPUs accessible to containers" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // Deprecated: This field is no longer used. Setting cdi.enabled=true will configure CDI as the default mechanism for making GPUs accessible to containers. + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Deprecated: This field is no longer used" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch,urn:alm:descriptor:com.tectonic.ui:hidden" + Default *bool `json:"default,omitempty"` + + // NRIPluginEnabled indicates whether an NRI Plugin should be run as a means of injecting CDI devices to gpu management containers. + // +kubebuilder:validation:Optional + // +kubebuilder:default=false + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NRI as an additional mechanism for injecting CDI devices to gpu management containers." + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + NRIPluginEnabled *bool `json:"nriPluginEnabled,omitempty"` +} + +// MIGStrategy indicates MIG mode +type MIGStrategy string + +// Constants representing different MIG strategies. +const ( + // MIGStrategyNone indicates MIG mode disabled. + MIGStrategyNone MIGStrategy = "none" + // MIGStrategySingle indicates Single MIG mode + MIGStrategySingle MIGStrategy = "single" + // MIGStrategyMixed indicates Mixed MIG mode + MIGStrategyMixed MIGStrategy = "mixed" +) + +// State indicates state of GPU operator components +type State string + +const ( + // Ignored indicates duplicate ClusterPolicy instances and rest are ignored. + Ignored State = "ignored" + // Ready indicates all components of ClusterPolicy are ready + Ready State = "ready" + // NotReady indicates some/all components of ClusterPolicy are not ready + NotReady State = "notReady" + // Disabled indicates if the state is disabled + Disabled State = "disabled" +) + +// ClusterPolicyStatus defines the observed state of ClusterPolicy +type ClusterPolicyStatus struct { + // +kubebuilder:validation:Enum=ignored;ready;notReady + // State indicates status of ClusterPolicy + State State `json:"state"` + // Namespace indicates a namespace in which the operator is installed + Namespace string `json:"namespace,omitempty"` + // Conditions is a list of conditions representing the ClusterPolicy's current state. + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +genclient +// +genclient:nonNamespaced +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:resource:scope=Cluster +// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0 +// +kubebuilder:printcolumn:name="Age",type=string,JSONPath=`.metadata.creationTimestamp`,priority=0 + +// ClusterPolicy is the Schema for the clusterpolicies API +type ClusterPolicy struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ClusterPolicySpec `json:"spec,omitempty"` + Status ClusterPolicyStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ClusterPolicyList contains a list of ClusterPolicy +type ClusterPolicyList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ClusterPolicy `json:"items"` +} + +// SetStatus sets state and namespace of ClusterPolicy instance +func (p *ClusterPolicy) SetStatus(s State, ns string) { + p.Status.State = s + p.Status.Namespace = ns +} + +func imagePath(repository string, image string, version string, imagePathEnvName string) (string, error) { + // ImagePath is obtained using following priority + // 1. ClusterPolicy (i.e through repository/image/path variables in CRD) + var crdImagePath string + if repository == "" && version == "" { + if image != "" { + // this is useful for tools like kbld(carvel) which transform templates into image as path@digest + crdImagePath = image + } + } else { + if repository == "" || image == "" || version == "" { + return "", fmt.Errorf("invalid image specification: repository, image and version must all be set (repository=%s, image=%s, version=%s)", repository, image, version) + } + // use @ if image digest is specified instead of tag + if strings.HasPrefix(version, "sha256:") { + crdImagePath = repository + "/" + image + "@" + version + } else { + crdImagePath = repository + "/" + image + ":" + version + } + } + if crdImagePath != "" { + return crdImagePath, nil + } + + // 2. Env passed to GPU Operator Pod (eg OLM) + envImagePath := os.Getenv(imagePathEnvName) + if envImagePath != "" { + return envImagePath, nil + } + + // 3. If both are not set, error out + return "", fmt.Errorf("empty image path provided through both ClusterPolicy CR and ENV %s", imagePathEnvName) +} + +// ImagePath sets image path for given component type +func ImagePath(spec interface{}) (string, error) { + switch v := spec.(type) { + case *DriverSpec: + config := spec.(*DriverSpec) + return imagePath(config.Repository, config.Image, config.Version, "DRIVER_IMAGE") + case *VGPUManagerSpec: + config := spec.(*VGPUManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "VGPU_MANAGER_IMAGE") + case *ToolkitSpec: + config := spec.(*ToolkitSpec) + return imagePath(config.Repository, config.Image, config.Version, "CONTAINER_TOOLKIT_IMAGE") + case *DevicePluginSpec: + config := spec.(*DevicePluginSpec) + return imagePath(config.Repository, config.Image, config.Version, "DEVICE_PLUGIN_IMAGE") + case *SandboxDevicePluginSpec: + config := spec.(*SandboxDevicePluginSpec) + return imagePath(config.Repository, config.Image, config.Version, "SANDBOX_DEVICE_PLUGIN_IMAGE") + case *DCGMExporterSpec: + config := spec.(*DCGMExporterSpec) + return imagePath(config.Repository, config.Image, config.Version, "DCGM_EXPORTER_IMAGE") + case *DCGMSpec: + config := spec.(*DCGMSpec) + return imagePath(config.Repository, config.Image, config.Version, "DCGM_IMAGE") + case *NodeStatusExporterSpec: + config := spec.(*NodeStatusExporterSpec) + return imagePath(config.Repository, config.Image, config.Version, "VALIDATOR_IMAGE") + case *GPUFeatureDiscoverySpec: + config := spec.(*GPUFeatureDiscoverySpec) + return imagePath(config.Repository, config.Image, config.Version, "GFD_IMAGE") + case *ValidatorSpec: + config := spec.(*ValidatorSpec) + return imagePath(config.Repository, config.Image, config.Version, "VALIDATOR_IMAGE") + case *InitContainerSpec: + config := spec.(*InitContainerSpec) + return imagePath(config.Repository, config.Image, config.Version, "CUDA_BASE_IMAGE") + case *MIGManagerSpec: + config := spec.(*MIGManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "MIG_MANAGER_IMAGE") + case *DriverManagerSpec: + config := spec.(*DriverManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "DRIVER_MANAGER_IMAGE") + case *GPUDirectStorageSpec: + config := spec.(*GPUDirectStorageSpec) + return imagePath(config.Repository, config.Image, config.Version, "GDS_IMAGE") + case *GDRCopySpec: + config := spec.(*GDRCopySpec) + return imagePath(config.Repository, config.Image, config.Version, "GDRCOPY_IMAGE") + case *VFIOManagerSpec: + config := spec.(*VFIOManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "VFIO_MANAGER_IMAGE") + case *VGPUDeviceManagerSpec: + config := spec.(*VGPUDeviceManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "VGPU_DEVICE_MANAGER_IMAGE") + case *KataManagerSpec: + config := spec.(*KataManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "KATA_MANAGER_IMAGE") + case *CCManagerSpec: + config := spec.(*CCManagerSpec) + return imagePath(config.Repository, config.Image, config.Version, "CC_MANAGER_IMAGE") + case *KataDevicePluginSpec: + config := spec.(*KataDevicePluginSpec) + return imagePath(config.Repository, config.Image, config.Version, "KATA_SANDBOX_DEVICE_PLUGIN_IMAGE") + default: + return "", fmt.Errorf("invalid type to construct image path: %v", v) + } +} + +// ImagePullPolicy sets image pull policy +func ImagePullPolicy(pullPolicy string) corev1.PullPolicy { + var imagePullPolicy corev1.PullPolicy + switch pullPolicy { + case "Always": + imagePullPolicy = corev1.PullAlways + case "Never": + imagePullPolicy = corev1.PullNever + case "IfNotPresent": + imagePullPolicy = corev1.PullIfNotPresent + default: + imagePullPolicy = corev1.PullIfNotPresent + } + return imagePullPolicy +} + +// IsEnabled returns true if driver install is enabled(default) through gpu-operator +func (d *DriverSpec) IsEnabled() bool { + if d.Enabled == nil { + // default is true if not specified by user + return true + } + return *d.Enabled +} + +// UseNvidiaDriverCRDType returns true if the driver installation is managed by NVIDIADriver CRD type +func (d *DriverSpec) UseNvidiaDriverCRDType() bool { + if d.UseNvidiaDriverCRD == nil { + // default is false if not specified by user + return false + } + return *d.UseNvidiaDriverCRD +} + +// UsePrecompiledDrivers returns true if driver install is enabled using pre-compiled modules +func (d *DriverSpec) UsePrecompiledDrivers() bool { + if d.UsePrecompiled == nil { + // default is false if not specified by user + return false + } + return *d.UsePrecompiled +} + +// OpenKernelModulesEnabled returns true if driver install is enabled using open GPU kernel modules +func (d *DriverSpec) OpenKernelModulesEnabled() bool { + return d.KernelModuleType == "open" +} + +// IsVGPULicensingEnabled returns true if the vgpu driver license config is provided +func (d *DriverSpec) IsVGPULicensingEnabled() bool { + if d.LicensingConfig == nil { + return false + } + return d.LicensingConfig.ConfigMapName != "" || d.LicensingConfig.SecretName != "" +} + +// IsAutoUpgradeEnabled returns true if auto upgrade is enabled +func (d *DriverSpec) IsAutoUpgradeEnabled() bool { + if d.UpgradePolicy == nil { + return false + } + return d.UpgradePolicy.AutoUpgrade +} + +// IsEnabled returns true if device-plugin is enabled(default) through gpu-operator +func (p *DevicePluginSpec) IsEnabled() bool { + if p.Enabled == nil { + // default is true if not specified by user + return true + } + return *p.Enabled +} + +// IsEnabled returns true if dcgm-exporter is enabled(default) through gpu-operator +func (e *DCGMExporterSpec) IsEnabled() bool { + if e.Enabled == nil { + // default is true if not specified by user + return true + } + return *e.Enabled +} + +// IsHostPIDEnabled returns true if hostPID is enabled for DCGM Exporter +func (e *DCGMExporterSpec) IsHostPIDEnabled() bool { + if e.HostPID == nil { + // default is false if not specified by user + return false + } + return *e.HostPID +} + +// IsHostNetworkEnabled returns true if hostNetwork is enabled for DCGM Exporter +func (e *DCGMExporterSpec) IsHostNetworkEnabled() bool { + if e.HostNetwork == nil { + // default is false if not specified by user + return false + } + return *e.HostNetwork +} + +// IsHPCJobMappingEnabled returns true if HPC job mapping is enabled for DCGM Exporter +func (e *DCGMExporterSpec) IsHPCJobMappingEnabled() bool { + if e.HPCJobMapping == nil || e.HPCJobMapping.Enabled == nil { + // default is false if not specified by user + return false + } + return *e.HPCJobMapping.Enabled +} + +// GetHPCJobMappingDirectory returns the directory path for HPC job mapping +func (e *DCGMExporterSpec) GetHPCJobMappingDirectory() string { + if e.HPCJobMapping == nil { + return "" + } + return e.HPCJobMapping.Directory +} + +// IsPodLabelsEnabled returns true if pod-label enrichment is enabled for DCGM Exporter +func (e *DCGMExporterSpec) IsPodLabelsEnabled() bool { + if e.EnablePodLabels == nil { + // default is false if not specified by user + return false + } + return *e.EnablePodLabels +} + +// IsPodUIDEnabled returns true if pod-UID enrichment is enabled for DCGM Exporter +func (e *DCGMExporterSpec) IsPodUIDEnabled() bool { + if e.EnablePodUID == nil { + // default is false if not specified by user + return false + } + return *e.EnablePodUID +} + +// IsKubernetesPodMetadataEnabled returns true if any Kubernetes pod metadata +// enrichment is enabled for DCGM Exporter. +func (e *DCGMExporterSpec) IsKubernetesPodMetadataEnabled() bool { + return e.IsPodLabelsEnabled() || e.IsPodUIDEnabled() +} + +// IsEnabled returns true if gpu-feature-discovery is enabled(default) through gpu-operator +func (g *GPUFeatureDiscoverySpec) IsEnabled() bool { + if g.Enabled == nil { + // default is true if not specified by user + return true + } + return *g.Enabled +} + +// IsEnabled returns true if VFIO-PCI Manager install is enabled through gpu-operator +func (v *VFIOManagerSpec) IsEnabled() bool { + if v.Enabled == nil { + // default is false if not specified by user + return false + } + return *v.Enabled +} + +// IsEnabled returns true if vGPU Manager install is enabled through gpu-operator +func (d *VGPUManagerSpec) IsEnabled() bool { + if d.Enabled == nil { + // default is false if not specified by user + return false + } + return *d.Enabled +} + +// IsEnabled returns true if vGPU Device Manager is enabled through gpu-operator +func (v *VGPUDeviceManagerSpec) IsEnabled() bool { + if v.Enabled == nil { + // default is false if not specified by user + return false + } + return *v.Enabled +} + +// IsEnabled returns true if container-toolkit install is enabled(default) through gpu-operator +func (t *ToolkitSpec) IsEnabled() bool { + if t.Enabled == nil { + // default is true if not specified by user + return true + } + return *t.Enabled +} + +// IsEnabled returns true if the cluster intends to run GPU accelerated +// workloads in sandboxed environments (VMs). +func (s *SandboxWorkloadsSpec) IsEnabled() bool { + if s.Enabled == nil { + // Sandbox workloads are disabled by default + return false + } + return *s.Enabled +} + +// IsEnabled returns true if the sandbox device plugin is enabled through gpu-operator +func (s *SandboxDevicePluginSpec) IsEnabled() bool { + if s.Enabled == nil { + // default is false if not specified by user + return false + } + return *s.Enabled +} + +// IsEnabled returns true if the kata sandbox device plugin is enabled through gpu-operator +func (k *KataDevicePluginSpec) IsEnabled() bool { + if k.Enabled == nil { + // default is false if not specified by user + return false + } + return *k.Enabled +} + +// IsEnabled returns true if PodSecurityAdmission configuration is enabled for all gpu-operator pods +func (p *PSASpec) IsEnabled() bool { + if p.Enabled == nil { + // PSA is disabled by default + return false + } + return *p.Enabled +} + +// IsEnabled returns true if mig-manager is enabled(default) through gpu-operator +func (m *MIGManagerSpec) IsEnabled() bool { + if m.Enabled == nil { + // default is true if not specified by user + return true + } + return *m.Enabled +} + +// IsEnabled returns true if node-status-exporter is +// enabled through gpu-operator +func (m *NodeStatusExporterSpec) IsEnabled() bool { + if m.Enabled == nil { + // default is false if not specified by user + return false + } + return *m.Enabled +} + +// IsEnabled returns true if GPUDirect RDMA are enabled through gpu-operator +func (g *GPUDirectRDMASpec) IsEnabled() bool { + if g.Enabled == nil { + // GPUDirectRDMA is disabled by default + return false + } + return *g.Enabled +} + +// IsHostMOFED returns true if GPUDirect RDMA is enabled through MOFED installed on the host +func (g *GPUDirectRDMASpec) IsHostMOFED() bool { + if g.UseHostMOFED == nil { + // GPUDirectRDMA is disabled by default + return false + } + return g.IsEnabled() && *g.UseHostMOFED +} + +// IsEnabled returns true if GPUDirect Storage are enabled through gpu-operator +func (gds *GPUDirectStorageSpec) IsEnabled() bool { + if gds.Enabled == nil { + // GPUDirectStorage is disabled by default + return false + } + return *gds.Enabled +} + +// IsGDRCopyEnabled returns true if GDRCopy is enabled through gpu-operator +func (c *ClusterPolicySpec) IsGDRCopyEnabled() bool { + if c.GDRCopy == nil { + // GDRCopy is disabled by default + return false + } + return c.GDRCopy.IsEnabled() +} + +// IsEnabled returns true if GDRCopy is enabled through gpu-operator +func (gdrcopy *GDRCopySpec) IsEnabled() bool { + if gdrcopy.Enabled == nil { + // GDRCopy is disabled by default + return false + } + return *gdrcopy.Enabled +} + +// IsEnabled returns true if DCGM hostengine as a separate Pod is enabled through gpu-perator +func (dcgm *DCGMSpec) IsEnabled() bool { + if dcgm.Enabled == nil { + // DCGM is enabled by default + return true + } + return *dcgm.Enabled +} + +// IsEnabled returns true if ServiceMonitor is enabled through gpu-operator +func (sm *ServiceMonitorConfig) IsEnabled() bool { + if sm.Enabled == nil { + // ServiceMonitor is disabled by default + return false + } + return *sm.Enabled +} + +// IsNLSEnabled returns true if NLS should be used for licensing the driver +func (l *DriverLicensingConfigSpec) IsNLSEnabled() bool { + if l.NLSEnabled == nil { + // NLS is not enabled by default + return false + } + return *l.NLSEnabled +} + +// IsEnabled returns true if CDI is enabled as a mechanism for +// providing GPU access to containers +func (c *CDIConfigSpec) IsEnabled() bool { + if c.Enabled == nil { + return true + } + return *c.Enabled +} + +// IsNRIPluginEnabled returns true if NRI Plugin is enabled as a mechanism for +// injecting CDI devices to containers +func (c *CDIConfigSpec) IsNRIPluginEnabled() bool { + if c.NRIPluginEnabled == nil { + return false + } + return *c.NRIPluginEnabled +} + +// IsEnabled returns true if Kata Manager is enabled +func (k *KataManagerSpec) IsEnabled() bool { + if k.Enabled == nil { + return false + } + return *k.Enabled +} + +// IsEnabled returns true if CC Manager is enabled for configuring +// CC mode on compatible GPUs on the node +func (c *CCManagerSpec) IsEnabled() bool { + if c.Enabled == nil { + return false + } + return *c.Enabled +} + +// +kubebuilder:object:generate=false +type ConfigWithName interface { + GetName() string +} + +// GetConfigMapName returns the config's name if it's non-empty and differs from defaultName, +// otherwise returns defaultName. The boolean indicates whether a custom name was used. +func GetConfigMapName[T ConfigWithName](config T, defaultName string) (string, bool) { + if name := config.GetName(); name != "" { + return name, name != defaultName + } + return defaultName, false +} + +func (c *MIGGPUClientsConfigSpec) GetName() string { + return ptr.Deref(c, MIGGPUClientsConfigSpec{}).Name +} + +func (c *MIGPartedConfigSpec) GetName() string { + return ptr.Deref(c, MIGPartedConfigSpec{}).Name +} + +func (c *VGPUDevicesConfigSpec) GetName() string { + return ptr.Deref(c, VGPUDevicesConfigSpec{}).Name +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/groupversion_info.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/groupversion_info.go new file mode 100644 index 0000000000..157fdd932d --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/groupversion_info.go @@ -0,0 +1,43 @@ +/* +Copyright 2021. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +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. +*/ + +// Package v1 contains API Schema definitions for the clusterpolicy v1 API group +// +kubebuilder:object:generate=true +// +groupName=nvidia.com +package v1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "nvidia.com", Version: "v1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, &ClusterPolicy{}, &ClusterPolicyList{}) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/zz_generated.deepcopy.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..9e936de60d --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1/zz_generated.deepcopy.go @@ -0,0 +1,1893 @@ +//go:build !ignore_autogenerated + +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1 + +import ( + "github.com/NVIDIA/k8s-kata-manager/api/v1alpha1/config" + "github.com/NVIDIA/k8s-operator-libs/api/upgrade/v1alpha1" + monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CCManagerSpec) DeepCopyInto(out *CCManagerSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CCManagerSpec. +func (in *CCManagerSpec) DeepCopy() *CCManagerSpec { + if in == nil { + return nil + } + out := new(CCManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CDIConfigSpec) DeepCopyInto(out *CDIConfigSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Default != nil { + in, out := &in.Default, &out.Default + *out = new(bool) + **out = **in + } + if in.NRIPluginEnabled != nil { + in, out := &in.NRIPluginEnabled, &out.NRIPluginEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CDIConfigSpec. +func (in *CDIConfigSpec) DeepCopy() *CDIConfigSpec { + if in == nil { + return nil + } + out := new(CDIConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CUDAValidatorSpec) DeepCopyInto(out *CUDAValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CUDAValidatorSpec. +func (in *CUDAValidatorSpec) DeepCopy() *CUDAValidatorSpec { + if in == nil { + return nil + } + out := new(CUDAValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPolicy) DeepCopyInto(out *ClusterPolicy) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPolicy. +func (in *ClusterPolicy) DeepCopy() *ClusterPolicy { + if in == nil { + return nil + } + out := new(ClusterPolicy) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterPolicy) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPolicyList) DeepCopyInto(out *ClusterPolicyList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterPolicy, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPolicyList. +func (in *ClusterPolicyList) DeepCopy() *ClusterPolicyList { + if in == nil { + return nil + } + out := new(ClusterPolicyList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterPolicyList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPolicySpec) DeepCopyInto(out *ClusterPolicySpec) { + *out = *in + in.Operator.DeepCopyInto(&out.Operator) + in.Daemonsets.DeepCopyInto(&out.Daemonsets) + in.Driver.DeepCopyInto(&out.Driver) + in.Toolkit.DeepCopyInto(&out.Toolkit) + in.DevicePlugin.DeepCopyInto(&out.DevicePlugin) + in.DCGMExporter.DeepCopyInto(&out.DCGMExporter) + in.DCGM.DeepCopyInto(&out.DCGM) + in.NodeStatusExporter.DeepCopyInto(&out.NodeStatusExporter) + in.GPUFeatureDiscovery.DeepCopyInto(&out.GPUFeatureDiscovery) + out.MIG = in.MIG + in.MIGManager.DeepCopyInto(&out.MIGManager) + in.PSP.DeepCopyInto(&out.PSP) + in.PSA.DeepCopyInto(&out.PSA) + in.Validator.DeepCopyInto(&out.Validator) + if in.GPUDirectStorage != nil { + in, out := &in.GPUDirectStorage, &out.GPUDirectStorage + *out = new(GPUDirectStorageSpec) + (*in).DeepCopyInto(*out) + } + if in.GDRCopy != nil { + in, out := &in.GDRCopy, &out.GDRCopy + *out = new(GDRCopySpec) + (*in).DeepCopyInto(*out) + } + in.SandboxWorkloads.DeepCopyInto(&out.SandboxWorkloads) + in.VFIOManager.DeepCopyInto(&out.VFIOManager) + in.SandboxDevicePlugin.DeepCopyInto(&out.SandboxDevicePlugin) + in.VGPUManager.DeepCopyInto(&out.VGPUManager) + in.VGPUDeviceManager.DeepCopyInto(&out.VGPUDeviceManager) + in.CDI.DeepCopyInto(&out.CDI) + in.KataManager.DeepCopyInto(&out.KataManager) + in.CCManager.DeepCopyInto(&out.CCManager) + out.HostPaths = in.HostPaths + in.KataSandboxDevicePlugin.DeepCopyInto(&out.KataSandboxDevicePlugin) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPolicySpec. +func (in *ClusterPolicySpec) DeepCopy() *ClusterPolicySpec { + if in == nil { + return nil + } + out := new(ClusterPolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterPolicyStatus) DeepCopyInto(out *ClusterPolicyStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterPolicyStatus. +func (in *ClusterPolicyStatus) DeepCopy() *ClusterPolicyStatus { + if in == nil { + return nil + } + out := new(ClusterPolicyStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ComponentCommonSpec) DeepCopyInto(out *ComponentCommonSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ComponentCommonSpec. +func (in *ComponentCommonSpec) DeepCopy() *ComponentCommonSpec { + if in == nil { + return nil + } + out := new(ComponentCommonSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerProbeSpec) DeepCopyInto(out *ContainerProbeSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerProbeSpec. +func (in *ContainerProbeSpec) DeepCopy() *ContainerProbeSpec { + if in == nil { + return nil + } + out := new(ContainerProbeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DCGMExporterHPCJobMappingConfig) DeepCopyInto(out *DCGMExporterHPCJobMappingConfig) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DCGMExporterHPCJobMappingConfig. +func (in *DCGMExporterHPCJobMappingConfig) DeepCopy() *DCGMExporterHPCJobMappingConfig { + if in == nil { + return nil + } + out := new(DCGMExporterHPCJobMappingConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DCGMExporterMetricsConfig) DeepCopyInto(out *DCGMExporterMetricsConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DCGMExporterMetricsConfig. +func (in *DCGMExporterMetricsConfig) DeepCopy() *DCGMExporterMetricsConfig { + if in == nil { + return nil + } + out := new(DCGMExporterMetricsConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DCGMExporterServiceConfig) DeepCopyInto(out *DCGMExporterServiceConfig) { + *out = *in + if in.InternalTrafficPolicy != nil { + in, out := &in.InternalTrafficPolicy, &out.InternalTrafficPolicy + *out = new(corev1.ServiceInternalTrafficPolicy) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DCGMExporterServiceConfig. +func (in *DCGMExporterServiceConfig) DeepCopy() *DCGMExporterServiceConfig { + if in == nil { + return nil + } + out := new(DCGMExporterServiceConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DCGMExporterSpec) DeepCopyInto(out *DCGMExporterSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.MetricsConfig != nil { + in, out := &in.MetricsConfig, &out.MetricsConfig + *out = new(DCGMExporterMetricsConfig) + **out = **in + } + if in.ServiceMonitor != nil { + in, out := &in.ServiceMonitor, &out.ServiceMonitor + *out = new(ServiceMonitorConfig) + (*in).DeepCopyInto(*out) + } + if in.ServiceSpec != nil { + in, out := &in.ServiceSpec, &out.ServiceSpec + *out = new(DCGMExporterServiceConfig) + (*in).DeepCopyInto(*out) + } + if in.HostPID != nil { + in, out := &in.HostPID, &out.HostPID + *out = new(bool) + **out = **in + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } + if in.HPCJobMapping != nil { + in, out := &in.HPCJobMapping, &out.HPCJobMapping + *out = new(DCGMExporterHPCJobMappingConfig) + (*in).DeepCopyInto(*out) + } + if in.EnablePodLabels != nil { + in, out := &in.EnablePodLabels, &out.EnablePodLabels + *out = new(bool) + **out = **in + } + if in.EnablePodUID != nil { + in, out := &in.EnablePodUID, &out.EnablePodUID + *out = new(bool) + **out = **in + } + if in.PodLabelAllowlistRegex != nil { + in, out := &in.PodLabelAllowlistRegex, &out.PodLabelAllowlistRegex + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DCGMExporterSpec. +func (in *DCGMExporterSpec) DeepCopy() *DCGMExporterSpec { + if in == nil { + return nil + } + out := new(DCGMExporterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DCGMSpec) DeepCopyInto(out *DCGMSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DCGMSpec. +func (in *DCGMSpec) DeepCopy() *DCGMSpec { + if in == nil { + return nil + } + out := new(DCGMSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DaemonsetsSpec) DeepCopyInto(out *DaemonsetsSpec) { + *out = *in + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]corev1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RollingUpdate != nil { + in, out := &in.RollingUpdate, &out.RollingUpdate + *out = new(RollingUpdateSpec) + **out = **in + } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DaemonsetsSpec. +func (in *DaemonsetsSpec) DeepCopy() *DaemonsetsSpec { + if in == nil { + return nil + } + out := new(DaemonsetsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevicePluginConfig) DeepCopyInto(out *DevicePluginConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevicePluginConfig. +func (in *DevicePluginConfig) DeepCopy() *DevicePluginConfig { + if in == nil { + return nil + } + out := new(DevicePluginConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DevicePluginSpec) DeepCopyInto(out *DevicePluginSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = new(DevicePluginConfig) + **out = **in + } + if in.MPS != nil { + in, out := &in.MPS, &out.MPS + *out = new(MPSConfig) + **out = **in + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DevicePluginSpec. +func (in *DevicePluginSpec) DeepCopy() *DevicePluginSpec { + if in == nil { + return nil + } + out := new(DevicePluginSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverCertConfigSpec) DeepCopyInto(out *DriverCertConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverCertConfigSpec. +func (in *DriverCertConfigSpec) DeepCopy() *DriverCertConfigSpec { + if in == nil { + return nil + } + out := new(DriverCertConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverLicensingConfigSpec) DeepCopyInto(out *DriverLicensingConfigSpec) { + *out = *in + if in.NLSEnabled != nil { + in, out := &in.NLSEnabled, &out.NLSEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverLicensingConfigSpec. +func (in *DriverLicensingConfigSpec) DeepCopy() *DriverLicensingConfigSpec { + if in == nil { + return nil + } + out := new(DriverLicensingConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverManagerSpec) DeepCopyInto(out *DriverManagerSpec) { + *out = *in + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverManagerSpec. +func (in *DriverManagerSpec) DeepCopy() *DriverManagerSpec { + if in == nil { + return nil + } + out := new(DriverManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverRepoConfigSpec) DeepCopyInto(out *DriverRepoConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverRepoConfigSpec. +func (in *DriverRepoConfigSpec) DeepCopy() *DriverRepoConfigSpec { + if in == nil { + return nil + } + out := new(DriverRepoConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverSpec) DeepCopyInto(out *DriverSpec) { + *out = *in + if in.UseNvidiaDriverCRD != nil { + in, out := &in.UseNvidiaDriverCRD, &out.UseNvidiaDriverCRD + *out = new(bool) + **out = **in + } + if in.UsePrecompiled != nil { + in, out := &in.UsePrecompiled, &out.UsePrecompiled + *out = new(bool) + **out = **in + } + if in.UseOpenKernelModules != nil { + in, out := &in.UseOpenKernelModules, &out.UseOpenKernelModules + *out = new(bool) + **out = **in + } + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.StartupProbe != nil { + in, out := &in.StartupProbe, &out.StartupProbe + *out = new(ContainerProbeSpec) + **out = **in + } + if in.LivenessProbe != nil { + in, out := &in.LivenessProbe, &out.LivenessProbe + *out = new(ContainerProbeSpec) + **out = **in + } + if in.ReadinessProbe != nil { + in, out := &in.ReadinessProbe, &out.ReadinessProbe + *out = new(ContainerProbeSpec) + **out = **in + } + if in.GPUDirectRDMA != nil { + in, out := &in.GPUDirectRDMA, &out.GPUDirectRDMA + *out = new(GPUDirectRDMASpec) + (*in).DeepCopyInto(*out) + } + if in.UpgradePolicy != nil { + in, out := &in.UpgradePolicy, &out.UpgradePolicy + *out = new(v1alpha1.DriverUpgradePolicySpec) + (*in).DeepCopyInto(*out) + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Manager.DeepCopyInto(&out.Manager) + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.RepoConfig != nil { + in, out := &in.RepoConfig, &out.RepoConfig + *out = new(DriverRepoConfigSpec) + **out = **in + } + if in.CertConfig != nil { + in, out := &in.CertConfig, &out.CertConfig + *out = new(DriverCertConfigSpec) + **out = **in + } + if in.LicensingConfig != nil { + in, out := &in.LicensingConfig, &out.LicensingConfig + *out = new(DriverLicensingConfigSpec) + (*in).DeepCopyInto(*out) + } + if in.VirtualTopology != nil { + in, out := &in.VirtualTopology, &out.VirtualTopology + *out = new(VirtualTopologyConfigSpec) + **out = **in + } + if in.KernelModuleConfig != nil { + in, out := &in.KernelModuleConfig, &out.KernelModuleConfig + *out = new(KernelModuleConfigSpec) + **out = **in + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverSpec. +func (in *DriverSpec) DeepCopy() *DriverSpec { + if in == nil { + return nil + } + out := new(DriverSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverValidatorSpec) DeepCopyInto(out *DriverValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverValidatorSpec. +func (in *DriverValidatorSpec) DeepCopy() *DriverValidatorSpec { + if in == nil { + return nil + } + out := new(DriverValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvVar) DeepCopyInto(out *EnvVar) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvVar. +func (in *EnvVar) DeepCopy() *EnvVar { + if in == nil { + return nil + } + out := new(EnvVar) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GDRCopySpec) DeepCopyInto(out *GDRCopySpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GDRCopySpec. +func (in *GDRCopySpec) DeepCopy() *GDRCopySpec { + if in == nil { + return nil + } + out := new(GDRCopySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUDirectRDMASpec) DeepCopyInto(out *GPUDirectRDMASpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.UseHostMOFED != nil { + in, out := &in.UseHostMOFED, &out.UseHostMOFED + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUDirectRDMASpec. +func (in *GPUDirectRDMASpec) DeepCopy() *GPUDirectRDMASpec { + if in == nil { + return nil + } + out := new(GPUDirectRDMASpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUDirectStorageSpec) DeepCopyInto(out *GPUDirectStorageSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUDirectStorageSpec. +func (in *GPUDirectStorageSpec) DeepCopy() *GPUDirectStorageSpec { + if in == nil { + return nil + } + out := new(GPUDirectStorageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUFeatureDiscoverySpec) DeepCopyInto(out *GPUFeatureDiscoverySpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUFeatureDiscoverySpec. +func (in *GPUFeatureDiscoverySpec) DeepCopy() *GPUFeatureDiscoverySpec { + if in == nil { + return nil + } + out := new(GPUFeatureDiscoverySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostPathsSpec) DeepCopyInto(out *HostPathsSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostPathsSpec. +func (in *HostPathsSpec) DeepCopy() *HostPathsSpec { + if in == nil { + return nil + } + out := new(HostPathsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ImageSpec) DeepCopyInto(out *ImageSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ImageSpec. +func (in *ImageSpec) DeepCopy() *ImageSpec { + if in == nil { + return nil + } + out := new(ImageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *InitContainerSpec) DeepCopyInto(out *InitContainerSpec) { + *out = *in + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InitContainerSpec. +func (in *InitContainerSpec) DeepCopy() *InitContainerSpec { + if in == nil { + return nil + } + out := new(InitContainerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KataDevicePluginSpec) DeepCopyInto(out *KataDevicePluginSpec) { + *out = *in + out.ImageSpec = in.ImageSpec + in.ComponentCommonSpec.DeepCopyInto(&out.ComponentCommonSpec) + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KataDevicePluginSpec. +func (in *KataDevicePluginSpec) DeepCopy() *KataDevicePluginSpec { + if in == nil { + return nil + } + out := new(KataDevicePluginSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KataManagerSpec) DeepCopyInto(out *KataManagerSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = new(config.Config) + (*in).DeepCopyInto(*out) + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KataManagerSpec. +func (in *KataManagerSpec) DeepCopy() *KataManagerSpec { + if in == nil { + return nil + } + out := new(KataManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KernelModuleConfigSpec) DeepCopyInto(out *KernelModuleConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KernelModuleConfigSpec. +func (in *KernelModuleConfigSpec) DeepCopy() *KernelModuleConfigSpec { + if in == nil { + return nil + } + out := new(KernelModuleConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MIGGPUClientsConfigSpec) DeepCopyInto(out *MIGGPUClientsConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MIGGPUClientsConfigSpec. +func (in *MIGGPUClientsConfigSpec) DeepCopy() *MIGGPUClientsConfigSpec { + if in == nil { + return nil + } + out := new(MIGGPUClientsConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MIGManagerSpec) DeepCopyInto(out *MIGManagerSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = new(MIGPartedConfigSpec) + **out = **in + } + if in.GPUClientsConfig != nil { + in, out := &in.GPUClientsConfig, &out.GPUClientsConfig + *out = new(MIGGPUClientsConfigSpec) + **out = **in + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MIGManagerSpec. +func (in *MIGManagerSpec) DeepCopy() *MIGManagerSpec { + if in == nil { + return nil + } + out := new(MIGManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MIGPartedConfigSpec) DeepCopyInto(out *MIGPartedConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MIGPartedConfigSpec. +func (in *MIGPartedConfigSpec) DeepCopy() *MIGPartedConfigSpec { + if in == nil { + return nil + } + out := new(MIGPartedConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MIGSpec) DeepCopyInto(out *MIGSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MIGSpec. +func (in *MIGSpec) DeepCopy() *MIGSpec { + if in == nil { + return nil + } + out := new(MIGSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MPSConfig) DeepCopyInto(out *MPSConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MPSConfig. +func (in *MPSConfig) DeepCopy() *MPSConfig { + if in == nil { + return nil + } + out := new(MPSConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStatusExporterSpec) DeepCopyInto(out *NodeStatusExporterSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStatusExporterSpec. +func (in *NodeStatusExporterSpec) DeepCopy() *NodeStatusExporterSpec { + if in == nil { + return nil + } + out := new(NodeStatusExporterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorMetricsSpec) DeepCopyInto(out *OperatorMetricsSpec) { + *out = *in + if in.ServiceMonitor != nil { + in, out := &in.ServiceMonitor, &out.ServiceMonitor + *out = new(ServiceMonitorConfig) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorMetricsSpec. +func (in *OperatorMetricsSpec) DeepCopy() *OperatorMetricsSpec { + if in == nil { + return nil + } + out := new(OperatorMetricsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OperatorSpec) DeepCopyInto(out *OperatorSpec) { + *out = *in + in.InitContainer.DeepCopyInto(&out.InitContainer) + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + in.Metrics.DeepCopyInto(&out.Metrics) + if in.UseOpenShiftDriverToolkit != nil { + in, out := &in.UseOpenShiftDriverToolkit, &out.UseOpenShiftDriverToolkit + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OperatorSpec. +func (in *OperatorSpec) DeepCopy() *OperatorSpec { + if in == nil { + return nil + } + out := new(OperatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PSASpec) DeepCopyInto(out *PSASpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PSASpec. +func (in *PSASpec) DeepCopy() *PSASpec { + if in == nil { + return nil + } + out := new(PSASpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PSPSpec) DeepCopyInto(out *PSPSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PSPSpec. +func (in *PSPSpec) DeepCopy() *PSPSpec { + if in == nil { + return nil + } + out := new(PSPSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PluginValidatorSpec) DeepCopyInto(out *PluginValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PluginValidatorSpec. +func (in *PluginValidatorSpec) DeepCopy() *PluginValidatorSpec { + if in == nil { + return nil + } + out := new(PluginValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceRequirements) DeepCopyInto(out *ResourceRequirements) { + *out = *in + if in.Limits != nil { + in, out := &in.Limits, &out.Limits + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Requests != nil { + in, out := &in.Requests, &out.Requests + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRequirements. +func (in *ResourceRequirements) DeepCopy() *ResourceRequirements { + if in == nil { + return nil + } + out := new(ResourceRequirements) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RollingUpdateSpec) DeepCopyInto(out *RollingUpdateSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RollingUpdateSpec. +func (in *RollingUpdateSpec) DeepCopy() *RollingUpdateSpec { + if in == nil { + return nil + } + out := new(RollingUpdateSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SandboxDevicePluginSpec) DeepCopyInto(out *SandboxDevicePluginSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SandboxDevicePluginSpec. +func (in *SandboxDevicePluginSpec) DeepCopy() *SandboxDevicePluginSpec { + if in == nil { + return nil + } + out := new(SandboxDevicePluginSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SandboxWorkloadsSpec) DeepCopyInto(out *SandboxWorkloadsSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SandboxWorkloadsSpec. +func (in *SandboxWorkloadsSpec) DeepCopy() *SandboxWorkloadsSpec { + if in == nil { + return nil + } + out := new(SandboxWorkloadsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ServiceMonitorConfig) DeepCopyInto(out *ServiceMonitorConfig) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.HonorLabels != nil { + in, out := &in.HonorLabels, &out.HonorLabels + *out = new(bool) + **out = **in + } + if in.AdditionalLabels != nil { + in, out := &in.AdditionalLabels, &out.AdditionalLabels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Relabelings != nil { + in, out := &in.Relabelings, &out.Relabelings + *out = make([]*monitoringv1.RelabelConfig, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(monitoringv1.RelabelConfig) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ServiceMonitorConfig. +func (in *ServiceMonitorConfig) DeepCopy() *ServiceMonitorConfig { + if in == nil { + return nil + } + out := new(ServiceMonitorConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ToolkitSpec) DeepCopyInto(out *ToolkitSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ToolkitSpec. +func (in *ToolkitSpec) DeepCopy() *ToolkitSpec { + if in == nil { + return nil + } + out := new(ToolkitSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ToolkitValidatorSpec) DeepCopyInto(out *ToolkitValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ToolkitValidatorSpec. +func (in *ToolkitValidatorSpec) DeepCopy() *ToolkitValidatorSpec { + if in == nil { + return nil + } + out := new(ToolkitValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VFIOManagerSpec) DeepCopyInto(out *VFIOManagerSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + in.DriverManager.DeepCopyInto(&out.DriverManager) + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VFIOManagerSpec. +func (in *VFIOManagerSpec) DeepCopy() *VFIOManagerSpec { + if in == nil { + return nil + } + out := new(VFIOManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VFIOPCIValidatorSpec) DeepCopyInto(out *VFIOPCIValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VFIOPCIValidatorSpec. +func (in *VFIOPCIValidatorSpec) DeepCopy() *VFIOPCIValidatorSpec { + if in == nil { + return nil + } + out := new(VFIOPCIValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VGPUDeviceManagerSpec) DeepCopyInto(out *VGPUDeviceManagerSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.Config != nil { + in, out := &in.Config, &out.Config + *out = new(VGPUDevicesConfigSpec) + **out = **in + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VGPUDeviceManagerSpec. +func (in *VGPUDeviceManagerSpec) DeepCopy() *VGPUDeviceManagerSpec { + if in == nil { + return nil + } + out := new(VGPUDeviceManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VGPUDevicesConfigSpec) DeepCopyInto(out *VGPUDevicesConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VGPUDevicesConfigSpec. +func (in *VGPUDevicesConfigSpec) DeepCopy() *VGPUDevicesConfigSpec { + if in == nil { + return nil + } + out := new(VGPUDevicesConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VGPUDevicesValidatorSpec) DeepCopyInto(out *VGPUDevicesValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VGPUDevicesValidatorSpec. +func (in *VGPUDevicesValidatorSpec) DeepCopy() *VGPUDevicesValidatorSpec { + if in == nil { + return nil + } + out := new(VGPUDevicesValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VGPUManagerSpec) DeepCopyInto(out *VGPUManagerSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + in.DriverManager.DeepCopyInto(&out.DriverManager) + if in.KernelModuleConfig != nil { + in, out := &in.KernelModuleConfig, &out.KernelModuleConfig + *out = new(KernelModuleConfigSpec) + **out = **in + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VGPUManagerSpec. +func (in *VGPUManagerSpec) DeepCopy() *VGPUManagerSpec { + if in == nil { + return nil + } + out := new(VGPUManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VGPUManagerValidatorSpec) DeepCopyInto(out *VGPUManagerValidatorSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VGPUManagerValidatorSpec. +func (in *VGPUManagerValidatorSpec) DeepCopy() *VGPUManagerValidatorSpec { + if in == nil { + return nil + } + out := new(VGPUManagerValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ValidatorSpec) DeepCopyInto(out *ValidatorSpec) { + *out = *in + in.Plugin.DeepCopyInto(&out.Plugin) + in.Toolkit.DeepCopyInto(&out.Toolkit) + in.Driver.DeepCopyInto(&out.Driver) + in.CUDA.DeepCopyInto(&out.CUDA) + in.VFIOPCI.DeepCopyInto(&out.VFIOPCI) + in.VGPUManager.DeepCopyInto(&out.VGPUManager) + in.VGPUDevices.DeepCopyInto(&out.VGPUDevices) + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidatorSpec. +func (in *ValidatorSpec) DeepCopy() *ValidatorSpec { + if in == nil { + return nil + } + out := new(ValidatorSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualTopologyConfigSpec) DeepCopyInto(out *VirtualTopologyConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualTopologyConfigSpec. +func (in *VirtualTopologyConfigSpec) DeepCopy() *VirtualTopologyConfigSpec { + if in == nil { + return nil + } + out := new(VirtualTopologyConfigSpec) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/gpucluster_types.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/gpucluster_types.go new file mode 100644 index 0000000000..5b6836213e --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/gpucluster_types.go @@ -0,0 +1,202 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + nvidiav1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" +) + +const ( + GPUClusterCRDName = "GPUCluster" +) + +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// GPUClusterSpec defines the desired state of GPUCluster, the DRA-based +// software-enablement stack. Unlike ClusterPolicy, it does not manage the NVIDIA driver +// or the device-plugin; the driver is installed separately (host-installed or via an +// NVIDIADriver CR) and GPUCluster waits for driver readiness before proceeding. +type GPUClusterSpec struct { + // DRADriver defines the spec for the NVIDIA DRA driver stack (gpus + computeDomains). + DRADriver DRADriverSpec `json:"draDriver"` + + // DCGM defines the spec for the standalone NVIDIA DCGM hostengine. Disabled by default; + // when disabled, dcgm-exporter uses its embedded nv-hostengine. NOTE: the reused enabled + // field carries no server-side default and its IsEnabled() treats nil as enabled, so the + // controller must default nil enabled to disabled here. + DCGM *nvidiav1.DCGMSpec `json:"dcgm,omitempty"` + + // DCGMExporter defines the spec for NVIDIA DCGM Exporter. Enabled by default, but the + // reused enabled field carries no server-side default; the controller defaults nil enabled. + DCGMExporter *nvidiav1.DCGMExporterSpec `json:"dcgmExporter,omitempty"` + + // HostPaths defines the host paths used in host-path volumes for various components. + HostPaths HostPathsSpec `json:"hostPaths,omitempty"` + + // Daemonsets defines the common configuration applied to all DaemonSets deployed + // by the GPUCluster controller. + Daemonsets nvidiav1.DaemonsetsSpec `json:"daemonsets,omitempty"` +} + +// DRADriverSpec defines the spec for the NVIDIA DRA driver stack. There is no top-level +// enabled toggle; the gpus capability is always deployed and computeDomains has its own +// enabled field. +type DRADriverSpec struct { + // NVIDIA DRA driver image repository + Repository string `json:"repository,omitempty"` + + // NVIDIA DRA driver image name + // +kubebuilder:validation:Pattern=^[a-zA-Z0-9\-]+$ + Image string `json:"image,omitempty"` + + // NVIDIA DRA driver image tag + Version string `json:"version,omitempty"` + + // Image pull policy + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // FeatureGates is a map of feature gate names to a boolean enabling or disabling each. + // It is rendered as the FEATURE_GATES environment variable on the DRA driver containers. + FeatureGates map[string]bool `json:"featureGates,omitempty"` + + // GPUs configures the gpu.nvidia.com capability of the DRA driver. + GPUs DRADriverGPUsSpec `json:"gpus,omitempty"` + + // ComputeDomains configures the compute-domain capability of the DRA driver. + ComputeDomains DRADriverComputeDomainsSpec `json:"computeDomains,omitempty"` +} + +// IsComputeDomainsEnabled returns true if the computeDomains capability of the DRA driver is enabled. +func (d *DRADriverSpec) IsComputeDomainsEnabled() bool { + return d.ComputeDomains.Enabled != nil && *d.ComputeDomains.Enabled +} + +// DRADriverGPUsSpec configures the gpus capability of the DRA driver. It maps onto the +// gpus container of the upstream kubelet-plugin DaemonSet. The capability is always +// deployed; there is no enabled toggle. +type DRADriverGPUsSpec struct { + // KubeletPlugin configures the kubelet-plugin workload for the gpus capability. + KubeletPlugin DRADriverKubeletPluginSpec `json:"kubeletPlugin,omitempty"` +} + +// DRADriverComputeDomainsSpec configures the computeDomains capability of the DRA driver. +// The kubeletPlugin maps onto the computeDomains container of the upstream kubelet-plugin +// DaemonSet; the controller is a separate Deployment. +type DRADriverComputeDomainsSpec struct { + // Enabled indicates if the computeDomains capability of the DRA driver is enabled. + // +kubebuilder:default=true + Enabled *bool `json:"enabled,omitempty"` + + // Controller configures the compute-domain controller Deployment. + Controller DRADriverControllerSpec `json:"controller,omitempty"` + + // KubeletPlugin configures the kubelet-plugin workload for the computeDomains capability. + KubeletPlugin DRADriverKubeletPluginSpec `json:"kubeletPlugin,omitempty"` +} + +// DRADriverKubeletPluginSpec configures a DRA driver kubelet-plugin container. The gpus and +// computeDomains blocks map onto the two containers of a single kubelet-plugin DaemonSet. +// Scheduling is opinionated and not configurable here. +type DRADriverKubeletPluginSpec struct { + // Optional: List of environment variables + Env []nvidiav1.EnvVar `json:"env,omitempty"` + + // Optional: Define resources requests and limits for the kubelet-plugin container + Resources *nvidiav1.ResourceRequirements `json:"resources,omitempty"` + + // Optional: Configure the container's gRPC health service and its probes + Healthcheck *DRADriverHealthcheckSpec `json:"healthcheck,omitempty"` +} + +// DRADriverHealthcheckSpec configures the gRPC health service of a kubelet-plugin +// container, checked by the startup and liveness probes. +type DRADriverHealthcheckSpec struct { + // +kubebuilder:default=true + Enabled *bool `json:"enabled,omitempty"` + + // Defaults to 51516 for the gpus container and 51515 for the computeDomains container. + // +kubebuilder:validation:Minimum=1 + // +kubebuilder:validation:Maximum=65535 + Port *int32 `json:"port,omitempty"` +} + +// DRADriverControllerSpec defines configuration for the compute-domain controller Deployment. +// Scheduling is opinionated and not configurable here. +type DRADriverControllerSpec struct { + // Optional: List of environment variables + Env []nvidiav1.EnvVar `json:"env,omitempty"` + + // Optional: Define resources requests and limits for the controller container + Resources *nvidiav1.ResourceRequirements `json:"resources,omitempty"` +} + +// HostPathsSpec defines various paths on the host needed by GPU Operator components. +// Unlike the v1 ClusterPolicy struct it mirrors, it has no RootFS: the host root is +// hard-coded to "/" for the DRA stack. +type HostPathsSpec struct { + // DriverInstallDir represents the root at which driver files including libraries, + // config files, and executables can be found. + DriverInstallDir string `json:"driverInstallDir,omitempty"` + + // KubeletRootDir represents the location of the kubelet root directory. + // If empty, it will default to "/var/lib/kubelet". + // +kubebuilder:default="/var/lib/kubelet" + KubeletRootDir string `json:"kubeletRootDir,omitempty"` +} + +// GPUClusterStatus defines the observed state of GPUCluster +type GPUClusterStatus struct { + // +kubebuilder:validation:Enum=ready;notReady;disabled + // State indicates the status of the GPUCluster instance + State State `json:"state"` + // Namespace indicates the namespace in which the operator and operands are installed + Namespace string `json:"namespace,omitempty"` + // Conditions is a list of conditions representing the GPUCluster's current state. + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +genclient +// +genclient:nonNamespaced +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:resource:scope=Cluster,shortName={"gc"} +//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0 +//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`,priority=0 +//+kubebuilder:validation:XValidation:rule="self.metadata.name == 'gpu-cluster'",message="GPUCluster is a singleton, metadata.name must be 'gpu-cluster'" + +// GPUCluster is the Schema for the gpuclusters API +type GPUCluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec GPUClusterSpec `json:"spec,omitempty"` + Status GPUClusterStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// GPUClusterList contains a list of GPUCluster +type GPUClusterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []GPUCluster `json:"items"` +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/groupversion_info.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/groupversion_info.go new file mode 100644 index 0000000000..c3c60f7769 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/groupversion_info.go @@ -0,0 +1,44 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Package v1alpha1 contains API Schema definitions for the nvidia v1alpha1 API group +// +kubebuilder:object:generate=true +// +groupName=nvidia.com +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + // SchemeGroupVersion is group version used to register these objects + SchemeGroupVersion = schema.GroupVersion{Group: "nvidia.com", Version: "v1alpha1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) + +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, &NVIDIADriver{}, &NVIDIADriverList{}) + scheme.AddKnownTypes(SchemeGroupVersion, &GPUCluster{}, &GPUClusterList{}) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/nvidiadriver_types.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/nvidiadriver_types.go new file mode 100644 index 0000000000..425f9ce809 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/nvidiadriver_types.go @@ -0,0 +1,904 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +package v1alpha1 + +import ( + "fmt" + "strings" + + "github.com/regclient/regclient/types/ref" + "golang.org/x/mod/semver" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + + upgrade_v1alpha1 "github.com/NVIDIA/k8s-operator-libs/api/upgrade/v1alpha1" + + "github.com/NVIDIA/gpu-operator/api/image" +) + +const ( + NVIDIADriverCRDName = "NVIDIADriver" + + // NVIDIADriverOwnerLabel is an operator-managed node label used to route each GPU node to one NVIDIADriver. + NVIDIADriverOwnerLabel = "nvidia.com/gpu-operator.driver.owner" + + // MinimumGDSVersionForOpenRM indicates the minimum GDS version that is supported only with OpenRM driver + MinimumGDSVersionForOpenRM = "v2.17.5" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// NVIDIADriverSpec defines the desired state of NVIDIADriver. +// The CEL validation allows non-default drivers to use nodeSelector, but requires +// default drivers to leave nodeSelector unset or empty. +// +kubebuilder:validation:XValidation:rule="has(self.default) && self.default ? !has(self.nodeSelector) || size(self.nodeSelector) == 0 : true",message="default NVIDIADriver must not use nodeSelector" +type NVIDIADriverSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Default indicates that this NVIDIADriver acts as the fallback driver daemon set manager for GPU nodes + // that do not match any non-default NVIDIADriver nodeSelector. + // +kubebuilder:default=false + Default bool `json:"default"` + + // +kubebuilder:validation:Enum=gpu;vgpu;vgpu-host-manager + // +kubebuilder:default=gpu + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="driverType is an immutable field. Please create a new NvidiaDriver resource instead when you want to change this setting." + DriverType DriverType `json:"driverType"` + + // UsePrecompiled indicates if deployment of NVIDIA Driver using pre-compiled modules is enabled + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Driver deployment using pre-compiled modules" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="usePrecompiled is an immutable field. Please create a new NvidiaDriver resource instead when you want to change this setting." + UsePrecompiled *bool `json:"usePrecompiled,omitempty"` + + // Deprecated: This field is no longer honored by the gpu-operator. Please use KernelModuleType instead. + // UseOpenKernelModules indicates if the open GPU kernel modules should be used + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable use of open GPU kernel modules" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch,urn:alm:descriptor:com.tectonic.ui:hidden" + UseOpenKernelModules *bool `json:"useOpenKernelModules,omitempty"` + + // KernelModuleType represents the type of driver kernel modules to be used when installing the GPU driver. + // Accepted values are auto, proprietary and open. NOTE: If auto is chosen, it means that the recommended kernel module + // type is chosen based on the GPU devices on the host and the driver branch used + // +kubebuilder:validation:Enum=auto;open;proprietary + // +kubebuilder:default=auto + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Kernel Module Type" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.description="Kernel Module Type" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:select:auto,urn:alm:descriptor:com.tectonic.ui:select:open,urn:alm:descriptor:com.tectonic.ui:select:proprietary" + KernelModuleType string `json:"kernelModuleType,omitempty"` + + // NVIDIA Driver container startup probe settings + StartupProbe *ContainerProbeSpec `json:"startupProbe,omitempty"` + + // NVIDIA Driver container liveness probe settings + LivenessProbe *ContainerProbeSpec `json:"livenessProbe,omitempty"` + + // NVIDIA Driver container readiness probe settings + ReadinessProbe *ContainerProbeSpec `json:"readinessProbe,omitempty"` + + // GPUDirectRDMA defines the spec for NVIDIA Peer Memory driver + GPUDirectRDMA *GPUDirectRDMASpec `json:"rdma,omitempty"` + + // GPUDirectStorage defines the spec for GDS driver + GPUDirectStorage *GPUDirectStorageSpec `json:"gds,omitempty"` + + // GDRCopy defines the spec for GDRCopy driver + GDRCopy *GDRCopySpec `json:"gdrcopy,omitempty"` + + // NVIDIA Driver repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA Driver container image name + // +kubebuilder:default=nvcr.io/nvidia/driver + Image string `json:"image"` + + // NVIDIA Driver version (or just branch for precompiled drivers) + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Manager represents configuration for NVIDIA Driver Manager initContainer + Manager DriverManagerSpec `json:"manager,omitempty"` + + // Optional: Define resources requests and limits for each pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Resource Requirements" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:resourceRequirements" + Resources *ResourceRequirements `json:"resources,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` + + // Optional: Custom repo configuration for NVIDIA Driver container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Repo Configuration For NVIDIA Driver Container" + RepoConfig *DriverRepoConfigSpec `json:"repoConfig,omitempty"` + + // Optional: Custom certificates configuration for NVIDIA Driver container + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Certificates Configuration For NVIDIA Driver Container" + CertConfig *DriverCertConfigSpec `json:"certConfig,omitempty"` + + // Optional: Licensing configuration for NVIDIA vGPU licensing + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Licensing Configuration For NVIDIA vGPU Driver Container" + LicensingConfig *DriverLicensingConfigSpec `json:"licensingConfig,omitempty"` + + // Optional: Virtual Topology Daemon configuration for NVIDIA vGPU drivers + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Custom Virtual Topology Daemon Configuration For vGPU Driver Container" + VirtualTopologyConfig *VirtualTopologyConfigSpec `json:"virtualTopologyConfig,omitempty"` + + // Optional: Kernel module configuration parameters for the NVIDIA Driver + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Kernel module configuration parameters for the NVIDIA driver" + KernelModuleConfig *KernelModuleConfigSpec `json:"kernelModuleConfig,omitempty"` + + // Optional: SecretEnv represents the name of the Kubernetes Secret with secret environment variables for the NVIDIA Driver + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Name of the Kubernetes Secret with secret environment variables for the NVIDIA Driver" + SecretEnv string `json:"secretEnv,omitempty"` + + // UpgradePolicy allows to control automatic upgrade of the driver on nodes + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Driver Upgrade Policy" + UpgradePolicy *DriverUpgradePolicySpec `json:"upgradePolicy,omitempty"` + + // +kubebuilder:validation:Optional + // NodeSelector specifies a selector for installation of NVIDIA driver + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + + // +kubebuilder:validation:Optional + // Affinity specifies node affinity rules for driver pods + NodeAffinity *corev1.NodeAffinity `json:"nodeAffinity,omitempty"` + + // +kubebuilder:validation:Optional + // Optional: Map of string keys and values that can be used to organize and categorize + // (scope and select) objects. May match selectors of replication controllers + // and services. + Labels map[string]string `json:"labels,omitempty"` + + // +kubebuilder:validation:Optional + // Optional: Annotations is an unstructured key value map stored with a resource that may be + // set by external tools to store and retrieve arbitrary metadata. They are not + // queryable and should be preserved when modifying objects. + Annotations map[string]string `json:"annotations,omitempty"` + + // +kubebuilder:validation:Optional + // Optional: Set tolerations + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Tolerations" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:io.kubernetes:Tolerations" + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + + // +kubebuilder:validation:Optional + // Optional: Set priorityClassName + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="PriorityClassName" + PriorityClassName string `json:"priorityClassName,omitempty"` + + // +kubebuilder:validation:Optional + // Optional: Set pod-level security context for driver pod + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="PodSecurityContext" + PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` + + // HostNetwork indicates whether the Driver pod uses the host's network namespace. + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable hostNetwork for NVIDIA Driver" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + HostNetwork *bool `json:"hostNetwork,omitempty"` +} + +// ResourceRequirements describes the compute resource requirements. +type ResourceRequirements struct { + // Limits describes the maximum amount of compute resources allowed. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + Limits corev1.ResourceList `json:"limits,omitempty"` + // Requests describes the minimum amount of compute resources required. + // If Requests is omitted for a container, it defaults to Limits if that is explicitly specified, + // otherwise to an implementation-defined value. Requests cannot exceed Limits. + // More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/ + // +optional + Requests corev1.ResourceList `json:"requests,omitempty"` +} + +// DriverManagerSpec describes configuration for NVIDIA Driver Manager(initContainer) +type DriverManagerSpec struct { + // Repository represents Driver Managerrepository path + Repository string `json:"repository,omitempty"` + + // Image represents NVIDIA Driver Manager image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // Version represents NVIDIA Driver Manager image tag(version) + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// EnvVar represents an environment variable present in a Container. +type EnvVar struct { + // Name of the environment variable. + Name string `json:"name"` + + // Value of the environment variable. + Value string `json:"value,omitempty"` +} + +// ContainerProbeSpec defines the properties for configuring container probes +type ContainerProbeSpec struct { + // Number of seconds after the container has started before liveness probes are initiated. + // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + // +kubebuilder:validation:Optional + InitialDelaySeconds int32 `json:"initialDelaySeconds,omitempty"` + // Number of seconds after which the probe times out. + // Defaults to 1 second. Minimum value is 1. + // More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#container-probes + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"` + // How often (in seconds) to perform the probe. + // Default to 10 seconds. Minimum value is 1. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + PeriodSeconds int32 `json:"periodSeconds,omitempty"` + // Minimum consecutive successes for the probe to be considered successful after having failed. + // Defaults to 1. Must be 1 for liveness and startup. Minimum value is 1. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + SuccessThreshold int32 `json:"successThreshold,omitempty"` + // Minimum consecutive failures for the probe to be considered failed after having succeeded. + // Defaults to 3. Minimum value is 1. + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Minimum=1 + FailureThreshold int32 `json:"failureThreshold,omitempty"` +} + +// GPUDirectStorageSpec defines the properties for NVIDIA GPUDirect Storage Driver deployment(Experimental) +type GPUDirectStorageSpec struct { + // Enabled indicates if GPUDirect Storage is enabled through GPU operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GPUDirect Storage through GPU operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // NVIDIA GPUDirect Storage Driver image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // NVIDIA GPUDirect Storage Driver image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // NVIDIA GPUDirect Storage Driver image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// GPUDirectRDMASpec defines the properties for nvidia-peermem deployment +type GPUDirectRDMASpec struct { + // Enabled indicates if GPUDirect RDMA is enabled through GPU operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GPUDirect RDMA through GPU operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + // UseHostMOFED indicates to use MOFED drivers directly installed on the host to enable GPUDirect RDMA + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Use MOFED drivers directly installed on the host to enable GPUDirect RDMA" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + UseHostMOFED *bool `json:"useHostMofed,omitempty"` +} + +// GDRCopySpec defines the properties for NVIDIA GDRCopy driver deployment +type GDRCopySpec struct { + // Enabled indicates if GDRCopy is enabled through GPU operator + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable GDRCopy through GPU operator" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + Enabled *bool `json:"enabled,omitempty"` + + // GDRCopy diver image repository + // +kubebuilder:validation:Optional + Repository string `json:"repository,omitempty"` + + // GDRCopy driver image name + // +kubebuilder:validation:Pattern=[a-zA-Z0-9\-]+ + Image string `json:"image,omitempty"` + + // GDRCopy driver image tag + // +kubebuilder:validation:Optional + Version string `json:"version,omitempty"` + + // Image pull policy + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image Pull Policy" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:imagePullPolicy" + ImagePullPolicy string `json:"imagePullPolicy,omitempty"` + + // Image pull secrets + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Image pull secrets" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:io.kubernetes:Secret" + ImagePullSecrets []string `json:"imagePullSecrets,omitempty"` + + // Optional: List of arguments + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Arguments" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Args []string `json:"args,omitempty"` + + // Optional: List of environment variables + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Environment Variables" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:advanced,urn:alm:descriptor:com.tectonic.ui:text" + Env []EnvVar `json:"env,omitempty"` +} + +// KernelModuleConfigSpec defines custom configuration parameters for the NVIDIA Driver +type KernelModuleConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// VirtualTopologyConfigSpec defines virtual topology daemon configuration with NVIDIA vGPU +type VirtualTopologyConfigSpec struct { + // Optional: Config name representing virtual topology daemon configuration file nvidia-topologyd.conf + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// DriverCertConfigSpec defines custom certificates configuration for NVIDIA Driver container +type DriverCertConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// DriverRepoConfigSpec defines custom repo configuration for NVIDIA Driver container +type DriverRepoConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` +} + +// DriverLicensingConfigSpec defines licensing server configuration for NVIDIA Driver container +type DriverLicensingConfigSpec struct { + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Secret Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + SecretName string `json:"secretName,omitempty"` + + // Deprecated: ConfigMapName has been deprecated in favour of SecretName. Please use secrets to handle the licensing server configuration more securely + // +kubebuilder:validation:Optional + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="ConfigMap Name" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:text" + Name string `json:"name,omitempty"` + + // NLSEnabled indicates if NVIDIA Licensing System is used for licensing. + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors=true + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Enable NVIDIA Licensing System licensing" + // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" + NLSEnabled *bool `json:"nlsEnabled,omitempty"` +} + +// DriverType defines NVIDIA driver type +type DriverType string + +const ( + // GPU driver type + GPU DriverType = "gpu" + // VGPU guest driver type + VGPU DriverType = "vgpu" + // VGPUHostManager specifies vgpu host manager type + VGPUHostManager DriverType = "vgpu-host-manager" +) + +// State indicates state of the NVIDIA driver managed by this instance +type State string + +const ( + // Ready indicates that the NVIDIA driver managed by this instance is ready + Ready State = "ready" + // NotReady indicates that the NVIDIA driver managed by this instance is not ready + NotReady State = "notReady" + // Disabled indicates if the state is disabled in ClusterPolicy + Disabled State = "disabled" +) + +// NVIDIADriverStatus defines the observed state of NVIDIADriver +type NVIDIADriverStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file + // +kubebuilder:validation:Enum=ignored;ready;notReady;disabled + // State indicates status of NVIDIADriver instance + State State `json:"state"` + // Namespace indicates a namespace in which the operator and driver are installed + Namespace string `json:"namespace,omitempty"` + // Conditions is a list of conditions representing the NVIDIADriver's current state. + Conditions []metav1.Condition `json:"conditions,omitempty"` +} + +// +genclient +// +genclient:nonNamespaced +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:resource:scope=Cluster,shortName={"nvd","nvdriver","nvdrivers"} +//+kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.state`,priority=0 +//+kubebuilder:printcolumn:name="Default",type=boolean,JSONPath=`.spec.default`,priority=0 +//+kubebuilder:printcolumn:name="Age",type=string,JSONPath=`.metadata.creationTimestamp`,priority=0 + +// NVIDIADriver is the Schema for the nvidiadrivers API +type NVIDIADriver struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec NVIDIADriverSpec `json:"spec,omitempty"` + Status NVIDIADriverStatus `json:"status,omitempty"` +} + +//+kubebuilder:object:root=true + +// NVIDIADriverList contains a list of NVIDIADriver +type NVIDIADriverList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []NVIDIADriver `json:"items"` +} + +// IsDefault returns true when the NVIDIADriver is marked as the fallback driver. +func (d *NVIDIADriver) IsDefault() bool { + return d != nil && d.Spec.Default +} + +// HasDeletionTimestamp returns true when the NVIDIADriver is marked for deletion. +func (d *NVIDIADriver) HasDeletionTimestamp() bool { + return d != nil && !d.GetDeletionTimestamp().IsZero() +} + +// ValidateNodeSelector rejects selectors that use operator-managed routing labels +// or scope the default fallback driver. +func (d *NVIDIADriver) ValidateNodeSelector() error { + if d == nil || d.Spec.NodeSelector == nil { + return nil + } + if d.IsDefault() && len(d.Spec.NodeSelector) > 0 { + return fmt.Errorf("default NVIDIADriver %q cannot use nodeSelector", d.Name) + } + if _, ok := d.Spec.NodeSelector[NVIDIADriverOwnerLabel]; ok { + return fmt.Errorf("NVIDIADriver %q nodeSelector cannot use reserved label %q", d.Name, NVIDIADriverOwnerLabel) + } + return nil +} + +// UsePrecompiledDrivers returns true if usePrecompiled option is enabled in spec +func (d *NVIDIADriverSpec) UsePrecompiledDrivers() bool { + if d.UsePrecompiled == nil { + return false + } + return *d.UsePrecompiled +} + +// GetNodeSelector returns node selector labels for NVIDIA driver installation +func (d *NVIDIADriver) GetNodeSelector() map[string]string { + ns := d.Spec.NodeSelector + if ns == nil { + ns = make(map[string]string) + // If no node selector is specified then the driver is deployed + // on all GPU nodes by default + ns["nvidia.com/gpu.present"] = "true" + } + return ns +} + +// GetImagePath returns the driver image path given the information +// provided in NVIDIADriverSpec and the osVersion passed as an argument. +// The driver image path will be in the following format unless the spec +// contains a digest. +// /:- +func (d *NVIDIADriverSpec) GetImagePath(osVersion string) (string, error) { + // We pass an empty string for the last arg, the imagePathEnvName, since + // we do not want any environment variable in the operator container + // to be used as the default driver image. This means that the driver + // image must be specified in the NVIDIADriver CR spec. + image, err := image.ImagePath(d.Repository, d.Image, d.Version, "") + if err != nil { + return "", fmt.Errorf("failed to get image path from crd: %w", err) + } + + // if image digest is specified, use it directly + if !strings.Contains(image, "sha256:") { + // append '-' to the driver tag + image = fmt.Sprintf("%s-%s", image, osVersion) + } + + _, err = ref.New(image) + if err != nil { + return "", fmt.Errorf("failed to parse driver image path: %w", err) + } + + return image, nil +} + +// GetImagePath returns the gds driver image path given the information +// provided in GPUDirectStorageSpec and the osVersion passed as an argument. +// The driver image path will be in the following format unless the spec +// contains a digest. +// /:- +func (d *GPUDirectStorageSpec) GetImagePath(osVersion string) (string, error) { + image, err := image.ImagePath(d.Repository, d.Image, d.Version, "") + if err != nil { + return "", fmt.Errorf("failed to get image path from crd: %w", err) + } + + // if image digest is specified, use it directly + if !strings.Contains(image, "sha256:") { + // append '-' to the driver tag + image = fmt.Sprintf("%s-%s", image, osVersion) + } + + _, err = ref.New(image) + if err != nil { + return "", fmt.Errorf("failed to parse driver image path: %w", err) + } + + return image, nil +} + +// GetImagePath returns the gdrcopy driver image path given the information +// provided in GDRCopySpec and the osVersion passed as an argument. +// The driver image path will be in the following format unless the spec +// contains a digest. +// /:- +func (d *GDRCopySpec) GetImagePath(osVersion string) (string, error) { + image, err := image.ImagePath(d.Repository, d.Image, d.Version, "") + if err != nil { + return "", fmt.Errorf("failed to get image path from crd: %w", err) + } + + // if image digest is specified, use it directly + if !strings.Contains(image, "sha256:") { + // append '-' to the driver tag + image = fmt.Sprintf("%s-%s", image, osVersion) + } + + _, err = ref.New(image) + if err != nil { + return "", fmt.Errorf("failed to parse driver image path: %w", err) + } + + return image, nil +} + +// GetPrecompiledImagePath returns the precompiled driver image path for a +// given os version and kernel version. Precompiled driver images follow +// the following format: +// /:-- +func (d *NVIDIADriverSpec) GetPrecompiledImagePath(osVersion string, kernelVersion string) (string, error) { + // We pass an empty string for the last arg, the imagePathEnvName, since + // we do not want any environment variable in the operator container + // to be used as the default driver image. This means that the driver + // image must be specified in the NVIDIADriver CR spec. + image, err := image.ImagePath(d.Repository, d.Image, d.Version, "") + if err != nil { + return "", fmt.Errorf("failed to get image path from crd: %w", err) + } + + // specifying a digest in the spec is not supported when using precompiled + if strings.Contains(image, "sha256:") { + return "", fmt.Errorf("specifying image digest is not supported when precompiled is enabled") + } + + // append '--' to the driver tag + image = fmt.Sprintf("%s-%s-%s", image, kernelVersion, osVersion) + + _, err = ref.New(image) + if err != nil { + return "", fmt.Errorf("failed to parse driver image path: %w", err) + } + + return image, nil +} + +// IsGDSEnabled returns true if GPUDirectStorage is enabled through gpu-operator +func (d *NVIDIADriverSpec) IsGDSEnabled() bool { + if d.GPUDirectStorage == nil || d.GPUDirectStorage.Enabled == nil { + // default is false if not specified by user + return false + } + return *d.GPUDirectStorage.Enabled +} + +// IsGDRCopyEnabled returns true if GDRCopy is enabled through gpu-operator +func (d *NVIDIADriverSpec) IsGDRCopyEnabled() bool { + if d.GDRCopy == nil || d.GDRCopy.Enabled == nil { + // default is false if not specified by user + return false + } + return *d.GDRCopy.Enabled +} + +// IsOpenKernelModulesEnabled returns true if NVIDIA OpenRM drivers are enabled +func (d *NVIDIADriverSpec) IsOpenKernelModulesEnabled() bool { + return d.KernelModuleType == "open" +} + +// IsOpenKernelModulesRequired returns true if NVIDIA OpenRM drivers required in this configuration +func (d *NVIDIADriverSpec) IsOpenKernelModulesRequired() bool { + // Add constraints here which require OpenRM drivers + if !d.IsGDSEnabled() { + return false + } + + // If image digest is provided instead of the version, assume that OpenRM driver is required + if strings.HasPrefix(d.GPUDirectStorage.Version, "sha256") { + return true + } + + gdsVersion := d.GPUDirectStorage.Version + if !strings.HasPrefix(gdsVersion, "v") { + gdsVersion = fmt.Sprintf("v%s", gdsVersion) + } + if semver.Compare(gdsVersion, MinimumGDSVersionForOpenRM) >= 0 { + return true + } + return false +} + +// IsVGPULicensingEnabled returns true if the vgpu driver license config is provided +func (d *NVIDIADriverSpec) IsVGPULicensingEnabled() bool { + if d.LicensingConfig == nil { + return false + } + return d.LicensingConfig.Name != "" || d.LicensingConfig.SecretName != "" +} + +// IsKernelModuleConfigEnabled returns true if kernel module config is provided +func (d *NVIDIADriverSpec) IsKernelModuleConfigEnabled() bool { + if d.KernelModuleConfig == nil { + return false + } + return d.KernelModuleConfig.Name != "" +} + +// IsVirtualTopologyConfigEnabled returns true if the virtual topology daemon config is provided +func (d *NVIDIADriverSpec) IsVirtualTopologyConfigEnabled() bool { + if d.VirtualTopologyConfig == nil { + return false + } + return d.VirtualTopologyConfig.Name != "" +} + +// IsRepoConfigEnabled returns true if additional repo config is provided +func (d *NVIDIADriverSpec) IsRepoConfigEnabled() bool { + if d.RepoConfig == nil { + return false + } + return d.RepoConfig.Name != "" +} + +// IsCertConfigEnabled returns true if additional certificate config is provided +func (d *NVIDIADriverSpec) IsCertConfigEnabled() bool { + if d.CertConfig == nil { + return false + } + return d.CertConfig.Name != "" +} + +// IsNLSEnabled returns true if NLS should be used for licensing the driver +func (l *DriverLicensingConfigSpec) IsNLSEnabled() bool { + if l.NLSEnabled == nil { + // NLS is enabled by default + return true + } + return *l.NLSEnabled +} + +// DriverUpgradePolicySpec describes policy configuration for automatic upgrades of the driver. +type DriverUpgradePolicySpec struct { + // AutoUpgrade is a switch for automatic upgrade feature. + // If set to false all other options are ignored. + // +optional + // +kubebuilder:default=true + AutoUpgrade bool `json:"autoUpgrade,omitempty"` + // MaxParallelUpgrades indicates how many nodes can be upgraded in parallel. + // 0 means no limit, all nodes will be upgraded in parallel. + // +optional + // +kubebuilder:default=1 + // +kubebuilder:validation:Minimum=0 + MaxParallelUpgrades int `json:"maxParallelUpgrades,omitempty"` + // MaxUnavailable is the maximum number of nodes with the driver installed, that can be unavailable during the upgrade. + // Value can be an absolute number (ex: 5) or a percentage of total nodes at the start of upgrade (ex: 10%). + // Absolute number is calculated from percentage by rounding up. + // By default, a fixed value of 25% is used. + // +optional + // +kubebuilder:default="25%" + MaxUnavailable *intstr.IntOrString `json:"maxUnavailable,omitempty"` + PodDeletion *PodDeletionSpec `json:"podDeletion,omitempty"` + WaitForCompletion *WaitForCompletionSpec `json:"waitForCompletion,omitempty"` + DrainSpec *DrainSpec `json:"drain,omitempty"` +} + +type PodDeletionSpec = upgrade_v1alpha1.PodDeletionSpec +type WaitForCompletionSpec = upgrade_v1alpha1.WaitForCompletionSpec +type DrainSpec = upgrade_v1alpha1.DrainSpec + +// GetUpgradePolicyWithDefaults returns the upgrade policy for this driver +// with default values applied for any unset fields. +func (s *NVIDIADriverSpec) GetUpgradePolicyWithDefaults() *upgrade_v1alpha1.DriverUpgradePolicySpec { + if s.UpgradePolicy == nil { + return getDefaultUpgradePolicySpec() + } + + result := &upgrade_v1alpha1.DriverUpgradePolicySpec{ + AutoUpgrade: s.UpgradePolicy.AutoUpgrade, + MaxParallelUpgrades: s.UpgradePolicy.MaxParallelUpgrades, + } + + if s.UpgradePolicy.MaxUnavailable != nil { + result.MaxUnavailable = s.UpgradePolicy.MaxUnavailable + } else { + result.MaxUnavailable = getDefaultMaxUnavailable() + } + + if s.UpgradePolicy.PodDeletion != nil { + result.PodDeletion = s.UpgradePolicy.PodDeletion + } else { + result.PodDeletion = getDefaultPodDeletionSpec() + } + + if s.UpgradePolicy.WaitForCompletion != nil { + result.WaitForCompletion = s.UpgradePolicy.WaitForCompletion + } else { + result.WaitForCompletion = getDefaultWaitForCompletionSpec() + } + + if s.UpgradePolicy.DrainSpec != nil { + result.DrainSpec = s.UpgradePolicy.DrainSpec + } else { + result.DrainSpec = getDefaultDrainSpec() + } + + return result +} + +func getDefaultUpgradePolicySpec() *upgrade_v1alpha1.DriverUpgradePolicySpec { + return &upgrade_v1alpha1.DriverUpgradePolicySpec{ + AutoUpgrade: true, + MaxParallelUpgrades: 1, + MaxUnavailable: getDefaultMaxUnavailable(), + PodDeletion: getDefaultPodDeletionSpec(), + WaitForCompletion: getDefaultWaitForCompletionSpec(), + DrainSpec: getDefaultDrainSpec(), + } +} + +func getDefaultMaxUnavailable() *intstr.IntOrString { + defaultMaxUnavailable := intstr.FromString("25%") + return &defaultMaxUnavailable +} + +func getDefaultPodDeletionSpec() *PodDeletionSpec { + return &PodDeletionSpec{ + Force: false, + TimeoutSecond: 300, + DeleteEmptyDir: false, + } +} + +func getDefaultWaitForCompletionSpec() *WaitForCompletionSpec { + return &WaitForCompletionSpec{ + PodSelector: "", + TimeoutSecond: 0, + } +} + +func getDefaultDrainSpec() *DrainSpec { + return &DrainSpec{ + Enable: false, + Force: false, + PodSelector: "", + TimeoutSecond: 300, + DeleteEmptyDir: false, + } +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/zz_generated.deepcopy.go b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/zz_generated.deepcopy.go new file mode 100644 index 0000000000..c75265398d --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,824 @@ +//go:build !ignore_autogenerated + +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by controller-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "github.com/NVIDIA/gpu-operator/api/nvidia/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerProbeSpec) DeepCopyInto(out *ContainerProbeSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerProbeSpec. +func (in *ContainerProbeSpec) DeepCopy() *ContainerProbeSpec { + if in == nil { + return nil + } + out := new(ContainerProbeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DRADriverComputeDomainsSpec) DeepCopyInto(out *DRADriverComputeDomainsSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + in.Controller.DeepCopyInto(&out.Controller) + in.KubeletPlugin.DeepCopyInto(&out.KubeletPlugin) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRADriverComputeDomainsSpec. +func (in *DRADriverComputeDomainsSpec) DeepCopy() *DRADriverComputeDomainsSpec { + if in == nil { + return nil + } + out := new(DRADriverComputeDomainsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DRADriverControllerSpec) DeepCopyInto(out *DRADriverControllerSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRADriverControllerSpec. +func (in *DRADriverControllerSpec) DeepCopy() *DRADriverControllerSpec { + if in == nil { + return nil + } + out := new(DRADriverControllerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DRADriverGPUsSpec) DeepCopyInto(out *DRADriverGPUsSpec) { + *out = *in + in.KubeletPlugin.DeepCopyInto(&out.KubeletPlugin) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRADriverGPUsSpec. +func (in *DRADriverGPUsSpec) DeepCopy() *DRADriverGPUsSpec { + if in == nil { + return nil + } + out := new(DRADriverGPUsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DRADriverHealthcheckSpec) DeepCopyInto(out *DRADriverHealthcheckSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(int32) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRADriverHealthcheckSpec. +func (in *DRADriverHealthcheckSpec) DeepCopy() *DRADriverHealthcheckSpec { + if in == nil { + return nil + } + out := new(DRADriverHealthcheckSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DRADriverKubeletPluginSpec) DeepCopyInto(out *DRADriverKubeletPluginSpec) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]v1.EnvVar, len(*in)) + copy(*out, *in) + } + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(v1.ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Healthcheck != nil { + in, out := &in.Healthcheck, &out.Healthcheck + *out = new(DRADriverHealthcheckSpec) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRADriverKubeletPluginSpec. +func (in *DRADriverKubeletPluginSpec) DeepCopy() *DRADriverKubeletPluginSpec { + if in == nil { + return nil + } + out := new(DRADriverKubeletPluginSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DRADriverSpec) DeepCopyInto(out *DRADriverSpec) { + *out = *in + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.FeatureGates != nil { + in, out := &in.FeatureGates, &out.FeatureGates + *out = make(map[string]bool, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + in.GPUs.DeepCopyInto(&out.GPUs) + in.ComputeDomains.DeepCopyInto(&out.ComputeDomains) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DRADriverSpec. +func (in *DRADriverSpec) DeepCopy() *DRADriverSpec { + if in == nil { + return nil + } + out := new(DRADriverSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverCertConfigSpec) DeepCopyInto(out *DriverCertConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverCertConfigSpec. +func (in *DriverCertConfigSpec) DeepCopy() *DriverCertConfigSpec { + if in == nil { + return nil + } + out := new(DriverCertConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverLicensingConfigSpec) DeepCopyInto(out *DriverLicensingConfigSpec) { + *out = *in + if in.NLSEnabled != nil { + in, out := &in.NLSEnabled, &out.NLSEnabled + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverLicensingConfigSpec. +func (in *DriverLicensingConfigSpec) DeepCopy() *DriverLicensingConfigSpec { + if in == nil { + return nil + } + out := new(DriverLicensingConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverManagerSpec) DeepCopyInto(out *DriverManagerSpec) { + *out = *in + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverManagerSpec. +func (in *DriverManagerSpec) DeepCopy() *DriverManagerSpec { + if in == nil { + return nil + } + out := new(DriverManagerSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverRepoConfigSpec) DeepCopyInto(out *DriverRepoConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverRepoConfigSpec. +func (in *DriverRepoConfigSpec) DeepCopy() *DriverRepoConfigSpec { + if in == nil { + return nil + } + out := new(DriverRepoConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DriverUpgradePolicySpec) DeepCopyInto(out *DriverUpgradePolicySpec) { + *out = *in + if in.MaxUnavailable != nil { + in, out := &in.MaxUnavailable, &out.MaxUnavailable + *out = new(intstr.IntOrString) + **out = **in + } + if in.PodDeletion != nil { + in, out := &in.PodDeletion, &out.PodDeletion + *out = new(PodDeletionSpec) + **out = **in + } + if in.WaitForCompletion != nil { + in, out := &in.WaitForCompletion, &out.WaitForCompletion + *out = new(WaitForCompletionSpec) + **out = **in + } + if in.DrainSpec != nil { + in, out := &in.DrainSpec, &out.DrainSpec + *out = new(DrainSpec) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverUpgradePolicySpec. +func (in *DriverUpgradePolicySpec) DeepCopy() *DriverUpgradePolicySpec { + if in == nil { + return nil + } + out := new(DriverUpgradePolicySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvVar) DeepCopyInto(out *EnvVar) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvVar. +func (in *EnvVar) DeepCopy() *EnvVar { + if in == nil { + return nil + } + out := new(EnvVar) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GDRCopySpec) DeepCopyInto(out *GDRCopySpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GDRCopySpec. +func (in *GDRCopySpec) DeepCopy() *GDRCopySpec { + if in == nil { + return nil + } + out := new(GDRCopySpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUCluster) DeepCopyInto(out *GPUCluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUCluster. +func (in *GPUCluster) DeepCopy() *GPUCluster { + if in == nil { + return nil + } + out := new(GPUCluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GPUCluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUClusterList) DeepCopyInto(out *GPUClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]GPUCluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUClusterList. +func (in *GPUClusterList) DeepCopy() *GPUClusterList { + if in == nil { + return nil + } + out := new(GPUClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *GPUClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUClusterSpec) DeepCopyInto(out *GPUClusterSpec) { + *out = *in + in.DRADriver.DeepCopyInto(&out.DRADriver) + if in.DCGM != nil { + in, out := &in.DCGM, &out.DCGM + *out = new(v1.DCGMSpec) + (*in).DeepCopyInto(*out) + } + if in.DCGMExporter != nil { + in, out := &in.DCGMExporter, &out.DCGMExporter + *out = new(v1.DCGMExporterSpec) + (*in).DeepCopyInto(*out) + } + out.HostPaths = in.HostPaths + in.Daemonsets.DeepCopyInto(&out.Daemonsets) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUClusterSpec. +func (in *GPUClusterSpec) DeepCopy() *GPUClusterSpec { + if in == nil { + return nil + } + out := new(GPUClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUClusterStatus) DeepCopyInto(out *GPUClusterStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUClusterStatus. +func (in *GPUClusterStatus) DeepCopy() *GPUClusterStatus { + if in == nil { + return nil + } + out := new(GPUClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUDirectRDMASpec) DeepCopyInto(out *GPUDirectRDMASpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.UseHostMOFED != nil { + in, out := &in.UseHostMOFED, &out.UseHostMOFED + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUDirectRDMASpec. +func (in *GPUDirectRDMASpec) DeepCopy() *GPUDirectRDMASpec { + if in == nil { + return nil + } + out := new(GPUDirectRDMASpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *GPUDirectStorageSpec) DeepCopyInto(out *GPUDirectStorageSpec) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GPUDirectStorageSpec. +func (in *GPUDirectStorageSpec) DeepCopy() *GPUDirectStorageSpec { + if in == nil { + return nil + } + out := new(GPUDirectStorageSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *HostPathsSpec) DeepCopyInto(out *HostPathsSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HostPathsSpec. +func (in *HostPathsSpec) DeepCopy() *HostPathsSpec { + if in == nil { + return nil + } + out := new(HostPathsSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KernelModuleConfigSpec) DeepCopyInto(out *KernelModuleConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KernelModuleConfigSpec. +func (in *KernelModuleConfigSpec) DeepCopy() *KernelModuleConfigSpec { + if in == nil { + return nil + } + out := new(KernelModuleConfigSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NVIDIADriver) DeepCopyInto(out *NVIDIADriver) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// 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(NVIDIADriver) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NVIDIADriver) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NVIDIADriverList) DeepCopyInto(out *NVIDIADriverList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]NVIDIADriver, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVIDIADriverList. +func (in *NVIDIADriverList) DeepCopy() *NVIDIADriverList { + if in == nil { + return nil + } + out := new(NVIDIADriverList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *NVIDIADriverList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NVIDIADriverSpec) DeepCopyInto(out *NVIDIADriverSpec) { + *out = *in + if in.UsePrecompiled != nil { + in, out := &in.UsePrecompiled, &out.UsePrecompiled + *out = new(bool) + **out = **in + } + if in.UseOpenKernelModules != nil { + in, out := &in.UseOpenKernelModules, &out.UseOpenKernelModules + *out = new(bool) + **out = **in + } + if in.StartupProbe != nil { + in, out := &in.StartupProbe, &out.StartupProbe + *out = new(ContainerProbeSpec) + **out = **in + } + if in.LivenessProbe != nil { + in, out := &in.LivenessProbe, &out.LivenessProbe + *out = new(ContainerProbeSpec) + **out = **in + } + if in.ReadinessProbe != nil { + in, out := &in.ReadinessProbe, &out.ReadinessProbe + *out = new(ContainerProbeSpec) + **out = **in + } + if in.GPUDirectRDMA != nil { + in, out := &in.GPUDirectRDMA, &out.GPUDirectRDMA + *out = new(GPUDirectRDMASpec) + (*in).DeepCopyInto(*out) + } + if in.GPUDirectStorage != nil { + in, out := &in.GPUDirectStorage, &out.GPUDirectStorage + *out = new(GPUDirectStorageSpec) + (*in).DeepCopyInto(*out) + } + if in.GDRCopy != nil { + in, out := &in.GDRCopy, &out.GDRCopy + *out = new(GDRCopySpec) + (*in).DeepCopyInto(*out) + } + if in.ImagePullSecrets != nil { + in, out := &in.ImagePullSecrets, &out.ImagePullSecrets + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.Manager.DeepCopyInto(&out.Manager) + if in.Resources != nil { + in, out := &in.Resources, &out.Resources + *out = new(ResourceRequirements) + (*in).DeepCopyInto(*out) + } + if in.Args != nil { + in, out := &in.Args, &out.Args + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVar, len(*in)) + copy(*out, *in) + } + if in.RepoConfig != nil { + in, out := &in.RepoConfig, &out.RepoConfig + *out = new(DriverRepoConfigSpec) + **out = **in + } + if in.CertConfig != nil { + in, out := &in.CertConfig, &out.CertConfig + *out = new(DriverCertConfigSpec) + **out = **in + } + if in.LicensingConfig != nil { + in, out := &in.LicensingConfig, &out.LicensingConfig + *out = new(DriverLicensingConfigSpec) + (*in).DeepCopyInto(*out) + } + if in.VirtualTopologyConfig != nil { + in, out := &in.VirtualTopologyConfig, &out.VirtualTopologyConfig + *out = new(VirtualTopologyConfigSpec) + **out = **in + } + if in.KernelModuleConfig != nil { + in, out := &in.KernelModuleConfig, &out.KernelModuleConfig + *out = new(KernelModuleConfigSpec) + **out = **in + } + if in.UpgradePolicy != nil { + in, out := &in.UpgradePolicy, &out.UpgradePolicy + *out = new(DriverUpgradePolicySpec) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.NodeAffinity != nil { + in, out := &in.NodeAffinity, &out.NodeAffinity + *out = new(corev1.NodeAffinity) + (*in).DeepCopyInto(*out) + } + if in.Labels != nil { + in, out := &in.Labels, &out.Labels + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Annotations != nil { + in, out := &in.Annotations, &out.Annotations + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]corev1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } + if in.HostNetwork != nil { + in, out := &in.HostNetwork, &out.HostNetwork + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVIDIADriverSpec. +func (in *NVIDIADriverSpec) DeepCopy() *NVIDIADriverSpec { + if in == nil { + return nil + } + out := new(NVIDIADriverSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NVIDIADriverStatus) DeepCopyInto(out *NVIDIADriverStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]metav1.Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NVIDIADriverStatus. +func (in *NVIDIADriverStatus) DeepCopy() *NVIDIADriverStatus { + if in == nil { + return nil + } + out := new(NVIDIADriverStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceRequirements) DeepCopyInto(out *ResourceRequirements) { + *out = *in + if in.Limits != nil { + in, out := &in.Limits, &out.Limits + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Requests != nil { + in, out := &in.Requests, &out.Requests + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRequirements. +func (in *ResourceRequirements) DeepCopy() *ResourceRequirements { + if in == nil { + return nil + } + out := new(ResourceRequirements) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VirtualTopologyConfigSpec) DeepCopyInto(out *VirtualTopologyConfigSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VirtualTopologyConfigSpec. +func (in *VirtualTopologyConfigSpec) DeepCopy() *VirtualTopologyConfigSpec { + if in == nil { + return nil + } + out := new(VirtualTopologyConfigSpec) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/clientset.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/clientset.go new file mode 100644 index 0000000000..304e39896c --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/clientset.go @@ -0,0 +1,133 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package versioned + +import ( + fmt "fmt" + http "net/http" + + nvidiav1 "github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1" + nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1" + discovery "k8s.io/client-go/discovery" + rest "k8s.io/client-go/rest" + flowcontrol "k8s.io/client-go/util/flowcontrol" +) + +type Interface interface { + Discovery() discovery.DiscoveryInterface + NvidiaV1() nvidiav1.NvidiaV1Interface + NvidiaV1alpha1() nvidiav1alpha1.NvidiaV1alpha1Interface +} + +// Clientset contains the clients for groups. +type Clientset struct { + *discovery.DiscoveryClient + nvidiaV1 *nvidiav1.NvidiaV1Client + nvidiaV1alpha1 *nvidiav1alpha1.NvidiaV1alpha1Client +} + +// NvidiaV1 retrieves the NvidiaV1Client +func (c *Clientset) NvidiaV1() nvidiav1.NvidiaV1Interface { + return c.nvidiaV1 +} + +// NvidiaV1alpha1 retrieves the NvidiaV1alpha1Client +func (c *Clientset) NvidiaV1alpha1() nvidiav1alpha1.NvidiaV1alpha1Interface { + return c.nvidiaV1alpha1 +} + +// Discovery retrieves the DiscoveryClient +func (c *Clientset) Discovery() discovery.DiscoveryInterface { + if c == nil { + return nil + } + return c.DiscoveryClient +} + +// NewForConfig creates a new Clientset for the given config. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfig will generate a rate-limiter in configShallowCopy. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*Clientset, error) { + configShallowCopy := *c + + if configShallowCopy.UserAgent == "" { + configShallowCopy.UserAgent = rest.DefaultKubernetesUserAgent() + } + + // share the transport between all clients + httpClient, err := rest.HTTPClientFor(&configShallowCopy) + if err != nil { + return nil, err + } + + return NewForConfigAndClient(&configShallowCopy, httpClient) +} + +// NewForConfigAndClient creates a new Clientset for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +// If config's RateLimiter is not set and QPS and Burst are acceptable, +// NewForConfigAndClient will generate a rate-limiter in configShallowCopy. +func NewForConfigAndClient(c *rest.Config, httpClient *http.Client) (*Clientset, error) { + configShallowCopy := *c + if configShallowCopy.RateLimiter == nil && configShallowCopy.QPS > 0 { + if configShallowCopy.Burst <= 0 { + return nil, fmt.Errorf("burst is required to be greater than 0 when RateLimiter is not set and QPS is set to greater than 0") + } + configShallowCopy.RateLimiter = flowcontrol.NewTokenBucketRateLimiter(configShallowCopy.QPS, configShallowCopy.Burst) + } + + var cs Clientset + var err error + cs.nvidiaV1, err = nvidiav1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + cs.nvidiaV1alpha1, err = nvidiav1alpha1.NewForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + + cs.DiscoveryClient, err = discovery.NewDiscoveryClientForConfigAndClient(&configShallowCopy, httpClient) + if err != nil { + return nil, err + } + return &cs, nil +} + +// NewForConfigOrDie creates a new Clientset for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *Clientset { + cs, err := NewForConfig(c) + if err != nil { + panic(err) + } + return cs +} + +// New creates a new Clientset for the given RESTClient. +func New(c rest.Interface) *Clientset { + var cs Clientset + cs.nvidiaV1 = nvidiav1.New(c) + cs.nvidiaV1alpha1 = nvidiav1alpha1.New(c) + + cs.DiscoveryClient = discovery.NewDiscoveryClient(c) + return &cs +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/doc.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/doc.go new file mode 100644 index 0000000000..161d7caf53 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/doc.go @@ -0,0 +1,20 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package contains the scheme of the automatically generated clientset. +package scheme diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/register.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/register.go new file mode 100644 index 0000000000..52289fe8cf --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/scheme/register.go @@ -0,0 +1,58 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package scheme + +import ( + nvidiav1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" + nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + schema "k8s.io/apimachinery/pkg/runtime/schema" + serializer "k8s.io/apimachinery/pkg/runtime/serializer" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" +) + +var Scheme = runtime.NewScheme() +var Codecs = serializer.NewCodecFactory(Scheme) +var ParameterCodec = runtime.NewParameterCodec(Scheme) +var localSchemeBuilder = runtime.SchemeBuilder{ + nvidiav1.AddToScheme, + nvidiav1alpha1.AddToScheme, +} + +// AddToScheme adds all types of this clientset into the given scheme. This allows composition +// of clientsets, like in: +// +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) +// +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// +// After this, RawExtensions in Kubernetes types will serialize kube-aggregator types +// correctly. +var AddToScheme = localSchemeBuilder.AddToScheme + +func init() { + v1.AddToGroupVersion(Scheme, schema.GroupVersion{Version: "v1"}) + utilruntime.Must(AddToScheme(Scheme)) +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/clusterpolicy.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/clusterpolicy.go new file mode 100644 index 0000000000..b99170526f --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/clusterpolicy.go @@ -0,0 +1,70 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + context "context" + + nvidiav1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" + scheme "github.com/NVIDIA/gpu-operator/api/versioned/scheme" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ClusterPoliciesGetter has a method to return a ClusterPolicyInterface. +// A group's client should implement this interface. +type ClusterPoliciesGetter interface { + ClusterPolicies() ClusterPolicyInterface +} + +// ClusterPolicyInterface has methods to work with ClusterPolicy resources. +type ClusterPolicyInterface interface { + Create(ctx context.Context, clusterPolicy *nvidiav1.ClusterPolicy, opts metav1.CreateOptions) (*nvidiav1.ClusterPolicy, error) + Update(ctx context.Context, clusterPolicy *nvidiav1.ClusterPolicy, opts metav1.UpdateOptions) (*nvidiav1.ClusterPolicy, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, clusterPolicy *nvidiav1.ClusterPolicy, opts metav1.UpdateOptions) (*nvidiav1.ClusterPolicy, error) + Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts metav1.DeleteOptions, listOpts metav1.ListOptions) error + Get(ctx context.Context, name string, opts metav1.GetOptions) (*nvidiav1.ClusterPolicy, error) + List(ctx context.Context, opts metav1.ListOptions) (*nvidiav1.ClusterPolicyList, error) + Watch(ctx context.Context, opts metav1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (result *nvidiav1.ClusterPolicy, err error) + ClusterPolicyExpansion +} + +// clusterPolicies implements ClusterPolicyInterface +type clusterPolicies struct { + *gentype.ClientWithList[*nvidiav1.ClusterPolicy, *nvidiav1.ClusterPolicyList] +} + +// newClusterPolicies returns a ClusterPolicies +func newClusterPolicies(c *NvidiaV1Client) *clusterPolicies { + return &clusterPolicies{ + gentype.NewClientWithList[*nvidiav1.ClusterPolicy, *nvidiav1.ClusterPolicyList]( + "clusterpolicies", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *nvidiav1.ClusterPolicy { return &nvidiav1.ClusterPolicy{} }, + func() *nvidiav1.ClusterPolicyList { return &nvidiav1.ClusterPolicyList{} }, + ), + } +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/doc.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/doc.go new file mode 100644 index 0000000000..fb431d1b5a --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/doc.go @@ -0,0 +1,20 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1 diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/generated_expansion.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/generated_expansion.go new file mode 100644 index 0000000000..9727986c3a --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/generated_expansion.go @@ -0,0 +1,21 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +type ClusterPolicyExpansion interface{} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/nvidia_client.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/nvidia_client.go new file mode 100644 index 0000000000..2d5494ba1a --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1/nvidia_client.go @@ -0,0 +1,101 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1 + +import ( + http "net/http" + + nvidiav1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1" + scheme "github.com/NVIDIA/gpu-operator/api/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type NvidiaV1Interface interface { + RESTClient() rest.Interface + ClusterPoliciesGetter +} + +// NvidiaV1Client is used to interact with features provided by the nvidia group. +type NvidiaV1Client struct { + restClient rest.Interface +} + +func (c *NvidiaV1Client) ClusterPolicies() ClusterPolicyInterface { + return newClusterPolicies(c) +} + +// NewForConfig creates a new NvidiaV1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*NvidiaV1Client, error) { + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new NvidiaV1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NvidiaV1Client, error) { + config := *c + setConfigDefaults(&config) + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &NvidiaV1Client{client}, nil +} + +// NewForConfigOrDie creates a new NvidiaV1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NvidiaV1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NvidiaV1Client for the given RESTClient. +func New(c rest.Interface) *NvidiaV1Client { + return &NvidiaV1Client{c} +} + +func setConfigDefaults(config *rest.Config) { + gv := nvidiav1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NvidiaV1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/doc.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/doc.go new file mode 100644 index 0000000000..917274fbce --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/generated_expansion.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..8a384ef1d7 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/generated_expansion.go @@ -0,0 +1,23 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type GPUClusterExpansion interface{} + +type NVIDIADriverExpansion interface{} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/gpucluster.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/gpucluster.go new file mode 100644 index 0000000000..962eaa9478 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/gpucluster.go @@ -0,0 +1,70 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" + scheme "github.com/NVIDIA/gpu-operator/api/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// GPUClustersGetter has a method to return a GPUClusterInterface. +// A group's client should implement this interface. +type GPUClustersGetter interface { + GPUClusters() GPUClusterInterface +} + +// GPUClusterInterface has methods to work with GPUCluster resources. +type GPUClusterInterface interface { + Create(ctx context.Context, gPUCluster *nvidiav1alpha1.GPUCluster, opts v1.CreateOptions) (*nvidiav1alpha1.GPUCluster, error) + Update(ctx context.Context, gPUCluster *nvidiav1alpha1.GPUCluster, opts v1.UpdateOptions) (*nvidiav1alpha1.GPUCluster, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, gPUCluster *nvidiav1alpha1.GPUCluster, opts v1.UpdateOptions) (*nvidiav1alpha1.GPUCluster, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*nvidiav1alpha1.GPUCluster, error) + List(ctx context.Context, opts v1.ListOptions) (*nvidiav1alpha1.GPUClusterList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *nvidiav1alpha1.GPUCluster, err error) + GPUClusterExpansion +} + +// gPUClusters implements GPUClusterInterface +type gPUClusters struct { + *gentype.ClientWithList[*nvidiav1alpha1.GPUCluster, *nvidiav1alpha1.GPUClusterList] +} + +// newGPUClusters returns a GPUClusters +func newGPUClusters(c *NvidiaV1alpha1Client) *gPUClusters { + return &gPUClusters{ + gentype.NewClientWithList[*nvidiav1alpha1.GPUCluster, *nvidiav1alpha1.GPUClusterList]( + "gpuclusters", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *nvidiav1alpha1.GPUCluster { return &nvidiav1alpha1.GPUCluster{} }, + func() *nvidiav1alpha1.GPUClusterList { return &nvidiav1alpha1.GPUClusterList{} }, + ), + } +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidia_client.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidia_client.go new file mode 100644 index 0000000000..c0f757e2e9 --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidia_client.go @@ -0,0 +1,106 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + http "net/http" + + nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" + scheme "github.com/NVIDIA/gpu-operator/api/versioned/scheme" + rest "k8s.io/client-go/rest" +) + +type NvidiaV1alpha1Interface interface { + RESTClient() rest.Interface + GPUClustersGetter + NVIDIADriversGetter +} + +// NvidiaV1alpha1Client is used to interact with features provided by the nvidia group. +type NvidiaV1alpha1Client struct { + restClient rest.Interface +} + +func (c *NvidiaV1alpha1Client) GPUClusters() GPUClusterInterface { + return newGPUClusters(c) +} + +func (c *NvidiaV1alpha1Client) NVIDIADrivers() NVIDIADriverInterface { + return newNVIDIADrivers(c) +} + +// NewForConfig creates a new NvidiaV1alpha1Client for the given config. +// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient), +// where httpClient was generated with rest.HTTPClientFor(c). +func NewForConfig(c *rest.Config) (*NvidiaV1alpha1Client, error) { + config := *c + setConfigDefaults(&config) + httpClient, err := rest.HTTPClientFor(&config) + if err != nil { + return nil, err + } + return NewForConfigAndClient(&config, httpClient) +} + +// NewForConfigAndClient creates a new NvidiaV1alpha1Client for the given config and http client. +// Note the http client provided takes precedence over the configured transport values. +func NewForConfigAndClient(c *rest.Config, h *http.Client) (*NvidiaV1alpha1Client, error) { + config := *c + setConfigDefaults(&config) + client, err := rest.RESTClientForConfigAndClient(&config, h) + if err != nil { + return nil, err + } + return &NvidiaV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new NvidiaV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *NvidiaV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new NvidiaV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *NvidiaV1alpha1Client { + return &NvidiaV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) { + gv := nvidiav1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = rest.CodecFactoryForGeneratedClient(scheme.Scheme, scheme.Codecs).WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *NvidiaV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidiadriver.go b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidiadriver.go new file mode 100644 index 0000000000..bf73e4f9cc --- /dev/null +++ b/vendor/github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1/nvidiadriver.go @@ -0,0 +1,70 @@ +/** +# Copyright (c) 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# 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. +**/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + context "context" + + nvidiav1alpha1 "github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1" + scheme "github.com/NVIDIA/gpu-operator/api/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// NVIDIADriversGetter has a method to return a NVIDIADriverInterface. +// A group's client should implement this interface. +type NVIDIADriversGetter interface { + NVIDIADrivers() NVIDIADriverInterface +} + +// NVIDIADriverInterface has methods to work with NVIDIADriver resources. +type NVIDIADriverInterface interface { + Create(ctx context.Context, nVIDIADriver *nvidiav1alpha1.NVIDIADriver, opts v1.CreateOptions) (*nvidiav1alpha1.NVIDIADriver, error) + Update(ctx context.Context, nVIDIADriver *nvidiav1alpha1.NVIDIADriver, opts v1.UpdateOptions) (*nvidiav1alpha1.NVIDIADriver, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, nVIDIADriver *nvidiav1alpha1.NVIDIADriver, opts v1.UpdateOptions) (*nvidiav1alpha1.NVIDIADriver, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*nvidiav1alpha1.NVIDIADriver, error) + List(ctx context.Context, opts v1.ListOptions) (*nvidiav1alpha1.NVIDIADriverList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *nvidiav1alpha1.NVIDIADriver, err error) + NVIDIADriverExpansion +} + +// nVIDIADrivers implements NVIDIADriverInterface +type nVIDIADrivers struct { + *gentype.ClientWithList[*nvidiav1alpha1.NVIDIADriver, *nvidiav1alpha1.NVIDIADriverList] +} + +// newNVIDIADrivers returns a NVIDIADrivers +func newNVIDIADrivers(c *NvidiaV1alpha1Client) *nVIDIADrivers { + return &nVIDIADrivers{ + gentype.NewClientWithList[*nvidiav1alpha1.NVIDIADriver, *nvidiav1alpha1.NVIDIADriverList]( + "nvidiadrivers", + c.RESTClient(), + scheme.ParameterCodec, + "", + func() *nvidiav1alpha1.NVIDIADriver { return &nvidiav1alpha1.NVIDIADriver{} }, + func() *nvidiav1alpha1.NVIDIADriverList { return &nvidiav1alpha1.NVIDIADriverList{} }, + ), + } +} diff --git a/vendor/k8s.io/client-go/discovery/fake/discovery.go b/vendor/k8s.io/client-go/discovery/fake/discovery.go deleted file mode 100644 index e5d9e7f800..0000000000 --- a/vendor/k8s.io/client-go/discovery/fake/discovery.go +++ /dev/null @@ -1,180 +0,0 @@ -/* -Copyright 2016 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -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. -*/ - -package fake - -import ( - "fmt" - "net/http" - - openapi_v2 "github.com/google/gnostic-models/openapiv2" - - "k8s.io/apimachinery/pkg/api/errors" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/apimachinery/pkg/version" - "k8s.io/client-go/discovery" - "k8s.io/client-go/openapi" - kubeversion "k8s.io/client-go/pkg/version" - restclient "k8s.io/client-go/rest" - "k8s.io/client-go/testing" -) - -// FakeDiscovery implements discovery.DiscoveryInterface and sometimes calls testing.Fake.Invoke with an action, -// but doesn't respect the return value if any. There is a way to fake static values like ServerVersion by using the Faked... fields on the struct. -type FakeDiscovery struct { - *testing.Fake - FakedServerVersion *version.Info -} - -// ServerResourcesForGroupVersion returns the supported resources for a group -// and version. -func (c *FakeDiscovery) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error) { - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "resource"}, - } - if _, err := c.Invokes(action, nil); err != nil { - return nil, err - } - for _, resourceList := range c.Resources { - if resourceList.GroupVersion == groupVersion { - return resourceList, nil - } - } - return nil, &errors.StatusError{ - ErrStatus: metav1.Status{ - Status: metav1.StatusFailure, - Code: http.StatusNotFound, - Reason: metav1.StatusReasonNotFound, - Message: fmt.Sprintf("the server could not find the requested resource, GroupVersion %q not found", groupVersion), - }} -} - -// ServerGroupsAndResources returns the supported groups and resources for all groups and versions. -func (c *FakeDiscovery) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { - sgs, err := c.ServerGroups() - if err != nil { - return nil, nil, err - } - resultGroups := []*metav1.APIGroup{} - for i := range sgs.Groups { - resultGroups = append(resultGroups, &sgs.Groups[i]) - } - - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "resource"}, - } - if _, err = c.Invokes(action, nil); err != nil { - return resultGroups, c.Resources, err - } - return resultGroups, c.Resources, nil -} - -// ServerPreferredResources returns the supported resources with the version -// preferred by the server. -func (c *FakeDiscovery) ServerPreferredResources() ([]*metav1.APIResourceList, error) { - return nil, nil -} - -// ServerPreferredNamespacedResources returns the supported namespaced resources -// with the version preferred by the server. -func (c *FakeDiscovery) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { - return nil, nil -} - -// ServerGroups returns the supported groups, with information like supported -// versions and the preferred version. -func (c *FakeDiscovery) ServerGroups() (*metav1.APIGroupList, error) { - action := testing.ActionImpl{ - Verb: "get", - Resource: schema.GroupVersionResource{Resource: "group"}, - } - if _, err := c.Invokes(action, nil); err != nil { - return nil, err - } - - groups := map[string]*metav1.APIGroup{} - - for _, res := range c.Resources { - gv, err := schema.ParseGroupVersion(res.GroupVersion) - if err != nil { - return nil, err - } - group := groups[gv.Group] - if group == nil { - group = &metav1.APIGroup{ - Name: gv.Group, - PreferredVersion: metav1.GroupVersionForDiscovery{ - GroupVersion: res.GroupVersion, - Version: gv.Version, - }, - } - groups[gv.Group] = group - } - - group.Versions = append(group.Versions, metav1.GroupVersionForDiscovery{ - GroupVersion: res.GroupVersion, - Version: gv.Version, - }) - } - - list := &metav1.APIGroupList{} - for _, apiGroup := range groups { - list.Groups = append(list.Groups, *apiGroup) - } - - return list, nil - -} - -// ServerVersion retrieves and parses the server's version. -func (c *FakeDiscovery) ServerVersion() (*version.Info, error) { - action := testing.ActionImpl{} - action.Verb = "get" - action.Resource = schema.GroupVersionResource{Resource: "version"} - _, err := c.Invokes(action, nil) - if err != nil { - return nil, err - } - - if c.FakedServerVersion != nil { - return c.FakedServerVersion, nil - } - - versionInfo := kubeversion.Get() - return &versionInfo, nil -} - -// OpenAPISchema retrieves and parses the swagger API schema the server supports. -func (c *FakeDiscovery) OpenAPISchema() (*openapi_v2.Document, error) { - return &openapi_v2.Document{}, nil -} - -func (c *FakeDiscovery) OpenAPIV3() openapi.Client { - panic("unimplemented") -} - -// RESTClient returns a RESTClient that is used to communicate with API server -// by this client implementation. -func (c *FakeDiscovery) RESTClient() restclient.Interface { - return nil -} - -func (c *FakeDiscovery) WithLegacy() discovery.DiscoveryInterface { - panic("unimplemented") -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 0bbb1592d2..13e2ebc80a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -33,6 +33,15 @@ github.com/NVIDIA/go-nvlib/pkg/nvpci github.com/NVIDIA/go-nvlib/pkg/nvpci/bytes github.com/NVIDIA/go-nvlib/pkg/nvpci/mmio github.com/NVIDIA/go-nvlib/pkg/pciids +# github.com/NVIDIA/gpu-operator/api v0.2603.3 => ./api +## explicit; go 1.26.3 +github.com/NVIDIA/gpu-operator/api/image +github.com/NVIDIA/gpu-operator/api/nvidia/v1 +github.com/NVIDIA/gpu-operator/api/nvidia/v1alpha1 +github.com/NVIDIA/gpu-operator/api/versioned +github.com/NVIDIA/gpu-operator/api/versioned/scheme +github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1 +github.com/NVIDIA/gpu-operator/api/versioned/typed/nvidia/v1alpha1 # github.com/NVIDIA/k8s-kata-manager v0.2.3 ## explicit; go 1.23.0 github.com/NVIDIA/k8s-kata-manager/api/v1alpha1/config @@ -767,7 +776,6 @@ k8s.io/client-go/applyconfigurations/storagemigration/v1beta1 k8s.io/client-go/discovery k8s.io/client-go/discovery/cached/disk k8s.io/client-go/discovery/cached/memory -k8s.io/client-go/discovery/fake k8s.io/client-go/dynamic k8s.io/client-go/features k8s.io/client-go/gentype @@ -1204,3 +1212,4 @@ sigs.k8s.io/structured-merge-diff/v6/value ## explicit; go 1.22 sigs.k8s.io/yaml sigs.k8s.io/yaml/kyaml +# github.com/NVIDIA/gpu-operator/api => ./api