Sub topic 7
Choosing a KServe Deployment Mode
This chapter assumes you know Kubernetes pods, Deployments, Services, namespaces, and YAML manifests. You should also be comfortable applying resources with kubectl and sending JSON over HTTP.
KServe can run an inference service in two main modes:
- Serverless uses Knative Serving to manage revisions, routing, and autoscaling.
- RawDeployment uses ordinary Kubernetes Deployments and Services.
Both modes expose a model as an endpoint. They differ in how Kubernetes creates pods, routes requests, and scales the workload.
Serverless mode
Serverless mode is the usual KServe choice when Knative is installed. KServe creates a Knative Service for the predictor. Knative then manages the underlying Deployment and request routing.
Serverless mode is useful when:
- Traffic is intermittent.
- You want scale to zero.
- You need request-based autoscaling.
- You plan to use revisions or traffic splitting.
- You want KServe and Knative to manage rollout behavior together.
A service with minReplicas: 0 can remove all model pods when no requests arrive. The next request causes a cold start while KServe downloads the model and starts the container. Cold starts can take seconds or longer for large models.
The following manifest selects Serverless mode explicitly:
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
namespace: ml
spec:
predictor:
deploymentMode: Serverless
minReplicas: 0
maxReplicas: 5
scaleMetric: concurrency
scaleTarget: 10
model:
modelFormat:
name: sklearn
storageUri: gs://kfserving-examples/models/sklearn/1.0/modelscaleTarget: 10 tells the autoscaler to aim for about ten concurrent requests per pod. The exact behavior also depends on the Knative autoscaler configuration and the time window used to measure traffic.
RawDeployment mode
RawDeployment mode creates standard Kubernetes resources instead of requiring Knative. This mode is useful when:
- Knative is unavailable or not allowed in the cluster.
- You need ordinary Kubernetes Deployment behavior.
- Traffic is steady enough to keep replicas running.
- Your platform team already operates Kubernetes-native autoscaling.
- You need predictable pod and Service behavior.
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
namespace: ml
spec:
predictor:
deploymentMode: RawDeployment
minReplicas: 2
maxReplicas: 6
model:
modelFormat:
name: sklearn
storageUri: gs://kfserving-examples/models/sklearn/1.0/modelRawDeployment normally keeps at least minReplicas pods running. Its scaling behavior depends on the autoscaling configuration available in the cluster, such as a Kubernetes Horizontal Pod Autoscaler or another supported controller. It does not provide Serverless mode's Knative scale-to-zero behavior by default.
Compare the modes
| Decision | Serverless | RawDeployment |
|---|---|---|
| Required platform | Knative Serving | Kubernetes |
| Scale to zero | Supported | Not the default |
| Cold starts | Possible | Avoided when replicas stay running |
| Request-based scaling | Knative autoscaler | Cluster autoscaling tools |
| Best fit | Bursty or infrequent traffic | Steady traffic or simple operations |
Choose Serverless when Knative features are part of your platform and traffic changes over time. Choose RawDeployment when you want standard Kubernetes behavior, stable warm replicas, or fewer platform dependencies. Test startup time, memory use, and request latency with a workload that resembles production.
Exercise
A model receives a few requests every hour, and a several-second cold start is acceptable. Which deployment mode and replica setting are a good starting point?
Show answer
Use Serverless mode with minReplicas: 0, because Knative can scale the service to zero between requests.