Skip to main content
Version: 0.9.x

Service Route

Service Routes can be used by service owners to configure traffic shifting across different versions of a service in a traffic group. Traffic to this service can originate from sidecars in same or different traffic groups as well as gateways.

The following example creates a traffic group for the sidecars in ns1, ns2 and ns3 namespaces owned by its parent workspace w1 under tenant mycompany and defines a service route for the reviews service in ns1 namespace with two subsets v1 and v2. 80% of the traffic to the reviews service is sent to v1 while the remaining 20% is sent to v2.

apiVersion: traffic.tsb.tetrate.io/v2
kind: Group
metadata:
name: t1
workspace: w1
tenant: mycompany
organization: myorg
spec:
namespaceSelectors:
- name: "*/ns1"
- name: "*/ns2"
- name: "*/ns3"
configMode: BRIDGED

And the service route for reviews.com service in ns1 namespace

apiVersion: traffic.tsb.tetrate.io/v2
kind: ServiceRoute
metadata:
name: reviews
group: t1
workspace: w1
tenant: mycompany
organization: myorg
spec:
service: ns1/reviews.com
subsets:
- name: v1
labels:
version: v1
weight: 80
- name: v2
labels:
version: v2
weight: 20

ServiceRoute

A service route controls routing configurations for traffic to a service in a traffic group.

FieldDescriptionValidation Rule

service

string
REQUIRED
The service on which the configuration is being applied. Must be in namespace/FQDN format.

string = {
  pattern: ^[^/]+/[^/]+$
}

subsets

List of tetrateio.api.tsb.traffic.v2.ServiceRoute.Subset
REQUIRED
The set of versions of a service and the percentage of traffic to send to each version.

repeated = {
  min_items: 1
}

stickySession

tetrateio.api.tsb.traffic.v2.ServiceRoute.StickySession
StickySession specifies how to forward traffic from a client to the same backend

StickySession

If set, all requests from a client will be forward to the same backend.

FieldDescriptionValidation Rule

header

string
Hash based on a specific HTTP header.

string = {
  min_len: 1
}

cookie

tetrateio.api.tsb.traffic.v2.ServiceRoute.StickySession.HTTPCookie
Hash based on HTTP cookie.

useSourceIp

bool
Hash based on the source IP address.

HTTPCookie

Describes a HTTP cookie that will be used for sticky sessions. If the cookie is not present, it will be generated.

FieldDescriptionValidation Rule

name

string
REQUIRED
Name of the cookie.

string = {
  min_len: 1
}

path

string
REQUIRED
Path to set for the cookie.

string = {
  min_len: 1
}

ttl

google.protobuf.Duration
REQUIRED
Lifetime of the cookie.

timestamp = {
  required: true
}

Subset

Subset denotes a specific version of a service. The pods/VMs of a subset should be uniquely identifiable using their labels.

FieldDescriptionValidation Rule

name

string
REQUIRED
Name used to refer to the subset.

string = {
  min_len: 1
}

labels

map<string, string>
Labels apply a filter over the endpoints of a service in the service registry.

weight

uint32
Percentage of traffic to be sent to this subset. Weight if not specified will be assumed to be 0 if there are multiple subsets. If there is only one subset, the weight will be assumed to be 1. The sum of non-zero weights across all subsets should add up to 100.