MeshFaultInjection

With the MeshFaultInjection policy you can easily test your microservices against resiliency.

This policy uses a new policy matching algorithm. Do not combine with FaultInjection.

targetRef support matrix

targetRefAllowed kinds
targetRef.kindMesh, MeshSubset
from[].targetRef.kindMesh, MeshSubset, MeshServiceSubset
targetRefAllowed kinds
targetRef.kindMesh, MeshGateway, MeshGateway with listener tags
to[].targetRef.kindMesh

MeshFaultInjection isn’t supported on delegated gateways.

To learn more about the information in this table, see the matching docs.

Configuration

MeshFaultInjection allows configuring a list of HTTP faults. They execute in the same order as they were defined.

  1. default:
  2. http:
  3. - abort:
  4. httpStatus: 500
  5. percentage: "2.5"
  6. delay:
  7. value: 5s
  8. percentage: 5
  9. responseBandwidth:
  10. limit: "50Mbps"
  11. percentage: 50
  12. - abort:
  13. httpStatus: 500
  14. percentage: 10
  15. - delay:
  16. value: 5s
  17. percentage: 5

It’s worth mentioning that percentage of the next filter depends on the percentage of previous ones.

  1. http:
  2. - abort:
  3. httpStatus: 500
  4. percentage: 70
  5. - abort:
  6. httpStatus: 503
  7. percentage: 50

That means that for 70% of requests, it returns 500 and for 50% of the 30% that passed it returns 503.

Abort

Abort defines a configuration of not delivering requests to destination service and replacing the responses from destination data plane by predefined status code.

  • httpStatus - HTTP status code which will be returned to source side, has to be in [100 - 599] range
  • percentage - a percentage of requests on which abort will be injected, has to be in [0.0 - 100.0] range. If the value is a double number, put it in quotes.

Delay

Delay defines a configuration of delaying a response from a destination.

  • value - the duration during which the response will be delayed
  • percentage - a percentage of requests on which abort will be injected, has to be in [0.0 - 100.0] range. If the value is a double number, put it in quotes.

ResponseBandwidth limit

ResponseBandwidth defines a configuration to limit the speed of responding to requests.

  • limit - represented by value measure in Gbps, Mbps, kbps, or bps, for example 10kbps
  • percentage - a percentage of requests on which abort will be injected, has to be in [0.0 - 100.0] range. If the value is a double number, put it in quotes.

Examples

Service backend returns 500 for 50% of requests from frontend service

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshFaultInjection
  3. metadata:
  4. name: default-fault-injection
  5. namespace: kuma-demo
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshSubset
  11. tags:
  12. app: backend
  13. from:
  14. - targetRef:
  15. kind: MeshSubset
  16. tags:
  17. kuma.io/service: frontend
  18. default:
  19. http:
  20. - abort:
  21. httpStatus: 500
  22. percentage: 50
  1. type: MeshFaultInjection
  2. mesh: default
  3. name: default-fault-injection
  4. spec:
  5. targetRef:
  6. kind: MeshSubset
  7. tags:
  8. app: backend
  9. from:
  10. - targetRef:
  11. kind: MeshSubset
  12. tags:
  13. kuma.io/service: frontend
  14. default:
  15. http:
  16. - abort:
  17. httpStatus: 500
  18. percentage: 50

50.5% of requests to service backend from any service is going to be delayed by 5 seconds

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshFaultInjection
  3. metadata:
  4. name: default-fault-injection
  5. namespace: kuma-demo
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshSubset
  11. tags:
  12. app: backend
  13. from:
  14. - targetRef:
  15. kind: Mesh
  16. name: default
  17. default:
  18. http:
  19. - delay:
  20. percentage: '50.5'
  21. value: 5s
  1. type: MeshFaultInjection
  2. mesh: default
  3. name: default-fault-injection
  4. spec:
  5. targetRef:
  6. kind: MeshSubset
  7. tags:
  8. app: backend
  9. from:
  10. - targetRef:
  11. kind: Mesh
  12. name: default
  13. default:
  14. http:
  15. - delay:
  16. percentage: '50.5'
  17. value: 5s

Backend service with a list of faults that are applied for frontend service

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshFaultInjection
  3. metadata:
  4. name: default-fault-injection
  5. namespace: kuma-demo
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshSubset
  11. tags:
  12. app: backend
  13. from:
  14. - targetRef:
  15. kind: MeshSubset
  16. tags:
  17. kuma.io/service: frontend
  18. default:
  19. http:
  20. - abort:
  21. httpStatus: 500
  22. percentage: '2.5'
  23. - abort:
  24. httpStatus: 500
  25. percentage: 10
  26. - delay:
  27. value: 5s
  28. percentage: 5
  1. type: MeshFaultInjection
  2. mesh: default
  3. name: default-fault-injection
  4. spec:
  5. targetRef:
  6. kind: MeshSubset
  7. tags:
  8. app: backend
  9. from:
  10. - targetRef:
  11. kind: MeshSubset
  12. tags:
  13. kuma.io/service: frontend
  14. default:
  15. http:
  16. - abort:
  17. httpStatus: 500
  18. percentage: '2.5'
  19. - abort:
  20. httpStatus: 500
  21. percentage: 10
  22. - delay:
  23. value: 5s
  24. percentage: 5

All policy options