Cap connections to a destination
Use MeshCircuitBreaker connectionLimits so a caller cannot open unbounded connections or queue unbounded requests against one destination.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshCircuitBreaker
metadata:
name: web-to-backend
namespace: kong-mesh-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: web
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
default:
connectionLimits:
maxConnections: 2
maxPendingRequests: 8
maxRequests: 2
maxRetries: 2Copied!
type: MeshCircuitBreaker
name: web-to-backend
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: web
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
default:
connectionLimits:
maxConnections: 2
maxPendingRequests: 8
maxRequests: 2
maxRetries: 2Copied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_circuit_breaker" "web_to_backend" {
provider = konnect-beta
type = "MeshCircuitBreaker"
name = "web-to-backend"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "web"
}
}
to = [
{
target_ref = {
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend"
}
}
default = {
connection_limits = {
max_connections = 2
max_pending_requests = 8
max_requests = 2
max_retries = 2
}
}
}
]
}
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!