Skip to main content
In this tutorial, we will create new subsets using Destination Rules and route traffic to grouped service endpoints. You will learn how to update your Istio configuration with custom labels, modify the Virtual Services, and manage traffic distribution between different versions of the reviews service.

Overview

Initially, the reviews service has three subsets defined by version labels: V1, V2, and V3. The corresponding Virtual Service configuration routes traffic based on these subsets. However, there may be scenarios when you need to group different deployments under a new rule or label. In our example, we introduce a new label (test: beta) to group deployments and update the existing configurations accordingly.
Ensure that any changes to labels also reflect in the corresponding Destination Rule and Virtual Service configurations to avoid routing mismatches.

Updating the Reviews Service

First, we add the new label to our application. The new label (test: beta) allows us to create additional subsets without affecting the initial routing for Version V1. In this example, we copy reviews.yml from the samples directory and proceed to update it.

Step 1: Open the File

Use your terminal to open the reviews.yml file:

Step 2: Add the New Label

For the reviews service, add the label test: beta and ensure Version V1 is skipped for the new grouping:
After updating the reviews service, add the same label to the Version V2 and Version V3 deployments. For instance, the deployment for Version V3 with the updated label is as follows:

Step 3: Apply Changes

After modifying the YAML file, delete the existing configuration and reapply the updated changes:
The image shows a Kiali Console interface displaying a list of workloads in the "default" namespace, each labeled with its name, type, and version. The sidebar includes options like Overview, Graph, Applications, Workloads, Services, and Istio Config.
Notice that the new test: beta label appears only in Version V2 and Version V3, while Version V1 remains unchanged. In the Applications page, you can now observe the service reflecting the new label.

Modifying the Istio Configuration

To leverage the new grouping label, update the Istio configuration by modifying both the Destination Rule and the Virtual Service.

Updating the Destination Rule

The original Destination Rule for the reviews service defines subsets for V1, V2, and V3. Here is the original configuration:
Update the configuration to incorporate the new grouping label by preserving the V1 subset and adding a new subset for test: beta:
This change allows you to test different versions of the application. You can even enable customers to choose their preferred version.

Updating the Virtual Service

When you update the Virtual Service, the subset references must match the updated Destination Rule. The original Virtual Service configuration is as follows:
To eliminate warnings on Kiali regarding mismatched subsets, update the Virtual Service to use only the V1 subset along with the new test-beta subset:

Managing Traffic Distribution

Now that the configurations have been updated, you can control the percentage of traffic routed to each subset. For a scenario where the new subset receives only 10% of the traffic, use this configuration:
After testing, you might observe that Reviews V1 handles most of the traffic while the new subset appears less frequently. To experiment with dynamic traffic distribution, adjust the weights—for example, giving V1 and the test subset equal distribution:

Updating the Destination Rule’s Traffic Policy

Next, update the Destination Rule to include a traffic policy for the new test subset. Specify the label for the test group and apply a random load balancing strategy:
With this configuration, Reviews V2 and V3 are randomly selected based on the load balancing strategy.

Reverting to Round-Robin Load Balancing

If you need to revert to a round-robin load balancing policy, remove the subsets from the Virtual Service and update the Destination Rule accordingly:

Destination Rule Update

Virtual Service Update

With these modifications, the reviews service will now utilize a round-robin strategy, cycling through available endpoints.

Conclusion

By leveraging Destination Rules and Virtual Services, Istio provides a powerful mechanism to manage and control traffic routing in your microservices architecture. This tutorial demonstrated how to add a new grouping label, update the relevant configurations, and control traffic distribution between different versions of the reviews service. With these techniques, you can enhance your service mesh architecture and experiment with advanced traffic management strategies. For additional details on Istio and traffic management strategies, refer to the Istio Documentation.

Watch Video

Practice Lab