The MeshFaultInjection policy makes a destination proxy reject HTTP requests, delay them,
or slow down their responses. Use this policy to test how callers handle failures without
changing the destination application. For example, check that:
A caller’s MeshRetry rules fire on the statuses you expect.
Its MeshTimeout values are shorter than an injected delay.
MeshCircuitBreaker outlier detection ejects endpoints
that return repeated errors.
Requests that no fault-injection rule matches get no faults. The policy doesn’t simulate a
process crash or a network outage, so the destination proxy must still be running and
receiving the test traffic.
Faults affect real requests. Start with a test destination or a specific caller, record
normal behavior before applying the policy, and remove the experiment when the test ends.
A rule without a client match affects every caller of the selected destination.
To apply the policy to one inbound, set the policy’s spec.targetRef.sectionName to the
inbound’s name from the destination Dataplane’s spec.networking.inbound[], or to its port as
a string if it doesn’t have a name. Without sectionName, the policy covers all eligible inbounds. Zone-proxy
listeners can also use rules with sectionName set to the listener name.
Faults require an HTTP, HTTP/2, or gRPC listener. They have no effect on traffic handled as
plain TCP, even if the application sends HTTP over it. For more information, see
Universal inbound protocols.
A rule holds a list of faults under http, and each entry can set any combination of
abort, delay, and responseBandwidth. Every fault takes a percentage from 0.0 to
100.0. You must wrap fractional values in quotes, for example: "2.5".
http accepts the following faults:
Fault
Effect
Fields
abort
The proxy answers with the given status and doesn’t deliver the request.
httpStatus (100 to 599) and percentage.
delay
The proxy waits before forwarding the request, on top of the application’s processing time.
value (a duration with a unit, such as 500ms, 5s, or 1m30s) and percentage.
responseBandwidth
The proxy limits the transfer rate of each selected response, not the destination’s total bandwidth.
limit (a whole number in Gbps, Mbps, or kbps, such as 50kbps) and percentage.
Entries in one http list run in order. An abort stops the request, so later entries only
see requests that weren’t aborted. A delay doesn’t stop the request, so it can still hit a
later delay or abort.
The following example aborts about 85% of requests, when placed under rules[].default:
About 70% of requests get a 500. Half of the remaining 30% get a 503, which is about 15% of
all requests. The other 15% reach the application. Moving a fault to the front of the list
changes how many requests the later ones see.
A rule that matches spiffeID injects faults only for requests from those clients, so other
callers of a shared destination aren’t affected. The following example delays half of the
requests from the frontend service account by 5 seconds:
Copy the full SPIFFE URI from the frontend workload’s certificate into
rules[].matches[].spiffeID.value. The example uses the default Kubernetes identity path. A
custom MeshIdentity template can change the trust domain and
path. Several frontend replicas can share this service-account identity, so the match doesn’t
select a single process.
The destination must authenticate the identity through mesh mTLS, because plaintext traffic
has no identity to match. The rule doesn’t grant access:
MeshTrafficPermission must also allow the caller.
Matching rules add their faults together. A narrower rule doesn’t replace a broader rule’s
faults. For example, if one rule delays all callers and another aborts requests from
frontend, frontend requests are eligible for both. A request that’s aborted doesn’t reach
the faults after it.
Setting a fault’s percentage to 0 disables only that fault, not faults in other matching
rules or policies. To stop an experiment for a caller, remove or narrow every rule that
includes it. To attribute a result to one fault, don’t overlap experiments.
Before applying the policy, confirm that the caller can reach the destination, record the
normal status and latency, and check for other fault-injection policies on the same traffic.
Send enough requests to observe the configured percentage. Count attempts at the destination
proxy, not only completed calls, because client retries can hide injected failures.
For abort, confirm that the client gets the configured status and the application doesn’t
receive those requests.
For delay, confirm that client-observed latency matches delay.value and any applicable
MeshTimeout.
For responseBandwidth, confirm the transfer rate with a response large enough to show the
limit.
If a rule matches spiffeID, confirm that a client that doesn’t match gets no fault from it.
Remove the test policy and confirm that the baseline requests succeed again. If faults
remain, check for another matching policy.
To tell injected faults from application errors, inspect the destination proxy’s Envoy
counters ending in: