Give one workload identity a separate limit
Give requests from the batch identity a separate ten-per-second bucket on each destination proxy. Other callers share a thousand-per-second bucket. Replace the example SPIFFE ID with the complete URI from the batch workload certificate.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshRateLimit
metadata:
name: backend-limit-batch-client
namespace: kong-mesh-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: backend
rules:
- matches:
- spiffeID:
type: Exact
value: spiffe://default.default.mesh.local/ns/kong-mesh-demo/sa/batch
default:
local:
http:
requestRate:
num: 10
interval: 1s
- default:
local:
http:
requestRate:
num: 1000
interval: 1sCopied!
type: MeshRateLimit
name: backend-limit-batch-client
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: backend
rules:
- matches:
- spiffeID:
type: Exact
value: spiffe://default.default.mesh.local/ns/kong-mesh-demo/sa/batch
default:
local:
http:
requestRate:
num: 10
interval: 1s
- default:
local:
http:
requestRate:
num: 1000
interval: 1sCopied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_rate_limit" "backend_limit_batch_client" {
provider = konnect-beta
type = "MeshRateLimit"
name = "backend-limit-batch-client"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "backend"
}
}
rules = [
{
matches = [
{
spiffe_id = {
type = "Exact"
value = "spiffe://default.default.mesh.local/ns/kong-mesh-demo/sa/batch"
}
}
]
default = {
local = {
http = {
request_rate = {
num = 10
interval = "1s"
}
}
}
}
},
{
default = {
local = {
http = {
request_rate = {
num = 1000
interval = "1s"
}
}
}
}
}
]
}
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!