1
- # Image URL to use all building/pushing image targets
2
- IMG ?= kubeflow/training-operator:latest
3
- # CRD generation options
4
- CRD_OPTIONS ?= "crd:generateEmbeddedObjectMeta=true,maxDescLen=400"
5
-
6
1
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
7
2
ifeq (,$(shell go env GOBIN) )
8
3
GOBIN =$(shell go env GOPATH) /bin
16
11
SHELL = /usr/bin/env bash -o pipefail
17
12
.SHELLFLAGS = -ec
18
13
19
- all : build
20
-
21
14
# #@ General
22
15
23
16
# The help target prints out all targets with their descriptions organized
@@ -36,108 +29,78 @@ help: ## Display this help.
36
29
37
30
# #@ Development
38
31
32
+ PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
33
+
34
+
35
+ # # Tool Binaries
36
+ LOCALBIN ?= $(PROJECT_DIR ) /bin
37
+ CONTROLLER_GEN ?= $(LOCALBIN ) /controller-gen
38
+ ENVTEST ?= $(LOCALBIN ) /setup-envtest
39
+
40
+ ENVTEST_K8S_VERSION ?= 1.31
41
+
42
+ .PHONY : envtest
43
+ envtest : # # Download the setup-envtest binary if required.
44
+ test -s
$(ENVTEST ) || GOBIN=
$(LOCALBIN ) go install sigs.k8s.io/controller-runtime/tools/
[email protected]
45
+
46
+ .PHONY : controller-gen
47
+ controller-gen : # # Download the controller-gen binary if required.
48
+ test -s
$(CONTROLLER_GEN ) || GOBIN=
$(LOCALBIN ) go install sigs.k8s.io/controller-tools/cmd/
[email protected]
49
+
50
+ # Download external CRDs for the integration testings.
51
+ EXTERNAL_CRDS_DIR ?= $(PROJECT_DIR ) /manifests/external-crds
52
+
53
+ JOBSET_ROOT = $(shell go list -m -mod=readonly -f "{{.Dir}}" sigs.k8s.io/jobset)
54
+ .PHONY : jobset-operator-crd
55
+ jobset-operator-crd : # # Copy the CRDs from the JobSet repository to the manifests/external-crds directory.
56
+ mkdir -p $(EXTERNAL_CRDS_DIR ) /jobset-operator/
57
+ cp -f $(JOBSET_ROOT ) /config/components/crd/bases/* $(EXTERNAL_CRDS_DIR ) /jobset-operator/
58
+
59
+ SCHEDULER_PLUGINS_ROOT = $(shell go list -m -f "{{.Dir}}" sigs.k8s.io/scheduler-plugins)
60
+ .PHONY : scheduler-plugins-crd
61
+ scheduler-plugins-crd : # # Copy the CRDs from the Scheduler Plugins repository to the manifests/external-crds directory.
62
+ mkdir -p $(EXTERNAL_CRDS_DIR ) /scheduler-plugins/
63
+ cp -f $(SCHEDULER_PLUGINS_ROOT ) /manifests/coscheduling/* $(EXTERNAL_CRDS_DIR ) /scheduler-plugins
64
+
65
+ .PHONY : manifests
39
66
manifests : controller-gen # # Generate manifests.
40
67
$(CONTROLLER_GEN ) " crd:generateEmbeddedObjectMeta=true" rbac:roleName=training-operator-v2 webhook \
41
68
paths=" ./pkg/apis/kubeflow.org/v2alpha1/...;./pkg/controller.v2/...;./pkg/runtime.v2/...;./pkg/webhooks.v2/...;./pkg/cert/..." \
42
69
output:crd:artifacts:config=manifests/v2/base/crds \
43
70
output:rbac:artifacts:config=manifests/v2/base/rbac \
44
71
output:webhook:artifacts:config=manifests/v2/base/webhook
45
72
73
+ .PHONY : generate
46
74
generate : go-mod-download manifests # # Generate APIs and SDK.
47
75
$(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate/boilerplate.go.txt" paths=" ./pkg/apis/..."
48
76
hack/update-codegen.sh
49
77
hack/python-sdk-v2/gen-sdk.sh
50
78
51
- fmt : # # Run go fmt against code.
79
+ .PHONY : go-mod-download
80
+ go-mod-download : # # Run go mod download to download modules.
81
+ go mod download
82
+
83
+ .PHONY : fmt
84
+ fmt : # # Run go fmt against the code.
52
85
go fmt ./...
53
86
54
- vet : # # Run go vet against code.
87
+ .PHONY : vet
88
+ vet : # # Run go vet against the code.
55
89
go vet ./...
56
90
57
91
GOLANGCI_LINT =$(shell which golangci-lint)
58
- golangci-lint :
92
+ .PHONY : golangci-lint
93
+ golangci-lint : # # Run golangci-lint to verify Go files.
59
94
ifeq ($(GOLANGCI_LINT ) ,)
60
95
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.61.0
61
96
$(info golangci-lint has been installed)
62
97
endif
63
98
golangci-lint run --timeout 5m --go 1.23 ./...
64
99
65
- ENVTEST_K8S_VERSION ?= 1.31
66
- HAS_SETUP_ENVTEST := $(shell command -v setup-envtest;)
67
-
68
- testall : manifests generate fmt vet golangci-lint test # # Run tests.
69
-
70
- test : envtest
71
- KUBEBUILDER_ASSETS=" $( shell setup-envtest use $( ENVTEST_K8S_VERSION) -p path) " \
72
- go test ./pkg/apis/kubeflow.org/v1/... ./pkg/cert/... ./pkg/common/... ./pkg/config/... ./pkg/controller.v1/... ./pkg/core/... ./pkg/util/... ./pkg/webhooks/... -coverprofile cover.out
73
-
74
- .PHONY : test-integrationv2
75
- test-integrationv2 : envtest jobset-operator-crd scheduler-plugins-crd
76
- KUBEBUILDER_ASSETS=" $( shell setup-envtest use $( ENVTEST_K8S_VERSION) -p path) " go test ./test/... -coverprofile cover.out
77
-
78
- .PHONY : testv2
79
- testv2 :
100
+ .PHONY : test
101
+ test : # # Run Go unit test.
80
102
go test ./pkg/apis/kubeflow.org/v2alpha1/... ./pkg/controller.v2/... ./pkg/runtime.v2/... ./pkg/webhooks.v2/... ./pkg/util.v2/... -coverprofile cover.out
81
103
82
- envtest :
83
- ifndef HAS_SETUP_ENVTEST
84
- go install sigs.k8s.io/controller-runtime/tools/
[email protected]
85
- @echo "setup-envtest has been installed"
86
- endif
87
- @echo "setup-envtest has already installed"
88
-
89
- build : generate fmt vet # # Build manager binary.
90
- go build -o bin/manager cmd/training-operator.v1/main.go
91
-
92
- run : manifests generate fmt vet # # Run a controller from your host.
93
- go run ./cmd/training-operator.v1/main.go
94
-
95
- docker-build : test # # Build docker image with the manager.
96
- docker build -t ${IMG} -f build/images/training-operator/Dockerfile .
97
-
98
- docker-push : # # Push docker image with the manager.
99
- docker push ${IMG}
100
-
101
- # #@ Deployment
102
-
103
- install : manifests kustomize # # Install CRDs into the K8s cluster specified in ~/.kube/config.
104
- $(KUSTOMIZE ) build manifests/base/crds | kubectl apply --server-side -f -
105
-
106
- uninstall : manifests kustomize # # Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
107
- $(KUSTOMIZE ) build manifests/base/crds | kubectl delete -f -
108
-
109
- deploy : manifests kustomize # # Deploy controller to the K8s cluster specified in ~/.kube/config.
110
- cd manifests/overlays/standalone && $(KUSTOMIZE ) edit set image kubeflow/training-operator=${IMG}
111
- $(KUSTOMIZE ) build manifests/overlays/standalone | kubectl apply -f -
112
-
113
- undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config.
114
- $(KUSTOMIZE ) build manifests/overlays/standalone | kubectl delete -f -
115
-
116
- PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST ) ) ) )
117
-
118
- .PHONY : go-mod-download
119
- go-mod-download :
120
- go mod download
121
-
122
- CONTROLLER_GEN = $(shell pwd) /bin/controller-gen
123
- controller-gen : # # Download controller-gen locally if necessary.
124
- GOBIN=
$(PROJECT_DIR ) /bin go install sigs.k8s.io/controller-tools/cmd/
[email protected]
125
-
126
- KUSTOMIZE = $(shell pwd) /bin/kustomize
127
- kustomize : # # Download kustomize locally if necessary.
128
- GOBIN=
$(PROJECT_DIR ) /bin go install sigs.k8s.io/kustomize/kustomize/
[email protected]
129
-
130
- # # Download external CRDs for the integration testings.
131
- EXTERNAL_CRDS_DIR ?= $(PROJECT_DIR ) /manifests/external-crds
132
-
133
- JOBSET_ROOT = $(shell go list -m -mod=readonly -f "{{.Dir}}" sigs.k8s.io/jobset)
134
- .PHONY : jobset-operator-crd
135
- jobset-operator-crd : # # Copy the CRDs from the jobset-operator to the manifests/external-crds directory.
136
- mkdir -p $(EXTERNAL_CRDS_DIR ) /jobset-operator/
137
- cp -f $(JOBSET_ROOT ) /config/components/crd/bases/* $(EXTERNAL_CRDS_DIR ) /jobset-operator/
138
-
139
- SCHEDULER_PLUGINS_ROOT = $(shell go list -m -f "{{.Dir}}" sigs.k8s.io/scheduler-plugins)
140
- .PHONY : scheduler-plugins-crd
141
- scheduler-plugins-crd :
142
- mkdir -p $(EXTERNAL_CRDS_DIR ) /scheduler-plugins/
143
- cp -f $(SCHEDULER_PLUGINS_ROOT ) /manifests/coscheduling/* $(EXTERNAL_CRDS_DIR ) /scheduler-plugins
104
+ .PHONY : test-integration
105
+ test-integration : envtest jobset-operator-crd scheduler-plugins-crd # # Run Go integration test.
106
+ KUBEBUILDER_ASSETS=" $( shell $( ENVTEST) use $( ENVTEST_K8S_VERSION) -p path) " go test ./test/... -coverprofile cover.out
0 commit comments