Route connections to an external service
Send TCP connections bound for a destination to a MeshExternalService, so a dependency can be moved outside the mesh without changing the client.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshTCPRoute
metadata:
name: frontend-to-external
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: MeshExternalService
labels:
kuma.io/display-name: external-backendCopied!
type: MeshTCPRoute
name: frontend-to-external
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
rules:
- default:
backendRefs:
- kind: MeshExternalService
labels:
kuma.io/display-name: external-backendCopied!
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_external" {
provider = konnect-beta
type = "MeshTCPRoute"
name = "frontend-to-external"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "frontend"
}
}
to = [
{
target_ref = {
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend"
}
}
rules = [
{
default = {
backend_refs = [
{
kind = "MeshExternalService"
labels = {
"kuma.io/display-name" = "external-backend"
}
}
]
}
}
]
}
]
}
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!