Sub topic 5
Loading Models from Storage with `storageUri`
Prerequisites and the model-loading path
This chapter assumes that you understand Kubernetes pods, namespaces, services, and YAML manifests. You should also know how to apply a manifest with kubectl, how to save a trained model, and how to send JSON over HTTP.
A KServe model usually starts in object storage or a persistent volume. The storageUri field tells KServe where to find the model artifacts. KServe then uses a storage initializer to copy those artifacts into the serving pod before the model server starts.
The URI scheme identifies the storage system:
gs://points to Google Cloud Storage.s3://points to Amazon S3 or an S3-compatible service.pvc://points to a mounted PersistentVolumeClaim.- A supported HTTP or HTTPS URI can point to downloadable model files, depending on the runtime and KServe version.
The directory must have the layout expected by the selected serving runtime. A scikit-learn runtime, for example, expects a compatible serialized model. A TensorFlow runtime expects a SavedModel directory.
Declare the storage location
This manifest asks KServe to load a scikit-learn model from Google Cloud Storage:
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/modelThe modelFormat.name value helps KServe select a compatible serving runtime. The storageUri is a location, not an upload command. The model must already exist there, and the Kubernetes workload must have permission to read it.
Apply the resource and inspect its status:
kubectl apply -f sklearn-iris.yaml
kubectl get inferenceservice sklearn-iris
kubectl describe inferenceservice sklearn-irisWait for the predictor to become ready before sending requests. If the service does not become ready, inspect the predictor pod and its events:
kubectl get pods
kubectl describe pod <predictor-pod-name>
kubectl logs <predictor-pod-name> -c storage-initializerThe storage initializer log often reveals an invalid URI, a missing object, or an authentication failure.
Permissions and reproducibility
Storage access is part of the deployment design. In production, give the serving workload read-only access to the model location. Use Kubernetes service accounts, cloud workload identity, or a secret managed by your platform. Do not place access keys in the InferenceService manifest or in source control.
Keep model artifacts immutable when possible. A versioned path such as models/sklearn/iris/v2 makes a deployment reproducible. Replacing files at a fixed path can cause different pods to load different content during a rollout.
Exercise
What must be true before a predictor can become ready when its model uses storageUri?
Show answer
The URI must identify an accessible model location, the artifacts must match the selected runtime, and the predictor workload must have permission to read them.