All Products
Search
Document Center

Alibaba Cloud Service Mesh:ASMCircuitBreaker CRD reference

Last Updated:Sep 24, 2026

Service Mesh (ASM) provides declarative circuit breaking through the ASMCircuitBreaker Custom Resource Definition (CRD). This reference covers every field in the ASMCircuitBreaker spec, along with configuration examples.

For a step-by-step setup guide, see Use route-level circuit breaking in ASM.

Full schema overview

The following YAML shows every available field and its nesting hierarchy:

apiVersion: istio.alibabacloud.com/v1       # v1beta1 for ASM < 1.15.3.105
kind: ASMCircuitBreaker
metadata:
  name: <circuit-breaker-name>
spec:
  workloadSelector:                          # Required. Labels to select target pods/VMs.
    labels:
      <label-key>: <label-value>
  isGateway: false                           # Whether this applies to a gateway.
  applyToTraffic: sidecar_outbound           # ASM 1.25+. Traffic direction.
  configs:                                   # Required. One or more circuit breaking rules.
    - name: <config-name>
      target_services:                       # ASM 1.25+. Services to protect.
        - kind: Service                      # Service | ServiceEntry | VirtualService
          namespace: <namespace>
          name: <service-name>
          port: <port-number>
          section_name: <route-name>         # VirtualService only.
      match:                                 # Route-level match conditions.
        vhost:
          name: <virtual-host-name>
          port: <port>
          route:
            name_match: <route-name>
            header_match:                    # ASM 1.16+.
              - name: <header-name>
                exact_match: <value>         # Choose one match type.
                regex_match: <pattern>
                prefix_match: <prefix>
                suffix_match: <suffix>
                present_match: true
                invert_match: false
      breaker_config:                        # Circuit breaking thresholds.
        window_size: 10s                     # Statistics time window (max 12s).
        break_duration: 30s                  # How long the circuit stays open.
        slow_request_rt: <duration>          # Slow request latency threshold.
        average_request_rt: <duration>       # Average response time.
        max_slow_requests: <count>           # Max slow requests before tripping.
        error_percent:                       # 5xx error percentage threshold.
          value: <0-100>
        gateway_error_percent:               # 502/503/504 error threshold. ASM 1.24.6.54+.
          value: <0-100>
        min_request_amount: 0                # Min requests before evaluating error_percent.
        custom_response:                     # Response returned when circuit is open.
          status_code: <http-status-code>
          header_to_add:
            <header-name>: <header-value>
          body: <response-body>

apiVersion

ASM versionapiVersion
1.15.3.105 or lateristio.alibabacloud.com/v1
Earlier than 1.15.3.105istio.alibabacloud.com/v1beta1

If you previously deployed an ASMCircuitBreaker in a Container Service for Kubernetes (ACK) cluster using v1beta1, update the apiVersion field to istio.alibabacloud.com/v1 and redeploy.

spec

applyToTraffic

Note

This field requires ASM 1.25 or later.

FieldTypeRequiredDefaultDescription
applyToTrafficstringNosidecar_outboundTraffic direction for the circuit breaking policy.

Valid values:

ValueDescription
sidecar_inboundInbound traffic to a sidecar proxy. The application with the sidecar acts as a server.
sidecar_outboundOutbound traffic from a sidecar proxy. The application with the sidecar acts as a client.
waypointTraffic processed by a waypoint proxy in Ambient mode.
gatewayGateway traffic.

ASMCircuitBreakerSpec

FieldTypeRequiredDefaultDescription
workloadSelectormap<string, string>Yes--Labels to select pods or VMs. Scoped to the namespace of the resource. See WorkloadSelector.
isGatewayboolNofalseWhen true, applies the configuration to a gateway.
configsCircuitBreakerConfig[]Yes--One or more circuit breaking configurations.

CircuitBreakerConfig

FieldTypeRequiredDefaultDescription
namestringNo--Name of this circuit breaking configuration.
matchCircuitBreakerMatchNo--Route-level match conditions. See CircuitBreakerMatch.
breaker_configBreakerConfigNo--Circuit breaking thresholds. See BreakerConfig.
target_servicesTargetServiceRef[]No--Target services for the policy. ASM 1.25+ only. See TargetServiceRef.

TargetServiceRef

Note

These fields require ASM 1.25 or later.

FieldTypeRequiredDefaultDescription
kindstringNoServiceResource type. Valid values: Service, ServiceEntry, VirtualService.
namestringYes--Name of the target service.
namespacestringNoSame as the ASMCircuitBreaker resourceNamespace of the target service.
portint32No--Port of the target service.
section_namestringNo--Name of a route defined in the VirtualService. Only valid when kind is VirtualService.

TargetServiceRef examples

Target a Service

Apply circuit breaking to port 8000 of the httpbin Service in the default namespace:

target_services:
- kind: Service
  namespace: default
  name: httpbin
  port: 8000

Target a ServiceEntry

Given the following ServiceEntry:

apiVersion: networking.istio.io/v1
kind: ServiceEntry
metadata:
  name: se-httpbin-external
spec:
  hosts:
  - httpbin.test.com
  location: MESH_EXTERNAL
  ports:
  - name: http
    number: 80
    protocol: HTTP
  - name: https
    number: 443
    protocol: HTTPS
  resolution: DNS

Apply circuit breaking to port 80 of this ServiceEntry:

target_services:
- kind: ServiceEntry
  namespace: default
  name: se-httpbin-external
  port: 80

Target a VirtualService route

