Split connections between two destinations
Weight two backendRefs 90 to 10 so a tenth of client connections reach a second destination.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshTCPRoute
metadata:
name: frontend-to-backend
namespace: kong-mesh-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
rules:
- default:
backendRefs:
- kind: MeshService
labels:
kuma.io/display-name: backend
port: 8080
weight: 90
- kind: MeshService
labels:
kuma.io/display-name: backend-next
port: 8080
weight: 10Copied!
type: MeshTCPRoute
name: frontend-to-backend
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
rules:
- default:
backendRefs:
- kind: MeshService
labels:
kuma.io/display-name: backend
port: 8080
weight: 90
- kind: MeshService
labels:
kuma.io/display-name: backend-next
port: 8080
weight: 10Copied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_tcp_route" "frontend_to_backend" {
provider = konnect-beta
type = "MeshTCPRoute"
name = "frontend-to-backend"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "frontend"
}
}
to = [
{
target_ref = {
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend"
}
}
rules = [
{
default = {
backend_refs = [
{
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend"
}
port = 8080
weight = 90
},
{
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend-next"
}
port = 8080
weight = 10
}
]
}
}
]
}
]
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}
Copied!