Fault Injection

FaultInjection policy helps you to test your microservices against resiliency. Kuma provides 3 different types of failures that could be imitated in your environment. These faults are Delay, Abort and ResponseBandwidth limit.

On Universal:

  1. type: FaultInjection
  2. mesh: default
  3. name: fi1
  4. sources:
  5. - match:
  6. service: frontend
  7. version: "0.1"
  8. protocol: http
  9. destinations:
  10. - match:
  11. service: backend
  12. protocol: http
  13. conf:
  14. abort:
  15. httpStatus: 500
  16. percentage: 50
  17. delay:
  18. percentage: 50.5
  19. value: 5s
  20. responseBandwidth:
  21. limit: 50 mbps
  22. percentage: 50

On Kubernetes:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: FaultInjection
  3. mesh: default
  4. metadata:
  5. namespace: default
  6. name: fi1
  7. spec:
  8. sources:
  9. - match:
  10. service: frontend
  11. version: "0.1"
  12. protocol: http
  13. destinations:
  14. - match:
  15. service: backend
  16. protocol: http
  17. conf:
  18. abort:
  19. httpStatus: 500
  20. percentage: 50
  21. delay:
  22. percentage: 50.5
  23. value: 5s
  24. responseBandwidth:
  25. limit: 50 mbps
  26. percentage: 50

Sources & Destinations

FaultInjection is a policy, which is applied to the connection between dataplanes. As most of the policies, FaultInjection supports the powerful mechanism of matching, which allows you to precisely match source and destination dataplanes.

FaultInjection policy available only for L7 HTTP traffic, protocol: http is mandatory tag both for source and destination selector.

HTTP Faults

At least one of the following Faults should be specified.

Abort

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

  • httpStatus - HTTP status code which will be returned to source side
  • percentage - percentage of requests on which abort will be injected, has to be in [0.0 - 100.0] range

Delay

Delay defines configuration of delaying a response from a destination.

  • value - the duration during which the response will be delayed
  • percentage - percentage of requests on which delay will be injected, has to be in [0.0 - 100.0] range

ResponseBandwidth limit

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

  • limit - represented by value measure in gbps, mbps, kbps or bps, e.g. 10kbps
  • percentage - percentage of requests on which response bandwidth limit will be injected, has to be in [0.0 - 100.0] range