Skip to content

Commit

Permalink
Enable make to apply local changes of model servers, explainers and s…
Browse files Browse the repository at this point in the history
…torage-initializer (kserve#591)
  • Loading branch information
pugangxa authored and k8s-ci-robot committed Jan 1, 2020
1 parent 6a1c7fe commit 5f84617
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ bin
# Ignore files for local deployment
config/overlays/development/manager_image_patch.yaml
config/overlays/development/configmap/inferenceservice_patch.yaml
config/overlays/dev-image-config/inferenceservice_patch.yaml
config/overlays/local/
.ko.yaml

Expand Down
55 changes: 55 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ HAS_LINT := $(shell command -v golint;)
# Image URL to use all building/pushing image targets
IMG ?= kfserving-controller:latest
LOGGER_IMG ?= logger:latest
SKLEARN_IMG ?= sklearnserver:latest
XGB_IMG ?= xgbserver:latest
PYTORCH_IMG ?= pytorchserver:latest
ALIBI_IMG ?= alibi-explainer:latest
STORAGE_INIT_IMG ?= storage-initializer:latest

all: test manager logger

Expand Down Expand Up @@ -36,6 +41,26 @@ deploy-local: manifests
./hack/image_patch_dev.sh local
kustomize build config/overlays/local | kubectl apply -f -

deploy-dev-sklearn: docker-push-sklearn
./hack/model_server_patch_dev.sh sklearn ${KO_DOCKER_REPO}/${SKLEARN_IMG}
kustomize build config/overlays/dev-image-config | kubectl apply -f -

deploy-dev-xgb: docker-push-xgb
./hack/model_server_patch_dev.sh xgboost ${KO_DOCKER_REPO}/${XGB_IMG}
kustomize build config/overlays/dev-image-config | kubectl apply -f -

deploy-dev-pytorch: docker-push-pytorch
./hack/model_server_patch_dev.sh pytorch ${KO_DOCKER_REPO}/${PYTORCH_IMG}
kustomize build config/overlays/dev-image-config | kubectl apply -f -

deploy-dev-alibi: docker-push-alibi
./hack/alibi_patch_dev.sh ${KO_DOCKER_REPO}/${ALIBI_IMG}
kustomize build config/overlays/dev-image-config | kubectl apply -f -

deploy-dev-storageInitializer: docker-push-storageInitializer
./hack/misc_patch_dev.sh storageInitializer ${KO_DOCKER_REPO}/${STORAGE_INIT_IMG}
kustomize build config/overlays/dev-image-config | kubectl apply -f -

deploy-ci: manifests
kustomize build config/overlays/test | kubectl apply -f -

Expand Down Expand Up @@ -98,6 +123,36 @@ docker-build-logger: test
docker-push-logger:
docker push ${LOGGER_IMG}

docker-build-sklearn:
cd python && docker build -t ${KO_DOCKER_REPO}/${SKLEARN_IMG} -f sklearn.Dockerfile .

docker-push-sklearn: docker-build-sklearn
docker push ${KO_DOCKER_REPO}/${SKLEARN_IMG}

docker-build-xgb:
cd python && docker build -t ${KO_DOCKER_REPO}/${XGB_IMG} -f xgb.Dockerfile .

docker-push-xgb: docker-build-xgb
docker push ${KO_DOCKER_REPO}/${XGB_IMG}

docker-build-pytorch:
cd python && docker build -t ${KO_DOCKER_REPO}/${PYTORCH_IMG} -f pytorch.Dockerfile .

docker-push-pytorch: docker-build-pytorch
docker push ${KO_DOCKER_REPO}/${PYTORCH_IMG}

docker-build-alibi:
cd python && docker build -t ${KO_DOCKER_REPO}/${ALIBI_IMG} -f alibiexplainer.Dockerfile .

docker-push-alibi: docker-build-alibi
docker push ${KO_DOCKER_REPO}/${ALIBI_IMG}

docker-build-storageInitializer:
cd python && docker build -t ${KO_DOCKER_REPO}/${STORAGE_INIT_IMG} -f storage-initializer.Dockerfile .

docker-push-storageInitializer: docker-build-storageInitializer
docker push ${KO_DOCKER_REPO}/${STORAGE_INIT_IMG}

apidocs:
docker build -f docs/apis/Dockerfile --rm -t apidocs-gen . && \
docker run -it --rm -v ${GOPATH}/src/github.com/kubeflow/kfserving/pkg/apis:/go/src/github.com/kubeflow/kfserving/pkg/apis -v ${PWD}/docs/apis:/go/gen-crd-api-reference-docs/apidocs apidocs-gen
5 changes: 5 additions & 0 deletions config/overlays/dev-image-config/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bases:
- ../../default

patches:
- inferenceservice_patch.yaml
13 changes: 13 additions & 0 deletions docs/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,19 @@ make deploy-dev
- **Note**: `deploy-dev` builds the image from your local code, publishes to `KO_DOCKER_REPO`
and deploys the `kfserving-controller-manager` and `logger` with the image digest to your cluster for testing. Please also ensure you are logged in to `KO_DOCKER_REPO` from your client machine.

There's also commands to build and deploy the image from your local code for the models, explainer and storage-initializer, you can choose to use one of below commands for your development purpose.
```bash
make deploy-dev-sklearn

make deploy-dev-xgb

make deploy-dev-pytorch

make deploy-dev-alibi

make deploy-dev-storageInitializer
```
- **Note**: These commands also publishes to `KO_DOCKER_REPO` with the image of version 'latest', and change the configmap of your cluster to point to the new built images. It's just for development and testing purpose so you need to do it one by one. In configmap, for predictors it will just keep the one in development, for exlainer and storage initializer will just change the item impacted and set all others images including the `kfserving-controller-manager` and `logger` to be default.

### Smoke test after deployment
```bash
Expand Down
23 changes: 23 additions & 0 deletions hack/alibi_patch_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
# Usage: image_patch_dev.sh [OVERLAY]
set -u
IMG=$1
if [ -z ${IMG} ]; then exit; fi
cat > config/overlays/dev-image-config/inferenceservice_patch.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: inferenceservice-config
namespace: kfserving-system
data:
explainers: |-
{
"alibi": {
"image" : "${IMG}",
"defaultImageVersion": "latest",
"allowedImageVersions": [
"latest"
]
}
}
EOF
17 changes: 17 additions & 0 deletions hack/misc_patch_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -u
CONFIG_NAME=$1
IMG=$2
if [ -z ${IMG} -o -z ${CONFIG_NAME} ]; then exit; fi
cat > config/overlays/dev-image-config/inferenceservice_patch.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: inferenceservice-config
namespace: kfserving-system
data:
${CONFIG_NAME}: |-
{
"image" : "${IMG}"
}
EOF
23 changes: 23 additions & 0 deletions hack/model_server_patch_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -u
CONFIG_NAME=$1
IMG=$2
if [ -z ${IMG} -o -z ${CONFIG_NAME} ]; then exit; fi
cat > config/overlays/dev-image-config/inferenceservice_patch.yaml << EOF
apiVersion: v1
kind: ConfigMap
metadata:
name: inferenceservice-config
namespace: kfserving-system
data:
predictors: |-
{
"${CONFIG_NAME}": {
"image" : "${IMG}",
"defaultImageVersion": "latest",
"allowedImageVersions": [
"latest"
]
}
}
EOF

0 comments on commit 5f84617

Please sign in to comment.