In this chapter, we are going to get our hands on some of the traffic management capabilities of Istio.
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:
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:
Configure the default route for all services to V1
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:
To take a look at a specific one:
Please note: In the place of the above command, we can either use kubectl or istioctl.
Config:
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).
Let's replace our first rules with a new set. Enable the ratings service for a
user jason by routing productpage traffic to reviews v2:
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:
Config:
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:
Config:
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:
Config:
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:
Route all traffic to version V1 of all services
Route all traffic to version V2 of reviews for user Jason
Route 50% of traffic to version V3 of reviews service
Route 100% of traffic to version V3 of reviews service