Given the following VirtualService:

apiVersion: networking.istio.io/v1
kind: VirtualService
metadata:
  name: vs-httpbin
spec:
  hosts:
  - httpbin.test.com
  http:
  - name: default
    route:
    - destination:
        host: httpbin
        port:
          number: 8000

Apply circuit breaking to the HTTP route named default:

target_services:
- kind: VirtualService
  namespace: default
  name: vs-httpbin
  section_name: default

BreakerConfig

Circuit breaking thresholds fall into two categories:

  • Slow request detection: slow_request_rt, max_slow_requests, and average_request_rt define when latency-based tripping occurs.

  • Error rate detection: error_percent and gateway_error_percent define when error-based tripping occurs.

Both categories share window_size, break_duration, and min_request_amount.

FieldTypeRequiredDefaultDescription
window_sizeDurationNo10sTime window for collecting request statistics. Maximum: 12s.
break_durationDurationNo30sDuration the circuit breaker stays open after tripping.
slow_request_rtDurationNo--Latency threshold for slow requests. Requests exceeding this response time are counted as slow.
average_request_rtDurationNo (Required before ASM 1.14)--Average response time for the service. Example: 0.01s.
max_slow_requestsuint32No--Maximum number of slow requests allowed within the time window. This must be an integer, for example, 1000. The circuit breaker trips when this count is exceeded.
error_percentPercentNo--5xx error rate threshold. The circuit breaker trips when the percentage of 5xx errors within the time window exceeds this value.
gateway_error_percentPercentNo--Gateway error rate threshold (502, 503, 504 only). ASM 1.24.6.54+ only.
min_request_amountuint32No0Minimum number of requests required before error_percent is evaluated. Prevents tripping on a small sample size.
custom_responseCustomResponseNo--Custom response returned to clients when the circuit breaker is open. See CustomResponse.

CustomResponse

Defines the response returned to clients when the circuit breaker rejects a request.

FieldTypeRequiredDefaultDescription
status_codeint32No--HTTP status code of the response.
header_to_addmap\[string\]stringNo--Headers to include in the response.
bodystringNo--Body of the response.

CircuitBreakerMatch

FieldTypeRequiredDefaultDescription
vhostVirtualHostMatchNo--Virtual host match conditions. See VirtualHostMatch.

VirtualHostMatch

FieldTypeRequiredDefaultDescription
namestringNo--Virtual host name to match.
portintNo--Request port to match.
routeRouteMatchYes--Routing rule to match. See RouteMatch.

RouteMatch

FieldTypeRequiredDefaultDescription
name_matchstringYes (gateway) / No (sidecar)--Route name to match. Corresponds to a route name defined in a VirtualService.
header_matchHeaderMatcher[]No--Request header conditions. Multiple headers supported. ASM 1.16+ only. Requires the latest gateway and sidecar proxy versions. See Upgrade an ASM instance and Upgrade a sidecar proxy.

HeaderMatcher

Specify exactly one match type per entry (regex_match, exact_match, prefix_match, suffix_match, or present_match).

FieldTypeRequiredDefaultDescription
namestringNo--Header name.
regex_matchstringNo--Match the header value against a regular expression.
exact_matchstringNo--Match the header value exactly.
prefix_matchstringNo--Match header values that start with the specified string.
suffix_matchstringNo--Match header values that end with the specified string.
present_matchboolNo--true: the header must be present (any value). false: the header must not be present.
invert_matchboolNofalsetrue: invert the match result. false: use the original match result.

Configuration examples

All examples use the applyToTraffic field to specify the traffic direction and breaker_config to set circuit breaking thresholds.

Client-side circuit breaking

Note

Requires ASM 1.25.6.74 or later.

This configuration applies to outbound traffic from the sleep application to httpbin on port 8000. The circuit breaker trips when either condition is met within a 10-second window:

  • More than 60% of requests return 5xx errors.

  • More than 10 requests exceed the 100 ms response time threshold.

When the circuit breaker is open, clients receive a 499 status code with a custom response body and header.

apiVersion: istio.alibabacloud.com/v1
kind: ASMCircuitBreaker
metadata:
  name: client-break
spec:
  workloadSelector:
    labels:
      app: sleep
  applyToTraffic: sidecar_outbound
  configs:
    - target_services:
      - name: httpbin
        port: 8000
      breaker_config:
        slow_request_rt: 0.1s
        break_duration: 90s
        window_size: 10s
        max_slow_requests: 10
        min_request_amount: 3
        error_percent:
          value: 60
        custom_response:
          header_to_add:
            x-envoy-circuitbreak: "true"
          body: "hello, break!"
          status_code: 499

Waypoint circuit breaking

Note

Requires ASM 1.25.6.74 or later. Applies only to Ambient mode.

This configuration applies the same circuit breaking thresholds through a waypoint proxy named default:

apiVersion: istio.alibabacloud.com/v1
kind: ASMCircuitBreaker
metadata:
  name: test
spec:
  workloadSelector:
    labels:
      gateway.networking.k8s.io/gateway-name: default
  applyToTraffic: waypoint
  configs:
    - target_services:
      - name: httpbin
        port: 8000
      breaker_config:
        slow_request_rt: 0.1s
        break_duration: 90s
        window_size: 10s
        max_slow_requests: 10
        min_request_amount: 3
        error_percent:
          value: 60
        custom_response:
          header_to_add:
            x-envoy-circuitbreak: "true"
          body: "hello, break!"
          status_code: 499

What's next