Integrating KServe with ASM allows developers to quickly deploy and manage inference services for machine learning models in cloud-native applications, reducing manual configuration and maintenance and improving development efficiency.
Prerequisites
-
An ACK cluster has been added to an ASM instance running v1.17.2.7 or later.
-
The feature to access Istio resources using the cluster's Kubernetes API has been enabled.
-
Knative components have been deployed in the ACK cluster, and the Knative on ASM feature has been enabled. For more information, see Step 1 in Deploy a serverless application by using Knative on ASM.
KServe
As a model server, KServe provides a foundation for serving machine learning and deep learning models at scale. KServe can be deployed as a traditional Kubernetes Deployment or in a serverless, scale-to-zero mode. It offers traffic-based auto scaling, and blue-green and canary deployments for models. For more information, see the KServe documentation.

Step 1: Install the KServe component
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the target ASM instance. In the navigation pane on the left, choose .
-
On the KServe on ASM page, click Enable KServe on ASM.
KServe depends on cert-manager. When you install KServe, the cert-manager component is installed automatically. If you want to use a self-managed cert-manager, turn off Automatically install the CertManager component in the cluster.
Step 2: Get the ASM gateway address
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
-
On the Ingress Gateway page, find and record the Service address of the target gateway.
Step 3: Create an inference service
This topic uses a pre-trained scikit-learn model for testing.
-
Connect to the data plane cluster using kubectl and run the following command to create a namespace for KServe resources:
kubectl create namespace kserve-test -
Create an InferenceService.
-
Create a file named isvc.yaml with the following content:
apiVersion: "serving.kserve.io/v1beta1" kind: "InferenceService" metadata: name: "sklearn-iris" spec: predictor: model: modelFormat: name: sklearn storageUri: "gs://kfserving-examples/models/sklearn/1.0/model" -
Run the following command to create the InferenceService in the kserve-test namespace:
kubectl apply -f isvc.yaml -n kserve-test
-
-
Run the following command to check the status of the sklearn-iris InferenceService:
kubectl get inferenceservices sklearn-iris -n kserve-testExpected output:
NAME URL READY PREV LATEST PREVROLLEDOUTREVISION LATESTREADYREVISION AGE sklearn-iris http://sklearn-iris.kserve-test.example.com True 100 sklearn-iris-predictor-00001 3h26mREADYisTrue, indicating that the InferenceService sklearn-iris is successfully installed. -
Optional: View the virtual service and Gateway.
Creating the sklearn-iris InferenceService automatically creates a corresponding virtual service and Gateway.
-
Log on to the ASM console. In the left-side navigation pane, choose .
-
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
-
On the VirtualService page, click the
icon next to Namespaces, select Namespaces from the Namespace drop-down list, and view the new virtual service. -
In the navigation pane on the left, choose .
-
On the Gateway page, select Namespaces from the Namespace drop-down list to view the new Gateway.
-
Step 4: Access the model service
The following examples are for Linux and macOS environments.
-
Run the following command to create a model input file:
cat <<EOF > "./iris-input.json" { "instances": [ [6.8, 2.8, 4.8, 1.4], [6.0, 3.4, 4.5, 1.6] ] } EOF -
Test access via the ASM gateway.
-
Run the following command to obtain the SERVICE_HOSTNAME:
SERVICE_HOSTNAME=$(kubectl get inferenceservice sklearn-iris -n kserve-test -o jsonpath='{.status.url}' | cut -d "/" -f 3) echo $SERVICE_HOSTNAMEExpected output:
sklearn-iris.kserve-test.example.com -
Run the following command to access the model service using the ASM gateway address that you obtained in Step 2:
ASM_GATEWAY="XXXX" # Replace XXXX with your ASM gateway address. curl -H "Host: ${SERVICE_HOSTNAME}" http://${ASM_GATEWAY}:80/v1/models/sklearn-iris:predict -d @./iris-input.jsonExpected output:
{"predictions": [1, 1]}
-
-
Load test the model service.
-
Run the following command to deploy a client application for load testing:
kubectl create -f https://alibabacloudservicemesh.oss-cn-beijing.aliyuncs.com/kserve/v0.7/loadtest.yaml -
Run the following command to view the pod name:
kubectl get podExpected output:
NAME READY STATUS RESTARTS AGE load-testxhwtq-pj9fq 0/1 Completed 0 3m24s sklearn-iris-predictor-00001-deployment-857f9bb56c-vg8tf 2/2 Running 0 51m -
Run the following command to view the load test logs:
kubectl logs load-testxhwtq-pj9fq # Replace the pod name with the actual pod name of the load test application.Expected output:
Requests [total, rate, throughput] 30000, 500.02, 500.01 Duration [total, attack, wait] 59.999s, 59.998s, 1.352ms Latencies [min, mean, 50, 90, 95, 99, max] 1.196ms, 1.463ms, 1.378ms, 1.588ms, 1.746ms, 2.99ms, 18.873ms Bytes In [total, mean] 690000, 23.00 Bytes Out [total, mean] 2460000, 82.00 Success [ratio] 100.00% Status Codes [code:count] 200:30000 Error Set:
-
Related documentation
-
To accelerate model loading for data-intensive, cloud-native applications such as big data and AI, see Accelerate data access for AI Serving by using KServe and Fluid on ASM.
-
To convert raw input data into the format required by the model server, see Deploy a transformer by using an InferenceService.
-
For large-scale, high-density, and frequently changing model services, you can use Model Service Mesh to manage, deploy, and schedule multiple model services. For more information, see Model Service Mesh.