forked from kserve/modelmesh-serving
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
206 lines (170 loc) · 6.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# Copyright 2021 IBM 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.
# collect args from `make run` so that they don't run twice
ifeq (run,$(firstword $(MAKECMDGOALS)))
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
ifneq ("$(wildcard /.dockerenv)","")
$(error Inside docker container, run 'make $(RUN_ARGS)')
endif
endif
# Container Engine to be used for building images
ENGINE ?= "docker"
# Image URL to use all building/pushing image targets
IMG ?= kserve/modelmesh-controller:latest
# Namespace to deploy model-serve into
NAMESPACE ?= "model-serving"
CONTROLLER_GEN_VERSION ?= "v0.7.0"
CRD_OPTIONS ?= "crd:maxDescLen=0"
# Model Mesh gRPC API Proto Generation
PROTO_FILES = $(shell find proto/ -iname "*.proto")
GENERATED_GO_FILES = $(shell find generated/ -iname "*.pb.go")
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
.PHONY: all
all: manager
# Run unit tests
.PHONY: test
test:
go test -coverprofile cover.out `go list ./... | grep -v fvt`
# Run fvt tests. This requires an etcd, kubernetes connection, and model serving installation. Ginkgo CLI is used to run them in parallel
.PHONY: fvt
fvt:
ginkgo -v -procs=2 --progress --fail-fast fvt/predictor fvt/scaleToZero fvt/storage fvt/hpa --timeout=50m
# Command to regenerate the grpc go files from the proto files
.PHONY: fvt-protoc
fvt-protoc:
rm -rf fvt/generated
protoc -I=fvt/proto --go_out=plugins=grpc:. --go_opt=module=github.com/kserve/modelmesh-serving $(shell find fvt/proto -iname "*.proto")
.PHONY: fvt-with-deploy
fvt-with-deploy: oc-login deploy-release-dev-mode fvt
.PHONY: oc-login
oc-login:
oc login --token=${OCP_TOKEN} --server=https://${OCP_ADDRESS} --insecure-skip-tls-verify=true
# Build manager binary
.PHONY: manager
manager: generate fmt
go build -o bin/manager main.go
# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: start
start: generate fmt manifests
go run ./main.go
# Install CRDs into a cluster
.PHONY: install
install: manifests
kustomize build config/crd | kubectl apply -f -
# Uninstall CRDs from a cluster
.PHONY: uninstall
uninstall: manifests
kustomize build config/crd | kubectl delete -f -
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
deploy: manifests
cd config/manager && kustomize edit set image controller=${IMG}
kustomize build config/default | kubectl apply -f -
# artifactory creds set via env var
.PHONY: deploy-release
deploy-release:
./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config
.PHONY: deploy-release-dev-mode
deploy-release-dev-mode:
./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging
.PHONY: deploy-release-dev-mode-fvt
deploy-release-dev-mode-fvt:
ifdef MODELMESH_SERVING_IMAGE
$(eval extra_options += --modelmesh-serving-image ${MODELMESH_SERVING_IMAGE})
endif
ifdef NAMESPACE_SCOPE_MODE
$(eval extra_options += --namespace-scope-mode)
endif
./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging --fvt ${extra_options}
.PHONY: delete
delete: oc-login
./scripts/delete.sh --namespace ${NAMESPACE} --local-config-path config
# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
manifests: controller-gen
# NOTE: We're currently copying the CRD manifests from KServe rather than using this target to regenerate those
# that are common (all apart from predictors) because the formatting ends up different depending on the version
# of controller-gen and yq used. The KServe make manifests also includes a bunch of yaml post-processing which
# would need to be replicated here.
# HACK: ignore errors from generating the TrainedModel CRD from KServe, which is removed below
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=controller-role crd paths="github.com/kserve/kserve/pkg/apis/serving/v1alpha1" output:crd:dir=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=controller-role crd paths="github.com/kserve/kserve/pkg/apis/serving/v1beta1" output:crd:dir=config/crd/bases
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=controller-role crd paths="./..." output:crd:dir=config/crd/bases
rm -f ./config/crd/bases/serving.kserve.io_trainedmodels.yaml
pre-commit run --all-files prettier > /dev/null || true
# Run go fmt against code
.PHONY: fmt
fmt:
./scripts/fmt.sh || (echo "Linter failed: $$?"; git status; exit 1)
# Generate code
.PHONY: generate
generate: controller-gen
$(CONTROLLER_GEN) object:headerFile="scripts/controller-gen-header.go.tmpl" paths="./..."
pre-commit run --all-files prettier > /dev/null || true
# Build the final runtime docker image
.PHONY: build
build:
./scripts/build_docker.sh --target runtime --engine $(ENGINE)
# Build the develop docker image
.PHONY: build.develop
build.develop:
./scripts/build_devimage.sh $(ENGINE)
# Start a terminal session in the develop docker container
.PHONY: develop
develop: build.develop
./scripts/develop.sh
# Run make commands from within the develop docker container
# For example, `make run fmt` will execute `make fmt` within the docker container
.PHONY: run
run: build.develop
./scripts/develop.sh make $(RUN_ARGS)
# Build the docker image
.PHONY: docker-build
docker-build: build
# Push the docker image
.PHONY: docker-push
docker-push:
docker push ${IMG}
# find or download controller-gen
# download controller-gen if necessary
.PHONY: controller-gen
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
set -e ;\
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$CONTROLLER_GEN_TMP_DIR ;\
go mod init tmp ;\
go get sigs.k8s.io/controller-tools/cmd/controller-gen@${CONTROLLER_GEN_VERSION} ;\
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
}
CONTROLLER_GEN=$(GOBIN)/controller-gen
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
# Model Mesh gRPC codegen
.PHONY: mmesh-codegen
mmesh-codegen:
protoc -I proto/ --go_out=plugins=grpc:generated/ $(PROTO_FILES)
# Check markdown files for invalid links
.PHONY: check-doc-links
check-doc-links:
@python3 scripts/verify_doc_links.py && echo "$@: OK"
# Override targets if they are included in RUN_ARGs so it doesn't run them twice
$(eval $(RUN_ARGS):;@:)