In this lesson, you will learn how to shift granular percentages of incoming traffic between distinct service versions using service mesh traffic splitting policies.
While standard Kubernetes Services distribute traffic randomly using round-robin load balancing across all available pods, a service mesh (such as Istio or Linkerd) intercepts this traffic at the proxy level. This allows you to manipulate the routing logic at Layer 7, moving beyond simple pod selection to weighted traffic distribution.
The Mechanics of Weighted Routing
Traffic splitting relies on two primary constructs: a VirtualService (or equivalent mesh resource) and multiple backend Destination targets. By defining weights, you instruct the sidecar proxies to direct a specific percentage of requests to one version of a service (e.g., v1) and the remainder to another (e.g., v2).
Consider this conceptual Istio configuration for splitting traffic 90/10:
spec:
hosts:
- my-service
http:
- route:
- destination:
host: my-service
subset: v1
weight: 90
- destination:
host: my-service
subset: v2
weight: 10
Why This Matters
When you release a new version of your application, you rarely want to cut over all users at once. By configuring these weights, you can perform a "canary release" pattern, exposing only a small segment of your production traffic to the new code. If the 10% of traffic directed to v2 results in elevated error rates or latency, the mesh proxy configuration allows you to instantly revert the weights to 100/0, effectively "draining" the problematic version without needing to redeploy or restart containers.
Because the service mesh manages this traffic outside of the Kubernetes Service object, you gain the ability to perform complex routing decisions based on request headers, cookies, or source IP, while keeping the underlying deployment scale independent of the traffic flow.
Key Takeaway: Traffic splitting transforms your deployment strategy by allowing you to control the blast radius of new code through weighted request distribution rather than binary service switching.