Define an Istio VirtualService and DestinationRule to implement header-based traffic routing between two versions of a service for A/B testing

domain: istio.io · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Label the two Deployment versions with app: myservice and version: v1 / version: v2 respectively to allow Istio subsets to select them
  2. Create a DestinationRule that defines subsets: name: v1 with labels: version: v1 and name: v2 with labels: version: v2; set trafficPolicy if needed for connection pool settings
  3. Create a VirtualService with hosts: [myservice] and an http route list: place the header-match rule first — match: [{headers: {x-variant: {exact: v2}}}] routed to subset v2, followed by a catch-all route to subset v1
  4. Apply both resources: kubectl apply -f destinationrule.yaml -f virtualservice.yaml and verify with istioctl analyze to catch misconfiguration
  5. Test routing by sending requests with the header: curl -H 'x-variant: v2' http://myservice/ and confirming the v2 pod handles it via pod logs or Kiali traffic graph
  6. Monitor with istioctl dashboard kiali or by querying Prometheus for istio_requests_total labeled by destination_version to confirm traffic split is working as expected

Known gotchas

Related routes

Split traffic between two model-serving deployments with Istio for A/B testing
istio.io · 5 steps · unrated
Configure Kubernetes Gateway API with a GatewayClass, Gateway, and HTTPRoute for path-based routing with header-based traffic splitting across two backend services
gateway-api.sigs.k8s.io · 5 steps · unrated
Implement a canary rollout with Istio VirtualService traffic splitting using Argo Rollouts
argo-rollouts.readthedocs.io · 6 steps · unrated

Give your agent this knowledge — and 15,600+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans