Sub topic 1
Why Serving Models Needs More Than a Deployment
Prerequisites
This chapter assumes you know Kubernetes pods, Deployments, Services, and namespaces. You should be able to apply YAML with kubectl, have a trained scikit-learn model saved in object storage, and be comfortable reading JSON over HTTP.
Why serving models needs more than a Deployment
A plain Deployment runs a container, and a Service routes traffic to it. That covers the process, but model serving needs more. You must load the model into a server that understands its format, scale with request load, shift traffic between model versions, and expose a predictable prediction API. KServe adds these behaviors as custom resources on top of Kubernetes.
How KServe is put together
KServe runs a controller that watches for its custom resources. You declare a model in an InferenceService, and the controller creates the pods, routes, and scaling rules needed to serve it.
Your first InferenceService
Save this manifest as sklearn-iris.yaml. It asks KServe to serve a scikit-learn model from a Cloud Storage path.
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/modelApply it and check the status:
kubectl apply -f sklearn-iris.yaml
kubectl get inferenceservice sklearn-irisServing runtimes: how a model format maps to a server
A ServingRuntime is a template that names a model server image and the model formats it supports. KServe matches modelFormat.name in your InferenceService to a runtime that supports that format.
| Model format | Typical built-in runtime |
|---|---|
| sklearn | kserve-sklearnserver |
| xgboost | kserve-xgbserver |
Runtime names vary by KServe version, so check your install with kubectl get clusterservingruntimes.
Exercise
Which field in the InferenceService tells KServe what kind of model is in storage?
Show answer
spec.predictor.model.modelFormat.name. KServe uses this value to choose a matching serving runtime.