Traffic Shifting
Before you get started, make sure you:
✓ Familiarize yourself with TSB concepts
✓ Install the TSB demo environment
✓ Deploy the Istio Bookinfo sample app
✓ Create a Tenant
✓ Create a Workspace
✓ Create Config Groups
✓ Setup an Ingress Gateway
In this scenario, you will use a Service Route to shift traffic from the reviews v1 to reviews v2 service.
If you open https://bookinfo.tetrate.com/productpage, and refresh the page
several times, you will see reviews changes between v1
(no ratings), v2
(black star ratings) and v3
(red star ratings).
In the following scenario, you will start with using reviews v1
, then
partially shift traffic from v1
to v2
, and finally use v2
only.
Serve v1 only
Using the UI
- Under Tenant on the left panel, select Workspaces.
- On the
bookinfo-ws
Workspace card, click on Traffic Groups. - Click on the
bookinfo-traffic
Traffic Group you created previously. - Select the
Traffic Settings
tab.
Now, you are going to add a new Service Route
- Under Traffic Settings, Click on Service Routes.
- Click Add new.... This will create a new Service Route with default name
fqn0
. - Click
fqn0
to open its configuration form, and rename tobookinfo-traffic-reviews
. - Set Service to
bookinfo/reviews.bookinfo.svc.cluster.local
. - Click on Subsets, then Add new Subset.... This will create a new
Subset called
subset-0
. - Click on
subset-0
.- Set name to
v1
. - Leave weight empty (this will default to 100). Weight is Percentage of traffic to be sent to this subset.
- Click on Add Label, and set Label to
version
and Value tov1
.
- Set name to
- Save Changes.
Using tctl
Create the following reviews.yaml
apiVersion: traffic.tsb.tetrate.io/v2
kind: ServiceRoute
Metadata:
organization: tetrate
name: bookinfo-traffic-reviews
group: bookinfo-traffic
workspace: bookinfo-ws
tenant: tetrate
spec:
service: bookinfo/reviews.bookinfo.svc.cluster.local
subsets:
- name: v1
labels:
version: v1
Apply with tctl
tctl apply -f reviews.yaml
Verify result
Now, open https://bookinfo.tetrate.com/productpage. Refresh the page several times. You will see reviews only shows v1 version (no stars).
Split traffic between v1 and v2
Using the UI
Now, split traffic evenly between v1
and v2
by updating the
bookinfo-traffic-reviews
Service Route.
- Select the
v1
subset of your Service Route again. - Enter
50
as Weight. - Just below v1, click on Add new Subset.... This will create a new Subset
called
subset-1
. - Click on
subset-1
.- Set name to
v2
. - Enter
50
as Weight. - Click on Add Label, and set Label to
version
and Value tov2
.
- Set name to
- Save Changes.
Using tctl
Now, split traffic evenly between v1
and v2
by updating reviews.yaml
apiVersion: traffic.tsb.tetrate.io/v2
kind: ServiceRoute
Metadata:
organization: tetrate
name: bookinfo-traffic-reviews
group: bookinfo-traffic
workspace: bookinfo-ws
tenant: tetrate
spec:
service: bookinfo/reviews.bookinfo.svc.cluster.local
subsets:
- name: v1
labels:
version: v1
weight: 50
- name: v2
labels:
version: v2
weight: 50
Re-apply with tctl
tctl apply -f reviews.yaml
Verify result
Go to https://bookinfo.tetrate.com/productpage again. Refresh the page several
times. You will see reviews switch between v1
(no ratings) and v2 (black star
ratings) versions.
Serve v2 only
Using the UI
Finally, route 100% traffic to the v2
by updating the
bookinfo-traffic-reviews
Service Route.
- Select the
v1
subset of your Service Route. - Click Delete v1.
- Select the
v2
subset of your Service Route. - Remove the value from
Weight
. - Save Changes.
Using tctl
Finally, route 100% traffic to the v2
version by updating reviews.yaml
apiVersion: traffic.tsb.tetrate.io/v2
kind: ServiceRoute
Metadata:
organization: tetrate
name: bookinfo-traffic-reviews
group: bookinfo-traffic
workspace: bookinfo-ws
tenant: tetrate
spec:
service: bookinfo/reviews.bookinfo.svc.cluster.local
subsets:
- name: v2
labels:
version: v2
Re-apply again with tctl
tctl apply -f reviews.yaml
Verify result
Go to https://bookinfo.tetrate.com/productpage again. Refresh the page several times. You will see reviews only showing the v2 version (black star ratings).