Skip to content

Commit f3c41a5

Browse files
committed
test: end-to-end demo with KServe ModelCar
Signed-off-by: tarilabs <[email protected]>
1 parent 3ef324c commit f3c41a5

File tree

7 files changed

+101
-0
lines changed

7 files changed

+101
-0
lines changed

.github/workflows/e2e.yaml

+29
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,35 @@ jobs:
3737
- name: Run E2E tests
3838
run: |
3939
make test-e2e-skopeo
40+
- name: Continue E2E by deploying KServe
41+
run: |
42+
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.16.1/cert-manager.yaml
43+
e2e/repeat.sh kubectl apply --server-side -f https://github.com/kserve/kserve/releases/download/v0.14.0/kserve.yaml
44+
e2e/repeat.sh kubectl apply --server-side -f https://github.com/kserve/kserve/releases/download/v0.14.0/kserve-cluster-resources.yaml
45+
kubectl patch configmap/inferenceservice-config -n kserve --type=strategic -p '{"data": {"deploy": "{\"defaultDeploymentMode\": \"RawDeployment\"}"}}'
46+
e2e/enable-modelcar.sh
47+
- name: Load image in KinD for amd64
48+
run: |
49+
digest=$(skopeo inspect --tls-verify=false --raw docker://localhost:5001/nstestorg/modelcar | jq -r '.manifests[] | select(.platform.architecture == "amd64") | .digest')
50+
skopeo copy --src-tls-verify=false docker://localhost:5001/nstestorg/modelcar@$digest docker-daemon:localhost:5001/nstestorg/modelcar:v1
51+
kind load docker-image -n "kind" "localhost:5001/nstestorg/modelcar:v1"
52+
- name: Apply Isvc using Modelcar # since the enable modelcar restart controller pod, better guard the kubectl apply
53+
run: |
54+
e2e/repeat.sh kubectl apply -f e2e/isvc-modelcar.yaml
55+
kubectl wait --for=condition=Ready isvc/my-inference-service --timeout=240s
56+
- name: Basic testing of Isvc that has Modelcar
57+
run: |
58+
echo "Starting port-forward..."
59+
kubectl port-forward svc/my-inference-service-predictor 8080:80 &
60+
PID=$!
61+
sleep 2
62+
echo "I have launched port-forward in background with: $PID."
63+
echo "Check that OIP return the expected name"
64+
curl -s http://localhost:8080/v2/models | jq -e '.models | index("my-inference-service") != null'
65+
echo "Check that OIP produces an Inference Prediction"
66+
curl -s -H "Content-Type: application/json" -d @e2e/data/input0.json http://localhost:8080/v2/models/my-inference-service/infer | jq
67+
curl -s -H "Content-Type: application/json" -d @e2e/data/input1.json http://localhost:8080/v2/models/my-inference-service/infer | jq
68+
curl -s -H "Content-Type: application/json" -d @e2e/data/input4.json http://localhost:8080/v2/models/my-inference-service/infer | jq
4069
e2e-oras:
4170
name: E2E using Oras CP
4271
runs-on: ubuntu-24.04

e2e/data/input0.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"inputs": [
3+
{
4+
"name": "input-0",
5+
"shape": [1, 4],
6+
"datatype": "FP32",
7+
"data": [6.2, 3.4, 5.4, 2.3]
8+
}
9+
]
10+
}
11+

e2e/data/input1.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"inputs": [
3+
{
4+
"name": "input-0",
5+
"shape": [1, 4],
6+
"datatype": "FP32",
7+
"data": [5.4, 3.9, 1.7, 0.4]
8+
}
9+
]
10+
}
11+

e2e/data/input4.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"inputs": [
3+
{
4+
"name": "input-0",
5+
"shape": [1, 4],
6+
"datatype": "FP32",
7+
"data": [6.6, 3.0, 4.4, 1.4]
8+
}
9+
]
10+
}
11+

e2e/enable-modelcar.sh

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# from https://kserve.github.io/website/latest/modelserving/storage/oci/#enabling-modelcars
4+
# Script to enable Modelcars
5+
# Fetch the current storageInitializer configuration
6+
config=$(kubectl get configmap inferenceservice-config -n kserve -o jsonpath='{.data.storageInitializer}')
7+
# Enable modelcars and set the UID for the containers to run (required for minikube)
8+
newValue=$(echo $config | jq -c '. + {"enableModelcar": true, "uidModelcar": 1010}')
9+
10+
# Create a temporary directory for the patch file
11+
tmpdir=$(mktemp -d)
12+
cat <<EOT > $tmpdir/patch.txt
13+
[{
14+
"op": "replace",
15+
"path": "/data/storageInitializer",
16+
"value": '$newValue'
17+
}]
18+
EOT
19+
20+
# Apply the patch to the ConfigMap
21+
kubectl patch configmap -n kserve inferenceservice-config --type=json --patch-file=$tmpdir/patch.txt
22+
23+
# Restart the KServe controller to apply changes
24+
kubectl delete pod -n kserve -l control-plane=kserve-controller-manager

e2e/isvc-modelcar.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: serving.kserve.io/v1beta1
2+
kind: InferenceService
3+
metadata:
4+
name: my-inference-service
5+
spec:
6+
predictor:
7+
model:
8+
modelFormat:
9+
name: sklearn
10+
storageUri: oci://localhost:5001/nstestorg/modelcar:v1

e2e/repeat.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
set -o xtrace
4+
5+
while ! $@ ; do echo "Retrying..."; sleep 5; done

0 commit comments

Comments
 (0)