Istio Service Mesh

Traffic Management

Fault Injection

Fault injection is a testing strategy designed to simulate errors and validate the resilience of your error handling mechanisms. In this guide, we explain how to simulate faults in your Virtual Services to ensure that your application gracefully handles failures.

Important

Before proceeding, make sure you have successfully deployed your application, configured a Gateway, and set up the product page and reviews Virtual Services. All components should be functioning as expected.

Fault injection in Istio supports the simulation of two primary error types in Virtual Services:

  • Delays
  • Aborts

Simulating Delay Faults

The following example demonstrates how to inject a delay fault into a Virtual Service. In this configuration, a delay of 5 seconds is applied to 10% of the requests routed to the service.

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: my-service
spec:
  hosts:
  - my-service
  http:
  - fault:
      delay:
        percentage:
          value: 0.1
        fixedDelay: 5s
    route:
    - destination:
        host: my-service
        subset: v1

In the above YAML, the delay fault for the Virtual Service named "my-service" causes a fixed delay of 5 seconds on 10% of the incoming requests. This helps you validate that your system's timeout and retry mechanisms are working correctly.

Simulating Abort Faults

In addition to delay faults, you can configure abort faults to simulate scenarios where requests are rejected with specific error codes. Abort faults help test how your service behaves under error conditions, ensuring that fallback mechanisms and error handling policies are effective.

For detailed instructions and additional configuration options for abort faults, refer to the Istio Fault Injection Documentation.

By incorporating both delay and abort fault injections, you can thoroughly assess the robustness of your application and ensure that it remains resilient even under adverse conditions.

For further reading, consider exploring these resources:

Watch Video

Watch video content

Previous
Demo Destination Rules