KFServing
Introduction
Section titled “Introduction”KFServing provides Kubernetes CRDs for machine learning model serving. It exposes high-level, production-oriented interfaces for common ML frameworks such as TensorFlow, XGBoost, Scikit-Learn, PyTorch, and ONNX, making it possible to operate trained models as services on Kubernetes.
- Features (https://github.com/kserve/kserve/blob/master/docs/samples/README.md)
- Scale to and from Zero
- Request based Autoscaling on CPU/GPU
- Revision Management
- Optimized Container
- Batching
- Request/Response logging
- Scalable Multi Model Serving
- Traffic management
- Security with AuthN/AuthZ
- Distributed Tracing
- Out-of-the-box metrics
- Ingress/Egress control
| KFServing can offer these serverless-style features because it builds on custom resources that are already provided by components such as Istio and Knative inside a Kubernetes cluster. You can also deploy Kubeflow, which includes KFServing as an embedded component, and use it as a fully managed MLOps framework.

See KFServing GitHub repository https://github.com/kserve/kserve See the KFServing v1beta1 RFC https://docs.google.com/document/d/1ktiO7gWohq19C_rixXH0T_D91TjkrQELlQjlkvSefVc/edit#heading=h.e1sgar1o8xoy
Architecture
Section titled “Architecture”- Architecture overview
- Data plane : The path that actually delivers traffic, shown here with a single-model request flow.
- Control plane : The layer that creates, configures, and controls the resources behind that data plane.
KFServing Architecture Overview https://github.com/kserve/kserve/blob/master/docs/README.md
Data Plane
Section titled “Data Plane”A predictor container is the core runtime for basic model serving. Explainer and transformer components are optional and can be added when a serving workflow needs explanation or pre/post-processing.
- Example request flow for a single model

-
Concepts
- Endpoint: An inference service is split into two endpoints,
defaultandcanary. The canary endpoint is optional, and the rollout strategy can be changed through detailedInferenceServicesettings. By default, traffic goes to thedefaultendpoint. - Predictor: The mandatory component of an InferenceService. It is the model-serving runtime that exposes a model at a network endpoint.
- Explainer: An optional data-plane component that provides model explanation in addition to ordinary prediction. It can be implemented with a user-defined container. KFServing commonly provides built-in explainers such as Alibi.
- Transformer: Lets users run pre-processing and post-processing around the prediction or explanation flow. It can also be implemented with a user-defined container. KFServing commonly provides built-in transformers such as Feast.
- Endpoint: An inference service is split into two endpoints,
-
Data Plane API (v2)
- The older v1 API is being consolidated into v2. In v1,
predictandexplainwere exposed separately as shown in the diagram above, while in v2 they are converging around the predict API. - Supports HTTP/REST and gRPC
- The older v1 API is being consolidated into v2. In v1,
See the v2 API docs https://github.com/kserve/kserve/tree/master/docs/predict-api/v2
Control Plane
Section titled “Control Plane”Using Kubernetes custom resources such as InferenceService and TrainedModel, KFServing deploys predictor, explainer, and transformer containers and then performs actions such as autoscaling in response to workload traffic.

- Control plane components
- Knative Serving Controller: Manages service revisions and creates network routing resources. By default it also injects the Queue Proxy sidecar, which exposes traffic metrics and enforces concurrency limits.
- Knative Activator: Brings pods back after they have scaled to zero and forwards requests to them.
- Knative Autoscaler (KPA): Watches application traffic and scales replicas up and down according to the configured metrics.
- KFServing Controller: Creates the services needed for request/response logging, batching, model pooling, and the model-server and agent containers themselves.
- Ingress Gateway: Routes external and internal requests.
Istio & Knative
Section titled “Istio & Knative”At its core, KFServing is a serverless model-serving system, and Knative is the foundation that enables that behavior.
Knative handles ingress traffic through the gateway provided by Istio. When a service must be exposed externally, Istio VirtualService resources are created and linked to the ServerlessService objects that correspond to Knative-managed revisions.
The following is a compact summary of the Istio/Knative processing flow and the main API resources that KFServing relies on.
See the MLOps Community KFServing slides https://www.slideshare.net/theofpa/serving-models-using-kfserving
- Istio routing API
| API group | Resource |
|---|---|
| networking.istio.io | Gateway |
| networking.istio.io | VirtualService |
- Knative traffic flow

| API group | Resource |
|---|---|
| autoscaling.internal.knative.dev | Metric |
| autoscaling.internal.knative.dev | PodAutoscaler |
| caching.internal.knative.dev | Image |
| networking.internal.knative.dev | Ingress |
| networking.internal.knative.dev | ServerlessService |
| serving.knative.dev | Configuration |
| serving.knative.dev | Revision |
| serving.knative.dev | Route |
| serving.knative.dev | Service |
Kubernetes Deploy
Section titled “Kubernetes Deploy”The prerequisites from the official KFServing installation guide must be in place. It is also possible to install Kubeflow and consume KFServing as part of a larger ML pipeline, but the environment below was built as a standalone KFServing deployment.
See the KFServing install guide https://github.com/kserve/kserve#install-kserve
Prerequisites
Section titled “Prerequisites”KFServing was moving from alpha toward beta when this was validated, and Knative was also changing quickly, so it was important to watch the deployment carefully. There can also be waiting periods while components such as cert-manager generate certificate secrets.
The prerequisite components were deployed as follows.
- Istio: v1.9.0
- Sidecar injection was not required here, so it was excluded from the installation.
- The
knative-local-gatewayservice created during Knative installation also appears in this namespace.
$ kubectl get all -n istio-system
NAME READY STATUS RESTARTS AGEpod/istio-ingressgateway-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/istiod-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/istiod-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/istiod-xxxxxxxxxx-xxxxx 1/1 Running 0 21h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/istio-ingressgateway LoadBalancer 10.0.0.15 <External-IP> 15021:32554/TCP,80:32236/TCP,443:31368/TCP,15012:30705/TCP,15443:30149/TCP 2d22hservice/istiod ClusterIP 10.0.0.16 <none> 15010/TCP,15012/TCP,443/TCP,15014/TCP 2d22hservice/knative-local-gateway ClusterIP 10.0.0.17 <none> 80/TCP 2d22h
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/istio-ingressgateway 1/1 1 1 2d22hdeployment.apps/istiod 3/3 3 3 2d22h- Knative Serving: v0.22.0
- The controller creates the serving containers used by KFServing and manages revisions and routes. Through the Queue Proxy sidecar it also exposes traffic metrics and enforces concurrency limits.
- The autoscaler watches serving-container metrics and performs automatic scale-out and scale-in.
- When a request arrives after scale-to-zero, the activator brings the pod back and forwards the request.
$ kubectl get all -n knative-serving
NAME READY STATUS RESTARTS AGEpod/activator-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/autoscaler-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/controller-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/istio-webhook-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/networking-istio-xxxxxxxxxx-xxxxx 1/1 Running 0 21hpod/webhook-xxxxxxxxxx-xxxxx 1/1 Running 0 21h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/activator-service ClusterIP 10.0.0.18 <none> 9090/TCP,8008/TCP,80/TCP,81/TCP 2d22hservice/autoscaler ClusterIP 10.0.0.19 <none> 9090/TCP,8008/TCP,8080/TCP 2d22hservice/autoscaler-bucket-00-of-01 ClusterIP 10.0.0.20 <none> 8080/TCP 2d22hservice/controller ClusterIP 10.0.0.21 <none> 9090/TCP,8008/TCP 2d22hservice/istio-webhook ClusterIP 10.0.0.22 <none> 9090/TCP,8008/TCP,443/TCP 2d22hservice/webhook ClusterIP 10.0.0.23 <none> 9090/TCP,8008/TCP,443/TCP 2d22h
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/activator 1/1 1 1 2d22hdeployment.apps/autoscaler 1/1 1 1 2d22hdeployment.apps/controller 1/1 1 1 2d22hdeployment.apps/istio-webhook 1/1 1 1 2d22hdeployment.apps/networking-istio 1/1 1 1 2d22hdeployment.apps/webhook 1/1 1 1 2d22h- Cert Manager: v1.3.1
$ kubectl get all -n cert-manager
NAME READY STATUS RESTARTS AGEpod/cert-manager-xxxxxxxxxx-xxxxx 1/1 Running 0 22hpod/cert-manager-cainjector-xxxxxxxxxx-xxxxx 1/1 Running 0 22hpod/cert-manager-webhook-xxxxxxxxxx-xxxxx 1/1 Running 0 22h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/cert-manager ClusterIP 10.0.0.24 <none> 9402/TCP 2d3hservice/cert-manager-webhook ClusterIP 10.0.0.25 <none> 443/TCP 2d3h
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/cert-manager 1/1 1 1 2d3hdeployment.apps/cert-manager-cainjector 1/1 1 1 2d3hdeployment.apps/cert-manager-webhook 1/1 1 1 2d3hKFServing Controller
Section titled “KFServing Controller”- KFServing
kfserving-controller: creates the services used for request/response logging, batching, and model pooling, and also creates the model servers themselves.
$ kubectl get all -n kfserving-system
NAME READY STATUS RESTARTS AGEpod/kfserving-controller-manager-0 2/2 Running 0 23h
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/kfserving-controller-manager-metrics-service ClusterIP 10.0.0.26 <none> 8443/TCP 2d3hservice/kfserving-controller-manager-service ClusterIP 10.0.0.27 <none> 443/TCP 2d3hservice/kfserving-webhook-server-service ClusterIP 10.0.0.28 <none> 443/TCP 2d3h
NAME READY AGEstatefulset.apps/kfserving-controller-manager 1/1 2d3h- KFServing request flow
+----------------------+ +-----------------------+ +----------------------------+ |Istio Virtual Service | |Istio Virtual Service | | K8S Service | | | | | | | |model-server | |model-server-predictor | | model-server-predictor | | +---->| -default +---->| -default-$revision | | | | | | | | *KFServing Route* | | *Knative Route* | | *Knative Revision Service* | +----------------------+ +-----------------------+ +----------------+-----------+ Istio Ingress Gateway Istio Local Gateway Kube Proxy | | | +-------------------------------------------------------+ | | *Knative Revision Pod* | | | | | | +-------------------+ +-----------------+ | | | | | | | | | | |kfserving-container|<-----+ Queue Proxy | |<------------------+ | | | | | | | +-------------------+ +--------------^--+ | | | | | | | +-----------------------^-------------------------------+ | scale deployment | +--------+--------+ | pull metrics | Knative | | | Autoscaler |----------- | KPA/HPA | +-----------------+InferenceService
Section titled “InferenceService”KFServing exposes two major custom resources, InferenceService and TrainedModel, but the core model-serving workflow built around a predictor can be implemented with InferenceService alone.
When you create an InferenceService on Kubernetes, resources like the following are created with it. The diagram below shows separate default and canary configurations, but an InferenceService can also be defined with only the default path.

- InferenceService
- A resource provided by KFServing, that is, by Kubeflow.
- Manages the overall lifecycle of the model server.
- Configuration
- A configuration resource provided by Knative.
- Tracks deployment history for the model server.
- Revision
- A revision resource provided by Knative.
- Created from configuration history; in practice it stores the serving-container spec.
- Route
- A route resource provided by Knative.
- Serves as the endpoint for network-traffic management.
- Routes traffic to the connected revision. (For example:
default-service -> revision-00X-service)
v1beta1 API
Section titled “v1beta1 API”With the KFServing API you create InferenceService, TrainedModel, and related resources while KFServing in turn manages the required Knative resources.
A predictor spec is mandatory, and predictor-level settings such as autoscaling and canary rollout can be configured there.
KFServing v1beta1 API docs https://github.com/kserve/kserve/tree/master/docs/apis/v1beta1
InferenceService deployment example
Section titled “InferenceService deployment example”The following shows the result of defining triton-inference-server as the predictor and deploying it through KFServing.
| During model serving, Triton can mount a model repository into the inference server and serve requests across multiple models. By contrast, runtimes such as TensorFlow appear to mount a single model into the predictor container. I did not dig far enough into real analyst workflows to compare those approaches in detail.
- Basic Kubernetes objects
# A service is created for each revision, and the serving container is deployed as a Deployment.$ kubectl get all
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEservice/triton-model ExternalName <none> knative-local-gateway.istio-system.svc.cluster.local <none> 2d18hservice/triton-model-predictor-default ExternalName <none> knative-local-gateway.istio-system.svc.cluster.local 80/TCP 2d18hservice/triton-model-predictor-default-00001 ClusterIP 10.0.0.29 <none> 80/TCP 2d18hservice/triton-model-predictor-default-00001-private ClusterIP 10.0.0.30 <none> 80/TCP,9090/TCP,9091/TCP,8022/TCP 2d18hservice/triton-model-predictor-default-00002 ClusterIP 10.0.0.31 <none> 80/TCP 2d18hservice/triton-model-predictor-default-00002-private ClusterIP 10.0.0.32 <none> 80/TCP,9090/TCP,9091/TCP,8022/TCP 2d18hservice/triton-model-predictor-default-00003 ClusterIP 10.0.0.33 <none> 80/TCP 25hservice/triton-model-predictor-default-00003-private ClusterIP 10.0.0.34 <none> 80/TCP,9090/TCP,9091/TCP,8022/TCP 25h
NAME READY UP-TO-DATE AVAILABLE AGEdeployment.apps/triton-model-predictor-default-00001-deployment 0/0 0 0 2d18hdeployment.apps/triton-model-predictor-default-00002-deployment 0/0 0 0 2d18hdeployment.apps/triton-model-predictor-default-00003-deployment 0/0 0 0 25h- Knative-related resources
# Knative InferenceService# - Query the canary rate, current revision, container status, and so on.$ kubectl get ksvc
NAME URL READY PREV LATEST PREVROLLEDOUTREVISION LATESTREADYREVISION AGEtriton-model http://triton-model.inference.<custom.domain> True 100 triton-model-predictor-default-00003 2d1h
# Knative configuration# - This configuration creates the revisions below.$ kubectl get configuration
NAME LATESTCREATED LATESTREADY READY REASONtriton-model-predictor-default triton-model-predictor-default-00003 triton-model-predictor-default-00003 True
# Knative revision$ kubectl revision configuration
NAME CONFIG NAME K8S SERVICE NAME GENERATION READY REASONtriton-model-predictor-default-00001 triton-model-predictor-default triton-model-predictor-default-00001 1 Truetriton-model-predictor-default-00002 triton-model-predictor-default triton-model-predictor-default-00002 2 Truetriton-model-predictor-default-00003 triton-model-predictor-default triton-model-predictor-default-00003 3 True
# Knative route$ kubectl route configuration
NAME URL READY REASONtriton-model-predictor-default http://triton-model-predictor-default.inference.<custom.domain> TruePredictor
Section titled “Predictor”Create an InferenceService, define a predictor, and KFServing will create the inference-server container for you.
- predictor
- You can use runtimes such as TFServing, TorchServe, Triton, MLServer/KFServer, and ONNX Runtime, each backed by an official image.
- A custom image can also be defined.
- storage
- Public-cloud object storage such as Amazon S3 and Google GCS can be used.
- PVC-based volume mounts are also supported.
Triton model server creation example
Section titled “Triton model server creation example”To mount Amazon S3 as storage, the related Secret and ServiceAccount were created in advance.
apiVersion: "serving.kubeflow.org/v1beta1"kind: "InferenceService"metadata: name: "triton-model" namespace: inferencespec: predictor: serviceAccountName: s3-sa triton: resources: limits: cpu: "1" memory: 2Gi storageUri: s3://kloudbank-triton-inference-server-repository/model_repositoryAutoscaling
Section titled “Autoscaling”As described above, Knative serving workloads scale in and out through HPA under the control of KPA. By setting minReplicas to 0, you can let unused model servers scale all the way down.
Main specs
Section titled “Main specs”-
minReplicas: minimum number of replicas- Default:
1 - If set to
0, the pod is terminated after the period configured in Knative.-
Related Knative Serving ConfigMap key:
scale-to-zero-grace-periodhttps://knative.dev/docs/serving/autoscaling/scale-to-zero/#scale-to-zero-last-pod-retention-period -
Example autoscaling history for an idle container
Terminal window $ kubectl get po -wNAME READY STATUS RESTARTS AGEtriton-model-predictor-default-00003-deployment-689d9545ff7hvkg 0/2 Pending 0 0striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 0/2 Pending 0 0striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 0/2 Init:0/1 0 0striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 0/2 Init:0/1 0 1striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 0/2 PodInitializing 0 4striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 1/2 Running 0 5striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 1/2 Running 0 6striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 2/2 Running 0 6striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 2/2 Terminating 0 68striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 1/2 Terminating 0 70striton-model-predictor-default-00003-deployment-689d9545ff7hvkg 0/2 Terminating 0 115s -
- Default:
-
maxReplicas: maximum number of replicas -
containerConcurrency- The number of requests that can be processed concurrently.
- Controls Knative Serving autoscaling behavior based on concurrency. https://knative.dev/docs/serving/autoscaling/concurrency
Canary
Section titled “Canary”By pointing to different storage locations, requests can be served by two or more model-server revisions.
In v1alpha2, default and canary predictor definitions were declared together in a single InferenceService. From v1beta1, it appears the pattern changed: first define the predictor used as the default, then add another predictor definition that specifies canaryTrafficPercent.
Because these InferenceService patches are all preserved and managed as revisions, the model-serving history is easier to roll back.
The following is the TensorFlow example from the KFServing samples.
- default predictor definition
apiVersion: "serving.kubeflow.org/v1beta1"kind: "InferenceService"metadata: name: "flower-sample" namespace: kfserving-testspec: predictor: minReplicas: 0 tensorflow: storageUri: gs://kfserving-samples/models/tensorflow/flowers- canary predictor and traffic percent definition
apiVersion: "serving.kubeflow.org/v1beta1"kind: "InferenceService"metadata: name: "flower-sample" namespace: kfserving-testspec: predictor: minReplicas: 0 # Indicates that this additional predictor is for canary handling. canaryTrafficPercent: 20 tensorflow: # Mount a different model storageUri: "gs://kfserving-samples/models/tensorflow/flowers-2"- The canary rollout can be checked by querying the
InferenceService
$ kubectl get isvc -owide
NAME URL READY PREV LATEST PREVROLLEDOUTREVISION LATESTREADYREVISION AGEflower-sample http://flower-sample.kfserving-test.<custom-domain> True 80 20 flower-sample-predictor-default-00002 flower-sample-predictor-default-00003 25hMonitoring
Section titled “Monitoring”This section is still pending a follow-up pass after the environment is rebuilt.