How do I combine weighted-routing with Fault Injection

I want to implement weight-based routing and then be able to inject a fault within one of the destinations. Is this possible?

Example: I have 2 services with weight based routing of 70-30. For service-1, which receives 70% of the traffic, I want to inject a fault of 503 50% of the time. For service-2, which receives 30% of the traffic is always successful.

Is there a way to configure this in Istio? I have tried several options, but have not been successful in getting the required behavior.

can you post your example configuration?

Here’s an example of the deployment yaml.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: greeter-service
spec:
hosts:
- greeter-service
http:
- route:
- destination:
host: greeter-service
port:
number: 3000
subset: v1
weight: 70
fault:
abort:
httpStatus: 500
percentage: 50
- destination:
host: greeter-service
port:
number: 3000
subset: v2
weight: 30

Hi,

what error did you got? is all OK in your YAML?

It should look like this:

kind: VirtualService
metadata:
  name: greeter-service
spec:
  hosts:
  - greeter-service
  http:
  - route:
    - destination:
        host: greeter-service
        port:
          number: 3000
        subset: v1
      weight: 70
      fault:
        abort:
          httpStatus: 500
          percentage: 50
    - destination:
        host: greeter-service
        port:
          number: 3000
        subset: v2
      weight: 30

I don’t get an error; however, I never get the fault to happen.
What you show in the yaml is what I had been testing with. The
weight-based routing works, but I never get the fault.