Service Mesh (ASM) allows you to declaratively define the circuit breaking configurations by using the ASMCircuitBreaker CustomResourceDefinition (CRD). This topic describes the fields of ASMCircuitBreaker.
apiVersion
If the version of your ASM instance is 1.15.3.105 or later, you can set the apiVersion field to
istio.alibabacloud.com/v1
. If you have set the apiVersion field toistio.alibabacloud.com/v1beta1
when you configured ASMCircuitBreaker in the ACK cluster, change the value toistio.alibabacloud.com/v1
in the ASMCircuitBreaker CRD, and deploy the cluster again.If the version of your ASM instance is earlier than 1.15.3.105, you can set the apiVersion field to
istio.alibabacloud.com/v1beta1
.
spec
The following tables describe the fields of the ASMCircuitBreaker spec. For more information about the features and examples of ASMCircuitBreaker, see Use the route-level circuit breaking feature of ASM.
ASMCircuitBreakerSpec
Field | Type | Required | Description |
workloadSelector | map<string, string> | Yes | The one or more labels that specify a set of pods or VMs on which the circuit breaking rule takes effect. The scope of label search is restricted to the configuration namespace in which the resources reside. For more information, see Workload Selector. |
isGateway | bool | No | Specifies whether to apply the configurations to a gateway. The value true indicates that the configurations apply to the gateway. Default value: false. |
configs | Yes | The circuit breaking rule. You can configure multiple circuit breaking rules. |
CircuitBreakerConfig
Field | Type | Required | Description |
name | string | No | The name of the circuit breaking rule. |
match | No | The match criteria. | |
breaker_config | No | The configurations of route-level circuit breaking. |
CircuitBreakerMatch
Field | Type | Required | Description |
vhost | No | The matched virtual host. |
BreakerConfig
Field | Type | Required | Description |
window_size | Duration | No | The statistical time window. Unit: seconds. Default value: 10. The value cannot exceed 12. |
break_duration | Duration | No | The circuit breaking period during which new requests are denied. Unit: seconds. Default value: 30. |
slow_request_rt | Duration | No | The response latency of a request beyond which the request is considered a slow request. |
average_request_rt | Duration |
| The average response time of a service request. Example: 0.01s. |
max_slow_requests | uint32 | No | The maximum number of slow requests that are allowed. The value must be an integer. Example: 1000. If this limit is reached, new requests are denied. |
error_percent | No | The maximum percentage of error requests that are allowed. The error code of an error request is 5XX. If this limit is reached within the statistical time window, new requests are denied. | |
min_request_amount | uint32 | No | The minimum number of requests. Default value: 0. If you set the error_percent field, we recommend that you also set this field to prevent requests from being denied by mistake. |
custom_response | No | The content that is displayed when a request is denied. You can customize the content. |
CustomResponse
Field | Type | Required | Description |
status_code | int32 | No | The HTTP response status code. |
header_to_add | map[string]string | No | The response headers. You can customize the response headers. |
body | string | No | The response body. You can customize the response body. |
VirtualHostMatch
Field | Type | Required | Description |
name | string | No | The name of the matched virtual host. |
port | int | No | The matched request port. |
route | Yes | The name of the route corresponding to the matched request port. |
RouteMatch
Field | Type | Required | Description |
name_match | string |
| The name of the matched route. This field specifies a single route in a virtual service. |
header_match | No | The header of the matched service requests. You can configure multiple headers. Important This field is available only when the version of your ASM instance is 1.16 or later and the gateways and sidecar proxies are of the latest versions. For more information about how to upgrade ASM instances and gateways, see Update an ASM instance. For more information about how to upgrade sidecar proxies, see Upgrade sidecar proxies. |
HeaderMatcher
Field | Type | Required | Description | |
name | string | No | The name of the header. | |
Specify one of the fields based on the match mode | regex_match | string | No | The regular expression used to perform a header match. The header value must match the specified regular expression. |
exact_match | string | No | The value used to perform a header match. The header value must exactly match the specified value. | |
prefix_match | string | No | The prefix used to perform a header match. The header value must start with the specified characters. | |
suffix_match | string | No | The suffix used to perform a header match. The header value must end with the specified characters. | |
present_match | bool | No |
| |
invert_match | bool | No | Specifies whether to invert the match result. Default value: false.
|