Intelligent Routing with Istio on Alibaba Cloud Container Service for Kubernetes

Request Routing

The BookInfo example application deploys three versions of the reviews service. Therefore, a default route must be configured.Otherwise, when the application is accessed for multiple times, the displayed review content sometimes contains the rating information, and sometimes does not contain the rating information.This symptom occurs because when no default route is explicitly specified for the application, Istio routes the requests to all available versions of the reviews service at random.

Set the Default Version of All Microservices to v1

Run the following command to set the default version of all microservices to v1:

istioctl create -f samples/bookinfo/routing/route-rule-all-v1.yaml
istioctl get virtualservices -o yaml

Route Requests from a Specific User to Reviews v2

Run the following command to route requests from the test user “jason” to reviews v2 to enable the ratings service.

kubectl replace -f samples/bookinfo/routing/route-rule-reviews-test-v2.yaml
kubectl  get virtualservice reviews -o yaml
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
clusterName: ""
creationTimestamp: 2018-06-04T10:49:53Z
generation: 0
name: reviews
namespace: default
resourceVersion: "2596548"
selfLink: /apis/networking.istio.io/v1alpha3/namespaces/default/virtualservices/reviews
uid: 03528fd9-67e5-11e8-af82-00163e0c19c2
spec:
hosts:
- reviews
http:
- match:
- headers:
cookie:
regex: ^(.*?;)?(user=jason)(;.*)?$
route:
- destination:
host: reviews
subset: v2
- route:
- destination:
host: reviews
subset: v1

Fault Injection

To test the resiliency of the Bookinfo application, inject a 7s delay between the reviews v2 and ratings microservices for user “jason”.As the reviews v2 service sets a 10s timeout for calls to the ratings service, it is expected that the end-to-end flow can continue without any errors.

HTTP Delay

Use HTTP Delay to create a fault injection rule to delay the traffic coming from user “jason”:

kubectl replace -f samples/bookinfo/routing/route-rule-ratings-test-delay.yaml

HTTP Abort

Similarly, use HTTP Abort to create a fault injection rule:

kubectl replace -f samples/bookinfo/routing/route-rule-ratings-test-abort.yaml

Traffic Shifting

In addition to content-based routing, Istio also supports the weight-based routing rule.

kubectl replace -f samples/bookinfo/routing/route-rule-all-v1.yaml
kubectl replace -f samples/bookinfo/routing/route-rule-reviews-50-v3.yaml

Summary

We can use Alibaba Cloud Container Service for Kubernetes to quickly build an Istio open platform for connecting, managing, and securing microservices, and to introduce and configure multiple relevant services for applications.Based on the official example, this article explains how to use Istio functions, such as traffic routing, fault injection, rate limiting, and traffic shifting.You are welcome to use Alibaba Cloud Container Service for Kubernetes to quickly build an Istio open platform and integrate Istio to microservice development in your project.

  1. Using Istio on Alibaba Cloud Container Service for Kubernetes
  2. Go through Istio Features with Samples on Alibaba Cloud Container Service for Kubernetes
  3. Intelligent Routing with Istio on Alibaba Cloud Container Service for Kubernetes
  4. Distributed Tracking with Istio on Alibaba Cloud Container Service for Kubernetes
  5. Telemetry Data Collection, Query, and Visualization with Istio on Alibaba Cloud Container Service for Kubernetes
  6. Fault Diagnosis and Detection using Istio within Alibaba Cloud Container Service for Kubernetes
  7. Observability Analysis using Istio and Kiali within Alibaba Cloud Container Service for Kubernetes

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alibaba Cloud

Alibaba Cloud

Follow me to keep abreast with the latest technology news, industry insights, and developer trends. Alibaba Cloud website:https://www.alibabacloud.com