Sub topic 9
Canary Rollouts and Rollback
Assume you understand Kubernetes Deployments, Services, namespaces, and kubectl. You should also know how to apply an InferenceService and send an HTTP prediction request.
A canary rollout sends a small percentage of requests to a new model version while the current version continues serving most traffic. This lets you compare accuracy, latency, errors, and resource use before promoting the new version.
KServe creates a new revision when the predictor configuration changes. The change might be a different storageUri, runtime, container image, or other serving setting. With Knative-based deployment, KServe can route traffic between the current and canary revisions.
Configure a canary
The following manifest changes the model location and sends 10 percent of traffic to the new version:
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
spec:
predictor:
canaryTrafficPercent: 10
model:
modelFormat:
name: sklearn
storageUri: gs://example-bucket/models/sklearn/iris/v2The canaryTrafficPercent field controls the share sent to the new revision. The remaining traffic stays with the previous revision. Replace the example storage path with a location that contains your model.
Apply the updated resource and inspect its status:
kubectl apply -f sklearn-iris-canary.yaml
kubectl get inferenceservice sklearn-iris
kubectl describe inferenceservice sklearn-irisThe status should show the service URL and revision information. A service can report ready before you have collected enough application-level evidence, so also monitor requests and model results.
Observe before promoting
A canary test should use representative requests. Compare the revisions using metrics such as:
- Prediction quality against labeled or reviewed examples.
- Request latency, especially the 95th or 99th percentile.
- HTTP errors, timeouts, and failed model loads.
- CPU, memory, and GPU use.
- Business signals such as conversion or rejection rates.
A successful readiness check only proves that the serving components started. It does not prove that the new model is correct.
| Observation | Action |
|---|---|
| Errors and latency remain acceptable | Increase the canary percentage or promote |
| Model results are wrong or the pod fails | Set canary traffic to zero |
| Results are uncertain | Keep the small percentage and collect more evidence |
Promote or roll back
After validation, promote the canary by setting its traffic percentage to 100:
spec:
predictor:
canaryTrafficPercent: 100
model:
modelFormat:
name: sklearn
storageUri: gs://example-bucket/models/sklearn/iris/v2Apply the file again:
kubectl apply -f sklearn-iris-promote.yaml
kubectl get inferenceservice sklearn-irisTo roll back, restore the previous model location and remove the canary setting, or explicitly direct all traffic back to the stable revision according to the KServe version and deployment configuration used by your cluster. A simple model-based rollback looks like this:
apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
name: sklearn-iris
spec:
predictor:
model:
modelFormat:
name: sklearn
storageUri: gs://example-bucket/models/sklearn/iris/v1Apply the rollback and verify both readiness and predictions. Keep the old model artifacts available until the rollout is complete. Deleting them too early can prevent a reliable rollback.
Exercise
A new model receives 10 percent of traffic and produces incorrect predictions, while the old model is healthy. What should you do first?
Show answer
Stop sending traffic to the new revision by rolling back the InferenceService to the old model configuration, then verify readiness and predictions before investigating the new model.