Skip to content

Commit

Permalink
Merge pull request #174 from vaibhavjainwiz/main
Browse files Browse the repository at this point in the history
[Sync] kserve/modelmesh-serving-main to main branch
  • Loading branch information
openshift-merge-robot committed Sep 5, 2023
2 parents 39ef635 + a8ad4fa commit 97f2a83
Show file tree
Hide file tree
Showing 26 changed files with 1,314 additions and 156 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build

on:
workflow_dispatch:
push:
branches: [master]
tags:
Expand Down Expand Up @@ -49,7 +50,7 @@ jobs:
driver-opts: network=host

- name: Login to DockerHub
if: github.event_name == 'push'
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/fvt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
go-version: '1.19'

- name: Start Minikube
uses: medyagh/setup-minikube@v0.0.11
uses: medyagh/setup-minikube@v0.0.13
id: minikube
with:
minikube-version: 1.27.1
minikube-version: 1.31.0
container-runtime: docker
kubernetes-version: v1.25.2
kubernetes-version: v1.26.1
cpus: max
memory: max

Expand Down Expand Up @@ -116,9 +116,11 @@ jobs:
docker pull kserve/rest-proxy:v0.10.0
=======
# docker pull pytorch/torchserve:0.7.1-cpu
docker pull kserve/modelmesh-runtime-adapter
docker pull kserve/rest-proxy
docker pull kserve/modelmesh
docker pull kserve/modelmesh:latest
docker pull kserve/modelmesh-minio-dev-examples:latest
docker pull kserve/modelmesh-minio-examples:latest
docker pull kserve/modelmesh-runtime-adapter:latest
docker pull kserve/rest-proxy:latest

>>>>>>> v0.11.0-rc0:.github/workflows/fvt.yml
- name: Check installation
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile.develop
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARG TARGETARCH

ARG OPENSHIFT_VERSION=4.12
ARG KUSTOMIZE_VERSION=4.5.2
ARG KUBEBUILDER_VERSION=v3.3.0
ARG KUBEBUILDER_VERSION=v3.11.0
ARG CONTROLLER_GEN_VERSION=v0.11.4

ENV PATH=/usr/local/go/bin:$PATH:/usr/local/kubebuilder/bin:
Expand Down Expand Up @@ -111,6 +111,12 @@ RUN true \
&& ginkgo version \
&& true

# Use setup-envtest for kubebuilder to use K8s version 1.23+ for autoscaling/v2 (HPA)
RUN true \
&& go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest \
&& setup-envtest use 1.23 \
&& true

# For GitHub Action 'lint', work around error "detected dubious ownership in repository at '/workspace'"
RUN git config --system --add safe.directory /workspace

Expand Down
10 changes: 8 additions & 2 deletions Dockerfile.develop.ci
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARG TARGETARCH=amd64

ARG OPENSHIFT_VERSION=4.12
ARG KUSTOMIZE_VERSION=4.5.2
ARG KUBEBUILDER_VERSION=v3.3.0
ARG KUBEBUILDER_VERSION=v3.11.0
ARG CONTROLLER_GEN_VERSION=v0.11.4

ENV PATH=/usr/local/go/bin:$PATH:/usr/local/kubebuilder/bin:
Expand All @@ -41,7 +41,7 @@ RUN --mount=type=cache,target=${HOME}/.cache/dnf:rw \
python3 \
python3-pip \
nodejs \
jq
jq

# Install pre-commit
ENV PIP_CACHE_DIR=${HOME}/.cache/pip
Expand Down Expand Up @@ -110,6 +110,12 @@ RUN true \
&& ginkgo version \
&& true

# Use setup-envtest for kubebuilder to use K8s version 1.23+ for autoscaling/v2 (HPA)
RUN true \
&& go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest \
&& setup-envtest use 1.23 \
&& true

# For GitHub Action 'lint', work around error "detected dubious ownership in repository at '/workspace'"
RUN git config --system --add safe.directory /go/src/github.com/opendatahub-io/modelmesh-serving

Expand Down
88 changes: 56 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ 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.11.4"

# Kubernetes version needs to be 1.23 or newer for autoscaling/v2 (HPA)
# https://github.com/kubernetes-sigs/controller-runtime/tree/main/tools/setup-envtest
# install with `go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest`
# find available versions by running `setup-envtest list`
KUBERNETES_VERSION ?= 1.23

CRD_OPTIONS ?= "crd:maxDescLen=0"

# Model Mesh gRPC API Proto Generation
Expand All @@ -44,71 +51,78 @@ GOBIN=$(shell go env GOBIN)
endif

.PHONY: all
## Alias for `manager`
all: manager

# Run unit tests
.PHONY: test
## Run unit tests (Requires kubebuilder, etcd, kube-apiserver, envtest)
test:
KUBEBUILDER_ASSETS="$$(setup-envtest use $(KUBERNETES_VERSION) -p path)" \
KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT=120s \
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
## Run FVT tests (Requires ModelMesh Serving deployment and GinkGo CLI)
fvt:
ginkgo -v -procs=2 --fail-fast fvt/predictor fvt/scaleToZero fvt/storage fvt/hpa --timeout=50m

