Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Kserve Kserve Tag Based Routing Validation

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

Overview

Concrete curl-based testing pattern using KServe tag-based routing to validate canary model revisions deterministically.

Description

When tag-based routing is enabled via the annotation serving.kserve.io/enable-tag-routing: "true", the Knative service reconciler creates tagged traffic targets (see ksvc_reconciler.go:L139-141). This generates tagged URLs that route exclusively to specific revisions, enabling deterministic validation of the canary.

Usage

Use this after applying a canary traffic split. Send test requests to the latest- prefixed URL to test the canary in isolation, and to the prev- prefixed URL to test the stable version.

Code Reference

Source Location

  • Repository: kserve
  • File: docs/samples/v1beta1/rollout/README.md, Lines 76-80
  • File: docs/samples/v1beta1/rollout/input.json, Lines 1-10
  • File: pkg/controller/v1beta1/inferenceservice/reconcilers/knative/ksvc_reconciler.go, Lines 139-141 (tag creation)

Signature

# Tag-based routing endpoints
curl -v -H "Host: latest-${MODEL_NAME}.${NAMESPACE}.example.com" \
  http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/${MODEL_NAME}:predict \
  -d @input.json

curl -v -H "Host: prev-${MODEL_NAME}.${NAMESPACE}.example.com" \
  http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/${MODEL_NAME}:predict \
  -d @input.json

Import

# No import needed — uses curl and kubectl

I/O Contract

Inputs

Name Type Required Description
INGRESS_HOST string Yes Ingress gateway IP address
INGRESS_PORT int Yes Ingress gateway port
MODEL_NAME string Yes InferenceService name
input.json JSON file Yes Test prediction data

Outputs

Name Type Description
Canary prediction JSON Response from canary revision only
Stable prediction JSON Response from stable revision only

Usage Examples

Validate Canary Revision

# Setup
INGRESS_HOST=$(kubectl -n istio-system get svc istio-ingressgateway \
  -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
INGRESS_PORT=80
MODEL_NAME="my-model"

# Test canary (latest tag)
echo "Testing canary revision:"
curl -s -H "Host: latest-${MODEL_NAME}.default.example.com" \
  http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/${MODEL_NAME}:predict \
  -d '{"instances": [[6.8, 2.8, 4.8, 1.4]]}'

# Test stable (prev tag)
echo "Testing stable revision:"
curl -s -H "Host: prev-${MODEL_NAME}.default.example.com" \
  http://${INGRESS_HOST}:${INGRESS_PORT}/v1/models/${MODEL_NAME}:predict \
  -d '{"instances": [[6.8, 2.8, 4.8, 1.4]]}'

# Compare responses to validate canary

Related Pages

Implements Principle

Page Connections

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