Istio routing to chaos testing

I'm reading traffic management documentation and also use Istio for chaos testing.

I know we can use some headers value to routing traffic for AB testing, but what I would like to know is if I can do the same to return an error in one service or make a delay, as the Istio chaos testing provides.

So I can end up making request with header request-type:chaos, and for those we will apply the chaos testing YAML config, but not for the rest of request.


Solution 1:

The RouteRule (used in the second link you sent) is deprecated and replaced by VirtualService:

VirtualService, DestinationRule, and ServiceEntry replace RouteRule, DestinationPolicy, and EgressRule respectively.

Good instructions on how to configure an HTTP delay fault is presented in this -> Fault Injection documentation.

Example YAML config for your header (request-type:chaos) based on Ingress Gateways and Fault Injection documentations:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
 name: httpbin
spec:
 hosts:
 - "httpbin.example.com"
 gateways:
 - httpbin-gateway
 http:
 - fault:
     delay:
       fixedDelay: 7s
       percent: 100
   match:
   - headers:
       request-type:
         exact: chaos
   route:
   - destination:
       port:
         number: 80
       host: my-echo-service
 - route:
   - destination:
       port:
         number: 80
       host: my-nginx-service