fvt-stable:
ginkgo -v -procs=2 --progress --fail-fast fvt/predictor fvt/scaleToZero fvt/storage --timeout=50m

# Command to regenerate the grpc go files from the proto files
.PHONY: fvt-protoc
fvt-protoc:
.PHONY: codegen-fvt
## Regenerate grpc code stubs for FVT
codegen-fvt:
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
## Alias for `oc-login, deploy-release-fvt, fvt`
fvt-with-deploy: oc-login deploy-release-fvt fvt

.PHONY: oc-login
## Login to OCP cluster
oc-login:
oc login --token=${OCP_TOKEN} --server=https://${OCP_ADDRESS} --insecure-skip-tls-verify=true

# Build manager binary
.PHONY: manager
## Build `manager` binary
manager: generate fmt
go build -o bin/manager main.go

# Run against the configured Kubernetes cluster in ~/.kube/config
.PHONY: start
## Run against a Kubernetes cluster
start: generate fmt manifests
go run ./main.go

# Install CRDs into a cluster
.PHONY: install
## Install CRDs into a Kubernetes cluster
install: manifests
kustomize build config/crd | kubectl apply -f -

# Uninstall CRDs from a cluster
.PHONY: uninstall
## Uninstall CRDs from a Kubernetes cluster
uninstall: manifests
kustomize build config/crd | kubectl delete -f -

# Deploy controller in the configured Kubernetes cluster in ~/.kube/config
.PHONY: deploy
## Deploy manifests to Kubernetes cluster
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 (artifactory creds set via env var)
deploy-release:
./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config

.PHONY: deploy-release-dev-mode
deploy-release-dev-mode:
.PHONY: deploy-release-dev
## Deploy release in dev mode (artifactory creds set via env var)
deploy-release-dev:
./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging

.PHONY: deploy-release-dev-mode-fvt
deploy-release-dev-mode-fvt:
.PHONY: deploy-release-fvt
## Deploy release in dev mode for FVT tests
deploy-release-fvt:
ifdef MODELMESH_SERVING_IMAGE
$(eval extra_options += --modelmesh-serving-image ${MODELMESH_SERVING_IMAGE})
endif
Expand All @@ -117,12 +131,13 @@ ifdef NAMESPACE_SCOPE_MODE
endif
./scripts/install.sh --namespace ${NAMESPACE} --install-config-path config --dev-mode-logging --fvt ${extra_options}

.PHONY: delete
delete: oc-login
.PHONY: undeploy-release
## Undeploy the ModelMesh Serving installation
undeploy-release:
./scripts/delete.sh --namespace ${NAMESPACE} --local-config-path config

# Generate manifests e.g. CRD, RBAC etc.
.PHONY: manifests
## Generate manifests e.g. CRD, RBAC etc.
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
Expand All @@ -135,38 +150,42 @@ manifests: controller-gen
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
## Auto-format source code and report code-style violations (lint)
fmt:
./scripts/fmt.sh || (echo "Linter failed: $$?"; git status; exit 1)

# Generate code
.PHONY: generate
## Generate code
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 runtime container image
build: build.develop
./scripts/build_docker.sh --target runtime --engine $(ENGINE)

# Build the develop docker image
.PHONY: build.develop
## Build developer container image
build.develop:
./scripts/build_devimage.sh $(ENGINE)

# Start a terminal session in the develop docker container
.PHONY: develop
## Run interactive shell inside developer container
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 make target inside developer container (e.g. `make run fmt`)
run: build.develop
./scripts/develop.sh make $(RUN_ARGS)

.PHONY: push
## Push the controller runtime image
push:
docker push ${IMG}

# Build the docker image
.PHONY: docker-build
docker-build: build
Expand All @@ -176,9 +195,8 @@ docker-build: build
docker-push:
podman push ${IMG}

# find or download controller-gen
# download controller-gen if necessary
.PHONY: controller-gen
## Find or download controller-gen
controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
Expand All @@ -190,16 +208,22 @@ else
CONTROLLER_GEN=$(shell which controller-gen)
endif

# Model Mesh gRPC codegen
.PHONY: mmesh-codegen
mmesh-codegen:
.PHONY: codegen
## Generate gRPC code stubs (protoc)
codegen:
protoc -I proto/ --go_out=plugins=grpc:generated/ $(PROTO_FILES)

# Check markdown files for invalid links
.PHONY: check-doc-links
## Check markdown files for invalid links
check-doc-links:
@python3 scripts/verify_doc_links.py && echo "$@: OK"

.DEFAULT_GOAL := help
.PHONY: help
## Print Makefile documentation
help:
@perl -0 -nle 'printf("\033[36m %-20s\033[0m %s\n", "$$2", "$$1") while m/^##\s*([^\r\n]+)\n^([\w.-]+):[^=]/gm' $(MAKEFILE_LIST) | sort

# Override targets if they are included in RUN_ARGs so it doesn't run them twice
$(eval $(RUN_ARGS):;@:)

Expand Down
Loading

0 comments on commit 97f2a83

Please sign in to comment.