Implementation:Kserve Kserve TrainedModel Full CRD
| Knowledge Sources | |
|---|---|
| Domains | Kubernetes, Multi-Model Serving |
| Last Updated | 2026-02-13 00:00 GMT |
Overview
Concrete CustomResourceDefinition for the TrainedModel resource provided by the KServe project.
Description
This file defines the full CRD for the TrainedModel custom resource (short name: tm), which represents individual trained models that can be loaded into a multi-model serving InferenceService. It is a namespaced v1alpha1 resource with spec fields for inferenceService reference and model details (framework, memory, storageUri), plus Knative-style status with conditions, URL, and address fields. This CRD enables multi-model serving by allowing multiple TrainedModel resources to be associated with a single InferenceService.
Usage
Apply this CRD to a Kubernetes cluster to enable multi-model serving workflows. Users create TrainedModel resources that reference an existing InferenceService, specifying the model framework, memory requirements, and storage location. The controller then loads these models into the referenced InferenceService. This follows the principle described in Kserve_Kserve_TrainedModel_Registration.
Code Reference
Source Location
- Repository: Kserve_Kserve
- File: config/crd/full/serving.kserve.io_trainedmodels.yaml
- Lines: 1-111
Signature
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.19.0
name: trainedmodels.serving.kserve.io
spec:
group: serving.kserve.io
names:
kind: TrainedModel
listKind: TrainedModelList
plural: trainedmodels
shortNames:
- tm
singular: trainedmodel
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .status.url
name: URL
type: string
- jsonPath: .status.conditions[?(@.type=='Ready')].status
name: Ready
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
properties:
spec:
properties:
inferenceService:
type: string
model:
properties:
framework:
type: string
memory:
x-kubernetes-int-or-string: true
storageUri:
type: string
required:
- framework
- memory
- storageUri
required:
- inferenceService
- model
Import
kubectl apply -f config/crd/full/serving.kserve.io_trainedmodels.yaml
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| spec.inferenceService | string | Yes | Name of the InferenceService to load this model into |
| spec.model.framework | string | Yes | The ML framework of the model (e.g., sklearn, tensorflow, pytorch) |
| spec.model.memory | integer or string (Quantity) | Yes | Memory required by the model |
| spec.model.storageUri | string | Yes | URI pointing to the model artifact storage location |
Outputs
| Name | Type | Description |
|---|---|---|
| TrainedModel CRD | CustomResourceDefinition | Registers the TrainedModel resource type in the Kubernetes API server |
| status.url | string | The URL at which the trained model is accessible |
| status.conditions | array | Knative-style conditions indicating readiness and health |
| status.address | object | Address information including URL, CACerts, and audience |
Usage Examples
Apply the CRD
kubectl apply -f config/crd/full/serving.kserve.io_trainedmodels.yaml
Create a TrainedModel resource
apiVersion: serving.kserve.io/v1alpha1
kind: TrainedModel
metadata:
name: my-sklearn-model
namespace: default
spec:
inferenceService: my-inference-service
model:
framework: sklearn
memory: "1Gi"
storageUri: "gs://my-bucket/sklearn-model"