Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Kserve Kserve CanaryTrafficPercent Spec

From Leeroopedia
Knowledge Sources
Domains MLOps, Deployment_Strategy, Traffic_Management
Last Updated 2026-02-13 00:00 GMT

Overview

Concrete Go type field and YAML configuration for controlling canary traffic percentage in KServe InferenceService deployments.

Description

The CanaryTrafficPercent field is defined in ComponentExtensionSpec as an optional *int64. When set, the Knative service reconciler creates two traffic targets: one for the latest revision (canary) and one for the previous revision (stable). The field value specifies the percentage of traffic routed to the canary.

Usage

Set canaryTrafficPercent in the InferenceService spec when updating a model version to enable canary testing. Remove the field (or set it absent) to promote the canary to 100% traffic.

Code Reference

Source Location

  • Repository: kserve
  • File: pkg/apis/serving/v1beta1/component.go, Line 114 (type definition)
  • File: pkg/controller/v1beta1/inferenceservice/reconcilers/knative/ksvc_reconciler.go, Lines 132-164 (traffic target construction)

Signature

// ComponentExtensionSpec defines the deployment configuration for a component
type ComponentExtensionSpec struct {
    // CanaryTrafficPercent defines the traffic split percentage between
    // the candidate revision and the last ready revision
    CanaryTrafficPercent *int64 `json:"canaryTrafficPercent,omitempty"`
    // ... other fields
}

Import

import servingv1beta1 "github.com/kserve/kserve/pkg/apis/serving/v1beta1"

I/O Contract

Inputs

Name Type Required Description
canaryTrafficPercent *int64 No Percentage of traffic to canary revision (0-100)
storageUri string Yes New model version URI (triggers new revision)

Outputs

Name Type Description
Knative Traffic Targets []TrafficTarget Two targets: stable (100-P%) and canary (P%)
Revisions Knative Revision New revision created for updated storageUri

Usage Examples

Apply Canary Split (10%)

apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: my-model
spec:
  predictor:
    canaryTrafficPercent: 10
    tensorflow:
      storageUri: "gs://kfserving-examples/models/tensorflow/flowers-2"

Increase to 50%

apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: my-model
spec:
  predictor:
    canaryTrafficPercent: 50
    tensorflow:
      storageUri: "gs://kfserving-examples/models/tensorflow/flowers-2"

Promote (Remove Canary)

apiVersion: serving.kserve.io/v1beta1
kind: InferenceService
metadata:
  name: my-model
spec:
  predictor:
    tensorflow:
      storageUri: "gs://kfserving-examples/models/tensorflow/flowers-2"
# No canaryTrafficPercent → 100% to latest

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment