Before we start playing with Istio's traffic management capabilities, we need to define the available versions of the deployed services. In Istio parlance, versions are called subsets. Subsets are defined in destination rules.
Run the following in the custom yaml section to create default destination rules for the Bookinfo services:
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---
Using Meshery, navigate to the Istio management page:
default
in the Namespace
field.Apply Service Mesh Configuration
card and select Bookinfo subsets
from the list.This will deploy the destination rules for all the Book info services defining their subsets. Verify the destination rules created by using the command below:
1kubectl get destinationrules234kubectl get destinationrules -o yaml
As part of the bookinfo sample app, there are multiple versions of reviews service. When we load the /productpage
in the browser multiple times we have seen the reviews service round robin between v1, v2 or v3. As the first exercise, let us first restrict traffic to just V1 of all the services.
Using Meshery, navigate to the Istio management page:
default
in the Namespace
field.Apply Custom Configuration
card and paste the configuration below.To view the applied rule:
1kubectl get virtualservice
To take a look at a specific one:
1kubectl get virtualservice reviews -o yaml
Please note: In the place of the above command, we can either use kubectl or istioctl.
Config:
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v113---
Now when we reload the /productpage
several times, we will ONLY be viewing the data from v1 of all the services, which means we will not see any ratings (any stars).
Using Meshery, navigate to the Istio management page:
default
in the Namespace
field.Apply Custom Configuration
card and paste the configuration below.This will update the existing virtual service definition for reviews to route all traffic for user jason
to review V2.
In a few, we should be able to verify the virtual service by using the command below:
1kubectl get virtualservice reviews -o yaml
Config:
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - match:10 - headers:11 end-user:12 exact: jason13 route:14 - destination:15 host: reviews16 subset: v217 - route:18 - destination:19 host: reviews20 subset: v121---
Now if we login as your jason
, you will be able to see data from reviews
v2. While if you NOT logged in or logged in as a different user, you will see data from reviews
v1.
To start canary testing, let's begin by transferring 50% of the traffic from reviews:v1 to reviews:v3 with the following command:
Using Meshery, navigate to the Istio management page:
default
in the Namespace
field.Apply Custom Configuration
card and paste the configuration below.This will update the existing virtual service definition for reviews to route 50% of all traffic to review V3.
In a few, we should be able to verify the virtual service by using the command below:
1kubectl get virtualservice reviews -o yaml
Config:
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: 5018---
Now, if we reload the /productpage
in your browser several times, you should now see red-colored star ratings approximately 50% of the time.
When version v3 of the reviews microservice is considered stable, we can route 100% of the traffic to reviews:v3:
Using Meshery, navigate to the Istio management page:
default
in the Namespace
field.Apply Custom Configuration
card and paste the configuration below.This will update the existing virtual service definition for reviews to route 100% of all traffic to review V3.
In a few, we should be able to verify the virtual service by using the command below:
1kubectl get virtualservice reviews -o yaml
Config:
1apiVersion: networking.istio.io/v1alpha32kind: VirtualService3metadata:4 name: reviews5spec:6 hosts:7 - reviews8 http:9 - route:10 - destination:11 host: reviews12 subset: v313---
Now, if we reload the /productpage
in your browser several times, you should now see red-colored star ratings 100% of the time.
Run the following command to create default destination rules for the Bookinfo services:
1kubectl apply -f samples/bookinfo/networking/destination-rule-all-mtls.yaml
1kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml
1kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
1kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-50-v3.yaml
1kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml