Inject faults for a single client
Match on the caller SPIFFE ID so a list of faults applies only to requests from frontend, leaving other callers of the same destination unaffected.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshFaultInjection
metadata:
name: backend-faults-from-frontend
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/frontend
default:
http:
- abort:
httpStatus: 500
percentage: '2.5'
- delay:
value: 5s
percentage: 5Copied!
type: MeshFaultInjection
name: backend-faults-from-frontend
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/frontend
default:
http:
- abort:
httpStatus: 500
percentage: '2.5'
- delay:
value: 5s
percentage: 5Copied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_fault_injection" "backend_faults_from_frontend" {
provider = konnect-beta
type = "MeshFaultInjection"
name = "backend-faults-from-frontend"
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/frontend"
}
}
]
default = {
http = [
{
abort = {
http_status = 500
percentage = { str = "2.5" }
}
},
{
delay = {
value = "5s"
percentage = { integer = 5 }
}
}
]
}
}
]
}
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!