Skip to content

Commit

Permalink
test: end-to-end demo with KServe ModelCar (#5)
Browse files Browse the repository at this point in the history
Signed-off-by: tarilabs <[email protected]>
  • Loading branch information
tarilabs authored Dec 19, 2024
1 parent 3ef324c commit ece9e4b
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,35 @@ jobs:
- name: Run E2E tests
run: |
make test-e2e-skopeo
- name: Continue E2E by deploying KServe
run: |
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml
e2e/repeat.sh kubectl apply --server-side -f https://github.com/kserve/kserve/releases/download/v0.14.0/kserve.yaml
e2e/repeat.sh kubectl apply --server-side -f https://github.com/kserve/kserve/releases/download/v0.14.0/kserve-cluster-resources.yaml
kubectl patch configmap/inferenceservice-config -n kserve --type=strategic -p '{"data": {"deploy": "{\"defaultDeploymentMode\": \"RawDeployment\"}"}}'
e2e/enable-modelcar.sh
- name: Load image in KinD for amd64
run: |
digest=$(skopeo inspect --tls-verify=false --raw docker://localhost:5001/nstestorg/modelcar | jq -r '.manifests[] | select(.platform.architecture == "amd64") | .digest')
skopeo copy --src-tls-verify=false docker://localhost:5001/nstestorg/modelcar@$digest docker-daemon:localhost:5001/nstestorg/modelcar:v1
kind load docker-image -n "kind" "localhost:5001/nstestorg/modelcar:v1"
- name: Apply Isvc using Modelcar # since the enable modelcar restart controller pod, better guard the kubectl apply
run: |
e2e/repeat.sh kubectl apply -f e2e/isvc-modelcar.yaml
kubectl wait --for=condition=Ready isvc/my-inference-service --timeout=240s
- name: Basic testing of Isvc that has Modelcar
run: |
echo "Starting port-forward..."
kubectl port-forward svc/my-inference-service-predictor 8080:80 &
PID=$!
sleep 2
echo "I have launched port-forward in background with: $PID."
echo "Check that OIP return the expected name"
curl -s http://localhost:8080/v2/models | jq -e '.models | index("my-inference-service") != null'
echo "Check that OIP produces an Inference Prediction"
curl -s -H "Content-Type: application/json" -d @e2e/data/input0.json http://localhost:8080/v2/models/my-inference-service/infer | jq
curl -s -H "Content-Type: application/json" -d @e2e/data/input1.json http://localhost:8080/v2/models/my-inference-service/infer | jq
curl -s -H "Content-Type: application/json" -d @e2e/data/input4.json http://localhost:8080/v2/models/my-inference-service/infer | jq
e2e-oras:
name: E2E using Oras CP
runs-on: ubuntu-24.04
Expand Down
11 changes: 11 additions & 0 deletions e2e/data/input0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"inputs": [
{
"name": "input-0",
"shape": [1, 4],
"datatype": "FP32",
"data": [6.2, 3.4, 5.4, 2.3]
}
]
}

11 changes: 11 additions & 0 deletions e2e/data/input1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"inputs": [
{
"name": "input-0",
"shape": [1, 4],
"datatype": "FP32",
"data": [5.4, 3.9, 1.7, 0.4]
}
]
}

11 changes: 11 additions & 0 deletions e2e/data/input4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"inputs": [
{
"name": "input-0",
"shape": [1, 4],
"datatype": "FP32",
"data": [6.6, 3.0, 4.4, 1.4]
}
]
}

24 changes: 24 additions & 0 deletions e2e/enable-modelcar.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# from https://kserve.github.io/website/latest/modelserving/storage/oci/#enabling-modelcars
# Script to enable Modelcars
# Fetch the current storageInitializer configuration
config=$(kubectl get configmap inferenceservice-config -n kserve -o jsonpath='{.data.storageInitializer}')
# Enable modelcars and set the UID for the containers to run (required for minikube)
newValue=$(echo $config | jq -c '. + {"enableModelcar": true, "uidModelcar": 1010}')

# Create a temporary directory for the patch file
tmpdir=$(mktemp -d)
cat <<EOT > $tmpdir/patch.txt
[{
"op": "replace",
"path": "/data/storageInitializer",
"value": '$newValue'
}]
EOT

# Apply the patch to the ConfigMap
kubectl patch configmap -n kserve inferenceservice-config --type=json --patch-file=$tmpdir/patch.txt

# Restart the KServe controller to apply changes
kubectl delete pod -n kserve -l control-plane=kserve-controller-manager
10 changes: 10 additions & 0 deletions e2e/isvc-modelcar.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: my-inference-service
spec:
predictor:
model:
modelFormat:
name: sklearn
storageUri: oci://localhost:5001/nstestorg/modelcar:v1
5 changes: 5 additions & 0 deletions e2e/repeat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
set -e
set -o xtrace

while ! $@ ; do echo "Retrying..."; sleep 5; done

0 comments on commit ece9e4b

Please sign in to comment.