Skip to main content
In this lesson you’ll apply two Istio fault-injection scenarios to a simple helloworld app: a fixed delay and an abort (HTTP error). The walkthrough shows how to deploy the sample app, run tests from a pod, and apply VirtualService configurations to observe Envoy-injected faults. Keywords: Istio fault injection, VirtualService, Envoy fault filter, delay, abort, helloworld sample Prerequisites:
  • A Kubernetes cluster with Istio installed and sidecar injection enabled for your namespace.
  • kubectl configured to talk to the cluster.
  1. Verify the namespace has Istio sidecar injection enabled
Example output:
  1. Deploy the helloworld sample application
Expected response:
  1. Create a test pod (use an image with curl available)
Example pod list:
  1. Confirm the helloworld service
Example output:
  1. Smoke test the application from the test pod
Sample responses (the service load-balances between v1 and v2):
At this point the app is functioning normally. Circuit-breaking and connection-level controls are configured in DestinationRule resources (if present) — these are separate from VirtualService fault injection.
  1. Verify there are no existing VirtualServices or DestinationRules in the namespace
Quick reference: common fault types
Do not apply fault injections in production clusters or against production services unless you have explicit permission and proper safeguards. Fault injection will deliberately break or delay traffic.
  1. Inject a fixed 5s delay for 100% of traffic
Save the following VirtualService as vs-delay.yaml:
Apply and verify:
Example output:
Test the injected delay:
Expected behavior: every request to helloworld:5000 is delayed by approximately 5 seconds.
  1. Change the fault to an abort (inject HTTP error responses)
Save this VirtualService as vs-abort-500.yaml to abort 100% of requests with HTTP 500:
Apply and test:
You will see an Envoy fault filter message similar to:
To see the injected status code in the HTTP response headers:
Example headers:
Tip: Change httpStatus to 404, 503, etc., to simulate different server responses.
  1. Inject a 50% abort (random failures)
Save this VirtualService (e.g. vs-abort-50.yaml) to abort 50% of requests with HTTP 404:
Apply and run multiple requests to observe the distribution:
Expected result: roughly half of the responses return HTTP/1.1 200 OK and half HTTP/1.1 404 Not Found (randomness and sample size affect exact counts). The same pattern can be used for percentage-based delays.
  1. Conditional fault injection (by header match)
You can scope faults to requests that match particular conditions (for example, a specific header). The Istio docs show an example where a 7s delay is injected only for requests with the end-user header equal to jason:
This injects a 7s delay only for requests where end-user: jason is present.
Fault injection in Istio is configured on VirtualService resources. Circuit-breaking and connection-level controls belong in DestinationRule resources — make sure to use the correct resource for each purpose.
  1. References and next steps

Watch Video

Practice Lab