Service routes and version subsets should be in place given the destination rules applied in Lab 3. If they are not present, re-apply the destination rules:
1apiVersion: networking.istio.io/v1alpha32kind: DestinationRule3metadata:4 name: productpage5spec:6 host: productpage7 subsets:8 - name: v19 labels:10 version: v111---1213apiVersion: networking.istio.io/v1alpha314kind: DestinationRule15metadata:16name: reviews17spec:18host: reviews19subsets: - name: v120labels:21version: v1 - name: v222labels:23version: v2 - name: v324labels:25version: v32627---2829apiVersion: networking.istio.io/v1alpha330kind: DestinationRule31metadata:32name: ratings33spec:34host: ratings35subsets: - name: v136labels:37version: v1 - name: v238labels:39version: v2 - name: v2-mysql40labels:41version: v2-mysql - name: v2-mysql-vm42labels:43version: v2-mysql-vm4445---4647apiVersion: networking.istio.io/v1alpha348kind: DestinationRule49metadata:50name: details51spec:52host: details53subsets: - name: v154labels:55version: v1 - name: v256labels:57version: v25859---
Start managing traffic routes
Some basics to get us started.
Send all requests to Productpage v1
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v1
Using Meshery, apply custom configuration.
Refresh BookInfo productpage
Send all requests to Productpage v2
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v2
Using Meshery, apply custom configuration.
Refresh BookInfo productpage.
Traffic routing based on user or user-agent type
Redirect requests from mobile devices
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: bookinfo5spec:6 hosts:7 - "bookinfo.meshery.io"8 gateways:9 - sample-app-gateway10 http:11 - match:12 - headers:13 User-Agent:14 regex: ^.*Mobile.*$15 route:16 - headers:17 request:18 set:19 x-response: "Success with Mobile"20 destination:21 host: productpage22 port:23 number: 908024 - route:25 - destination:26 host: product27 subset: random
Set your browser to mimic a mobile device. Enable Developer tools, if need. Refresh BookInfo productpage.
Redirect requests based on HTTP header information
Example of using user information from HTTP headers to redirect requests.
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - match:10 - headers:11 end-user:12 exact: naruto13 route:14 - destination:15 host: reviews16 subset: v217 - match:18 - headers:19 end-user:20 exact: sasuke21 route:22 - destination:23 host: reviews24 subset: v325 - route:26 - destination:27 host: reviews28 subset: v1
Traffic Mirroring with Istio
You will need to generate load on BookInfo's productpage service. See Lab 4 for instructions for running a performance test.
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v113 weight: 10014 mirror:15 host: reviews16 subset: v217 mirror_percent: 100
Incrementally increase the traffic split percentage to the higher version service #. Start at 20% traffic split
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v113 weight: 8014 - destination:15 host: reviews16 subset: v317 weight: 20
Move to 50%. Observe in Meshery.
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v113 weight: 5014 - destination:15 host: reviews16 subset: v317 weight: 50
Injecting Latency
Acknowledging the fallacy that the network is always reliable, you will intentionally cause a little chaos.
Exploring timeouts with Reviews service
Note Istio Proxy's default timeout settings.
12---3apiVersion: networking.istio.io/v1alpha34kind: VirtualService5metadata:6 name: reviews7spec:8 hosts:9 - reviews10 http:11 - match:12 - headers:13 end-user:14 exact: naruto15 fault:16 delay:17 percentage:18 value: 100.019 fixedDelay: 11s20 route:21 - destination:22 host: reviews23 subset: v124 - route:25 - destination:26 host: reviews27 subset: v2
Exploring timeouts with Ratings service
12---3apiVersion: networking.istio.io/v1alpha34kind: VirtualService5metadata:6 name: ratings7spec:8 hosts:9 - ratings10 http:11 - match:12 - headers:13 end-user:14 exact: naruto15 fault:16 delay:17 percentage:18 value: 100.019 fixedDelay: 5s20 route:21 - destination:22 host: ratings23 subset: v124 - route:25 - destination:26 host: ratings27 subset: v1
Retries
Overcoming the latency issue.
Set 5 retry attempts and a 3 second timeout
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v113 retries:14 attempts: 515 perTryTimeout: 3s
Follow these steps if the above steps did not work
If you haven't forked or cloned this repository, please do so now:
git clone https://github.com/layer5io/advanced-istio-service-mesh-workshop
Route all traffic to version V1
kubectl apply -f route-v1-v2/v1.yaml
Route all traffic to version V2
kubectl apply -f route-v1-v2/v2.yaml
Traffic routing based on user or user-agent type
kubectl apply -f route-header/device.yaml
kubectl apply -f route-header/user.yaml