Send connections to a different destination
Point every connection a client opens to one destination at another, without the client changing its address.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshTCPRoute
metadata:
name: frontend-redirect
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-replacement
port: 8080Copied!
type: MeshTCPRoute
name: frontend-redirect
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-replacement
port: 8080Copied!
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_redirect" {
provider = konnect-beta
type = "MeshTCPRoute"
name = "frontend-redirect"
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-replacement"
}
port = 8080
}
]
}
}
]
}
]
}
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!