Skip to content

Commit

Permalink
Setup KF Model Registry GH tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Lamparelli <[email protected]>
Signed-off-by: Ricardo M. Oliveira <[email protected]>
  • Loading branch information
lampajr authored and rimolive committed May 3, 2024
1 parent f34c3c4 commit 101fd6d
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 28 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/model_registry_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# If anyone changes or improve the following tests for Model Registry, please
# consider reflecting the same changes on https://github.com/kubeflow/model-registry
name: Deploy and test Kubeflow Model Registry
on:
pull_request:
paths:
- apps/model-registry/upstream/**
- tests/gh-actions/kind-cluster.yaml
- tests/gh-actions/install_istio.sh

jobs:
build-kfmr:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install KinD
run: ./tests/gh-actions/install_kind.sh

- name: Create KinD Cluster
run: kind create cluster --config tests/gh-actions/kind-cluster.yaml

- name: Install kustomize
run: ./tests/gh-actions/install_kustomize.sh

- name: Install Istio
run: ./tests/gh-actions/install_istio.sh

- name: Create kubeflow namespace
run: kustomize build common/kubeflow-namespace/base | kubectl apply -f -

- name: Build & Apply KF Model Registry manifests
run: |
kustomize build apps/model-registry/upstream/overlays/db | kubectl apply -f -
kustomize build apps/model-registry/upstream/options/istio | kubectl apply -f -
- name: Test KF Model Registry deployment
run: |
echo "Waiting for all Model Registry Pods to become ready..."
kubectl wait --for=condition=available -n kubeflow deployment/model-registry-db --timeout=600s
kubectl wait --for=condition=available -n kubeflow deployment/model-registry-deployment --timeout=600s
8 changes: 8 additions & 0 deletions apps/model-registry/upstream/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
approvers:
- tarilabs
- rareddy
- Tomcli
reviewers:
- tarilabs
- rareddy
- Tomcli
56 changes: 56 additions & 0 deletions apps/model-registry/upstream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Install Kubeflow Model Registry

This folder contains [Kubeflow Model Registry](https://www.kubeflow.org/docs/components/model-registry/installation/) Kustomize manifests

## Installation

To install Kubeflow Model Registry, follow [Kubeflow Model Registry deployment documentation](https://www.kubeflow.org/docs/components/model-registry/installation/)

The following instructions will summarize how to deploy Model Registry as separate component in the context of a default Kubeflow >=1.8 installation.

```bash
kubectl apply -k overlays/db
```

As the default Kubeflow installation provides an Istio mesh, apply the necessary manifests:

```bash
kubectl apply -k options/istio
```

Check everything is up and running:

```bash
kubectl wait --for=condition=available -n kubeflow deployment/model-registry-deployment --timeout=2m
kubectl logs -n kubeflow deployment/model-registry-deployment
```

Optionally, you can also port-forward the REST API container port of Model Registry to interact with it from your terminal:

```bash
kubectl port-forward svc/model-registry-service -n kubeflow 8081:8080
```

And then, from another terminal:

```bash
curl -sX 'GET' \
'http://localhost:8081/api/model_registry/v1alpha3/registered_models?pageSize=100&orderBy=ID&sortOrder=DESC' \
-H 'accept: application/json' | jq
```

## Usage

For a basic usage of the Kubeflow Model Registry, follow the [Kubeflow Model Registry getting started documentation](https://www.kubeflow.org/docs/components/model-registry/getting-started/)

## Uninstall

To uninstall the Kubeflow Model Registry run:

```bash
# Delete istio options
kubectl delete -k options/istio

# Delete model registry db and deployment
kubectl delete -k overlays/db
```
59 changes: 31 additions & 28 deletions hack/sync-model-registry-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,61 @@
#
# Afterwards the developers can submit the PR to the kubeflow/manifests
# repo, based on that local branch
# It must be executed directly from its directory

# strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -euo pipefail
set -euxo pipefail
IFS=$'\n\t'

COMMIT="v0.2.0-alpha" # You can use tags as well
DEV_MODE=${DEV_MODE:=false}
SRC_DIR=${SRC_DIR:=/tmp/kubeflow-model-registry}
BRANCH=${BRANCH:=sync-kubeflow-model-registry-manifests-${COMMIT?}}

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
MANIFESTS_DIR=$(dirname $SCRIPT_DIR)

if [ "$DEV_MODE" != "false" ]; then
echo "WARNING: Dev mode enabled..."
fi

echo "Creating branch: ${BRANCH}"

# DEV: Comment out this if you are testing locally
if [ -n "$(git status --porcelain)" ]; then
# Uncommitted changes
echo "WARNING: You have uncommitted changes, exiting..."
exit 1
echo "WARNING: You have uncommitted changes"
fi

if [ `git branch --list $BRANCH` ]
then
echo "WARNING: Branch $BRANCH already exists. Exiting..."
exit 1
echo "WARNING: Branch $BRANCH already exists."
fi

# DEV: If you are testing locally set DEV_MODE=true to skip this step
if [ "$DEV_MODE" = "false" ]; then
# Create the branch in the manifests repository
if ! git show-ref --verify --quiet refs/heads/$BRANCH; then
git checkout -b $BRANCH
else
echo "Branch $BRANCH already exists."
fi

echo "Checking out in $SRC_DIR to $COMMIT..."

# Checkout the Model Registry repository
mkdir -p $SRC_DIR
cd $SRC_DIR
if [ ! -d "model-registry/.git" ]; then
git clone https://github.com/kubeflow/model-registry.git
fi
cd $SRC_DIR/model-registry
if ! git rev-parse --verify --quiet $COMMIT; then
git checkout -b $COMMIT
else
git checkout $COMMIT
fi

if [ -n "$(git status --porcelain)" ]; then
# Uncommitted changes
echo "WARNING: You have uncommitted changes, exiting..."
exit 1
echo "WARNING: You have uncommitted changes"
fi
git checkout $COMMIT

echo "Copying model-registry manifests..."
DST_DIR=$MANIFESTS_DIR/apps/model-registry/upstream
rm -rf $DST_DIR
mkdir -p $DST_DIR
if [ -d "$DST_DIR" ]; then
rm -r "$DST_DIR"
fi
cp $SRC_DIR/manifests/kustomize/* $DST_DIR -r

echo "Successfully copied all manifests."
Expand All @@ -68,11 +74,8 @@ DST_TXT="\[$COMMIT\](https://github.com/kubeflow/model-registry/tree/$COMMIT/man

sed -i "s|$SRC_TXT|$DST_TXT|g" ${MANIFESTS_DIR}/README.md

# DEV: If you are testing locally set DEV_MODE=true to skip this step
if [ "$DEV_MODE" = "false" ]; then
echo "Committing the changes..."
cd $MANIFESTS_DIR
git add apps
git add README.md
git commit -s -m "Update kubeflow/model-registry manifests from ${COMMIT}"
fi
echo "Committing the changes..."
cd $MANIFESTS_DIR
git add apps
git add README.md
git commit -s -m "Update kubeflow/model-registry manifests from ${COMMIT}"

0 comments on commit 101fd6d

Please sign in to comment.