Demo of Istio DestinationRule and VirtualService showing subset definitions and weighted traffic splits with configuration examples, commands, and tips for traffic policies and routing
Use this file to discover all available pages before exploring further.
DestinationRule resources in Istio define endpoint groups (subsets) and per-destination traffic policies (load balancing, connection pools, outlier detection, TLS, etc.). When paired with a VirtualService, DestinationRules enable advanced traffic routing scenarios such as weighted traffic splits between versions of an application.
Both the client and server namespaces must have Istio sidecar injection enabled for Istio routing to work across namespaces. Use istioctl analyze -n <namespace> to confirm.
This demo walks through a common scenario: splitting traffic between two versions of a HelloWorld service using a DestinationRule to define subsets and a VirtualService to split traffic by weight.
Run these commands to confirm cluster state and Istio injection:
# List namespaces and labels (look for istio-injection=enabled)kubectl get ns --show-labels# Confirm Istio resources and analyze a namespaceistioctl analyze -n defaultistioctl analyze -n test
If a namespace needs injection enabled:
kubectl create ns test # if not presentkubectl label namespace test istio-injection=enabled
Verify the HelloWorld sample is deployed in the default namespace and that pods have sidecars (Ready should be 2/2):
kubectl get pods -n default --show-labelskubectl get svc -n default --show-labels
Create a simple test client pod in the test namespace for curl-based tests:
kubectl run -n test test --image=nginx --restart=Never --command -- sleep 1dkubectl get pods -n test
Exec into the test pod for manual testing:
kubectl exec -ti -n test test -- /bin/bash
Inside the test pod, verify the service responds on port 5000 at /hello:
Without a VirtualService, Kubernetes service load balancing determines which pod receives traffic. The following steps add a DestinationRule (to create subsets) and a VirtualService (to control traffic split).
kubectl apply -f vs.yamlkubectl get virtualservices.networking.istio.io -n default# Example output:# NAME GATEWAYS HOSTS AGE# hello-world-vs [] ["helloworld"] 5s
Test from the test pod with multiple requests:
kubectl exec -ti -n test test -- /bin/bash# inside pod:for i in {1..6}; do curl -sS helloworld.default.svc:5000/hello; echo; done# Expect approximately half v1 and half v2 responses
Ensure the VirtualService destination port matches the application’s listening port (5000 in this demo). A mismatched port (for example, using 80) will prevent traffic from reaching the application.
To change the split, update the weight values in vs.yaml. Example: send 95% to v1 and 5% to v2:
# Update the 'weight' fields in vs.yaml route entries# weight: 95 for subset v1# weight: 5 for subset v2
Apply the modified VirtualService:
kubectl apply -f vs.yaml
Test again from the client pod:
kubectl exec -ti -n test test -- /bin/bash# inside pod:for i in {1..20}; do curl -sS helloworld.default.svc:5000/hello; echo; done# Expect mostly v1 responses (~95%) with occasional v2
This concludes the DestinationRule demo. Try creating DestinationRules and VirtualServices in a lab environment and experiment with different traffic-splitting and policy combinations.