mirror of https://github.com/hashicorp/consul
fault injection docs
parent
7d4deda640
commit
da722983c1
|
@ -0,0 +1,193 @@
|
|||
---
|
||||
layout: docs
|
||||
page_title: Fault Injection
|
||||
description: Learn how to use fault injection in a Consul service mesh. Fault injection can be used to inject artificial latency, response codes, or bandwidth limits for application testing.
|
||||
---
|
||||
|
||||
# Fault Injection
|
||||
|
||||
This topic describes how to configure Consul to inject different types of faults into the services in the mesh.
|
||||
|
||||
<EnterpriseAlert> This feature is available in Consul Enterprise. </EnterpriseAlert>
|
||||
|
||||
## Introduction
|
||||
|
||||
Consul allows you to configure fault injection filters which can alter the responses from an upstream service. By injecting HTTP and gRPC statuses, bandwidth limits, or delays, users can test the resilience of their system to different unexpected issues.
|
||||
|
||||
Consul applies fault injection filters per upstream service as part of their service defaults. For example, if you wished to simulate that an upstream returned a 500 HTTP status code 50 percent of the time, you would add an Abort configuration to the Envoy extensions for the upstream service's service default configuration.
|
||||
|
||||
The fault injection filters may be used individually, or in a combination of the three types by adding multiple blocks to the `Arguments.Config` section of the configuration.
|
||||
|
||||
## Requirements
|
||||
|
||||
Consul Enterprise v1.18.0 or later
|
||||
|
||||
## Inject Delays
|
||||
|
||||
Specify the fault injection behavior in the service defaults config entry.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="VMs" group="vms">
|
||||
|
||||
1. `Arguments.Config.Delay.Duration`: The delay in milliseconds to use when injecting a delay type fault.
|
||||
1. `Arguments.Config.Delay.Percentage`: The percentage of responses to inject the delay behavior into.
|
||||
|
||||
The following example configures the default behavior for a service named `billing`. This configuration injects a 100 ms delay into 50 percent of responses from the billing service.
|
||||
|
||||
```hcl
|
||||
Kind = "service-defaults"
|
||||
Name = "billing"
|
||||
EnvoyExtensions = [
|
||||
{
|
||||
Name = "builtin/fault-injection"
|
||||
Arguments = {
|
||||
Config = {
|
||||
Delay = {
|
||||
Duration = 100
|
||||
Percentage = 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="Kubernetes" group="k8s">
|
||||
|
||||
1. `spec.arguments.config.delay.duration`: The delay in milliseconds to use when injecting a delay type fault.
|
||||
1. `spec.arguments.config.delay.percentage`: The percentage of responses to inject the delay behavior into.
|
||||
|
||||
The following example configures the default behavior for a service named `billing`. This configuration injects a 100 ms delay into 50 percent of responses from the billing service.
|
||||
|
||||
```yaml
|
||||
kind: ServiceDefaults
|
||||
metadata:
|
||||
name: billing
|
||||
spec:
|
||||
envoyExtensions:
|
||||
- name: "builtin/fault-injection"
|
||||
arguments:
|
||||
config:
|
||||
delay:
|
||||
duration: 100
|
||||
percentage: 50
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
|
||||
Refer to the [service defaults configuration entry reference](/consul/docs/connect/config-entries/service-defaults) for additional specifications and example configurations.
|
||||
|
||||
## Inject Statuses
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="VMs" group="vms">
|
||||
|
||||
1. `Arguments.Config.Abort.HttpStatus`: The HTTP status code to inject into responses when injecting an abort type fault. You may specify either a HTTP status or a gRPC status but not both.
|
||||
1. `Arguments.Config.Abort.GrpcStatus`: The gRPC status to inject into responses when injecting an abort type fault. You may specify either a HTTP status or a gRPC status but not both.
|
||||
1. `Arguments.Config.Abort.Percentage`: The percentage of responses to inject the abort behavior into.
|
||||
|
||||
The following example configures the default behavior for a service named `billing`. This configuration injects an HTTP status code of 503 into 5 percent of responses from the billing service.
|
||||
|
||||
```hcl
|
||||
Kind = "service-defaults"
|
||||
Name = "billing"
|
||||
EnvoyExtensions = [
|
||||
{
|
||||
Name = "builtin/fault-injection"
|
||||
Arguments = {
|
||||
Config = {
|
||||
Abort = {
|
||||
HttpStatus = 503
|
||||
Percentage = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="Kubernetes" group="k8s">
|
||||
|
||||
1. `spec.arguments.config.abort.httpStatus`: The HTTP status code to inject into responses when injecting an abort type fault. You may specify either a HTTP status or a gRPC status but not both.
|
||||
1. `spec.arguments.config.abort.grpcStatus`: The gRPC status to inject into responses when injecting an abort type fault. You may specify either a HTTP status or a gRPC status but not both.
|
||||
1. `spec.arguments.config.abort.percentage`: The percentage of responses to inject the abort behavior into.
|
||||
|
||||
The following example configures the default behavior for a service named `billing`. This configuration injects an HTTP status code of 503 into 5 percent of responses from the billing service.
|
||||
|
||||
```yaml
|
||||
kind: ServiceDefaults
|
||||
metadata:
|
||||
name: billing
|
||||
spec:
|
||||
envoyExtensions:
|
||||
- name: "builtin/fault-injection"
|
||||
arguments:
|
||||
config:
|
||||
abort:
|
||||
httpStatus: 503
|
||||
percentage: 5
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Refer to the [service defaults configuration entry reference](/consul/docs/connect/config-entries/service-defaults) for additional specifications and example configurations.
|
||||
|
||||
## Inject Bandwidth Limit
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="VMs" group="vms">
|
||||
|
||||
1. `Arguments.Config.Bandwidth.Limit`: The amount of data allowed through the filter when applied. This value is specified in KiB/s. When the limit is exceeded, requests, operations, or connections will be subjected to rate limiting.
|
||||
1. `Arguments.Config.Bandwidth.Percentage`: The percent of responses to inject the bandwidth limit behavior into.
|
||||
|
||||
The following example configures the default behavior for a service named `billing`. This configuration limits the bandwidth of outgoing requests to 100 KiB/s for 50 percent of responses from the billing service.
|
||||
|
||||
```hcl
|
||||
Kind = "service-defaults"
|
||||
Name = "billing"
|
||||
EnvoyExtensions = [
|
||||
{
|
||||
Name = "builtin/fault-injection"
|
||||
Arguments = {
|
||||
Config = {
|
||||
Bandwidth = {
|
||||
Limit = 100
|
||||
Percentage = 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="Kubernetes" group="k8s">
|
||||
|
||||
1. `spec.arguments.config.delay.duration`:
|
||||
1. `spec.arguments.config.delay.duration`:
|
||||
|
||||
The following example configures the default behavior for a service named `billing`. This configuration limits the bandwidth of outgoing requests to 100 KiB/s for 50 percent of responses from the billing service.
|
||||
|
||||
```yaml
|
||||
kind: ServiceDefaults
|
||||
metadata:
|
||||
name: billing
|
||||
spec:
|
||||
envoyExtensions:
|
||||
- name: "builtin/fault-injection"
|
||||
arguments:
|
||||
config:
|
||||
bandwidth:
|
||||
limit: 100
|
||||
percentage: 100
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
Refer to the [service defaults configuration entry reference](/consul/docs/connect/config-entries/service-defaults) for additional specifications and example configurations.
|
Loading…
Reference in New Issue