Careful!

You are browsing documentation for a version of Kuma that is not the latest release.

MeshRetry

This policy uses new policy matching algorithm. Do not combine with Retry.

This policy enables Kuma to know how to behave if there are failed requests which could be retried.

TargetRef support matrix

targetRef Allowed kinds
targetRef.kind Mesh, MeshSubset, MeshService, MeshServiceSubset
to[].targetRef.kind Mesh, MeshService

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

Configuration

The policy let you configure retry behaviour for HTTP, GRPC and TCP protocols. The protocol is selected by picking the most specific protocol.

Each protocol has a separate section under default in the policy yaml. Some sections are common between protocols or have similar meaning.

Retry on

The field retryOn is a list of conditions which will cause a retry.

For HTTP these are related to the response status code or method (5xx, 429, HttpMethodGet). For gRPC these are status codes in response headers (canceled, deadline-exceeded, etc.). There is no equivalent for TCP.

One or more conditions can be specified, for example:

retryOn:
  - "429"
  - "503"

means that it the policy will retry on a status code 429 or 503.

Full list of available HTTP conditions:

retryOn:
  - 5XX
  - GatewayError
  - Reset
  - Retriable4xx
  - ConnectFailure
  - EnvoyRatelimited
  - RefusedStream
  - Http3PostConnectFailure
  - HttpMethodConnect
  - HttpMethodDelete
  - HttpMethodGet
  - HttpMethodHead
  - HttpMethodOptions
  - HttpMethodPatch
  - HttpMethodPost
  - HttpMethodPut
  - HttpMethodTrace
  - "429" # any HTTP status code
  - "503"

Full list of available gRPC conditions:

retryOn:
  - Canceled
  - DeadlineExceeded
  - Internal
  - ResourceExhausted
  - Unavailable

Back off

This parameter is applicable to both HTTP and GRPC.

It consists of BaseInterval (the amount of time between retries) and MaxInterval (the maximal amount of time taken between retries).

We use an exponential back-off algorithm with jitter for retries. Given a base interval B and retry number N, the back-off for the retry is in the range [0, (2N - 1) × B).

For example, given a 25 ms interval, the first retry will be delayed randomly by 0-24 ms, the second by 0-74 ms, the third by 0-174 ms, and so on.

The interval is capped at a MaxInterval, which defaults to 10 times the BaseInterval.

Rate limited back off

This parameter is applicable to both HTTP and GRPC.

MeshRetry can be configured in such a way that when the upstream server rate limits the request and responds with a header like retry-after or x-ratelimit-reset it uses the value from the header to determine when to send the retry request instead of the back off algorithm.

Example

Given this configuration:

retryOn:
  - "503"
rateLimitedBackOff:
  resetHeaders:
    - name: retry-after
      format: Seconds
    - name: x-ratelimit-reset
      format: UnixTimestamp

and an HTTP response:

HTTP/1.1 503 Service Unavailable
retry-after: 15

The retry request will be issued after 15 seconds.

If the response is as follows:

HTTP/1.1 503 Service Unavailable
x-ratelimit-reset: 1706096119

The request will be retried at Wed Jan 24 2024 11:35:19 GMT+0000.

If the response does not contain retry-after or x-ratelimit-reset header (with valid integer value) then the amount of time to wait before issuing a request is determined by back off algorithm.

Examples

HTTP frontend to backend on 5xx

apiVersion: kuma.io/v1alpha1
kind: MeshRetry
metadata:
  name: web-to-backend-retry-http
  namespace: kuma-system
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: MeshService
    name: web
  to:
  - targetRef:
      kind: MeshService
      name: backend_kuma-demo_svc_8080
    default:
      http:
        numRetries: 10
        backOff:
          baseInterval: 15s
          maxInterval: 20m
        retryOn:
        - 5xx

gRPC frontend to backend on DeadlineExceeded

apiVersion: kuma.io/v1alpha1
kind: MeshRetry
metadata:
  name: web-to-backend-retry-grpc
  namespace: kuma-system
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: MeshService
    name: web
  to:
  - targetRef:
      kind: MeshService
      name: backend_kuma-demo_svc_8080
    default:
      grpc:
        numRetries: 5
        backOff:
          baseInterval: 5s
          maxInterval: 1m
        retryOn:
        - DeadlineExceeded

TCP frontend to backend

apiVersion: kuma.io/v1alpha1
kind: MeshRetry
metadata:
  name: web-to-backend-retry-tcp
  namespace: kuma-system
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: MeshService
    name: web
  to:
  - targetRef:
      kind: MeshService
      name: backend_kuma-demo_svc_8080
    default:
      tcp:
        maxConnectAttempt: 5

All policy options

Spec is the specification of the Kuma MeshRetry resource.

Type: object

Properties

  • targetRef required

    • TargetRef is a reference to the resource the policy takes an effect on.The resource could be either a real store object or virtual resourcedefined inplace.

    • Type: object

    • Properties

      • kind

        • Kind of the referenced resource
        • Type: string
        • The value is restricted to the following:
          1. "Mesh"
          2. "MeshSubset"
          3. "MeshGateway"
          4. "MeshService"
          5. "MeshServiceSubset"
          6. "MeshHTTPRoute"
      • mesh

        • Mesh is reserved for future use to identify cross mesh resources.
        • Type: string
      • name

        • Name of the referenced resource. Can only be used with kinds: MeshService,MeshServiceSubset and MeshGatewayRoute
        • Type: string
      • proxyTypes

        • ProxyTypes specifies the data plane types that are subject to the policy. When not specified,all data plane types are targeted by the policy.

        • Type: array

        • Item Count: ≥ 1

          • Items
          • Type: string
          • The value is restricted to the following:
            1. "Sidecar"
            2. "Gateway"
      • tags

        • Tags used to select a subset of proxies by tags. Can only be used with kindsMeshSubset and MeshServiceSubset
        • Type: object
        • This schema accepts additional properties.
        • Properties
  • to

    • To list makes a match between the consumed services and corresponding configurations

    • Type: array

      • Items

      • Type: object

      • Properties

        • default

          • Default is a configuration specific to the group of destinations referenced in'targetRef'

          • Type: object

          • Properties

            • grpc

              • GRPC defines a configuration of retries for GRPC traffic

              • Type: object

              • Properties

                • backOff

                  • BackOff is a configuration of durations which will be used in an exponentialbackoff strategy between retries.
                  • Type: object
                  • Properties
                    • baseInterval
                      • BaseInterval is an amount of time which should be taken between retries.Must be greater than zero. Values less than 1 ms are rounded up to 1 ms.
                      • Type: string
                      • Default: "25ms"
                    • maxInterval
                      • MaxInterval is a maximal amount of time which will be taken between retries.Default is 10 times the "BaseInterval".
                      • Type: string
                • numRetries

                  • NumRetries is the number of attempts that will be made on failed (andretriable) requests. If not set, the default value is 1.
                  • Type: integer
                • perTryTimeout

                  • PerTryTimeout is the maximum amount of time each retry attempt can takebefore it times out. If not set, the global request timeout for the routewill be used. Setting this value to 0 will disable the per-try timeout.
                  • Type: string
                • rateLimitedBackOff

                  • RateLimitedBackOff is a configuration of backoff which will be used whenthe upstream returns one of the headers configured.
                  • Type: object
                  • Properties
                    • maxInterval
                      • MaxInterval is a maximal amount of time which will be taken between retries.
                      • Type: string
                      • Default: "300s"
                    • resetHeaders
                      • ResetHeaders specifies the list of headers (like Retry-After or X-RateLimit-Reset)to match against the response. Headers are tried in order, and matchedcase-insensitive. The first header to be parsed successfully is used.If no headers match the default exponential BackOff is used instead.
                      • Type: array
                        • Items
                        • Type: object
                        • Properties
                          • format required
                            • The format of the reset header.
                            • Type: string
                            • The value is restricted to the following:
                              1. "Seconds"
                              2. "UnixTimestamp"
                          • name required
                            • The Name of the reset header.
                            • Type: string
                            • The value must match this pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
                            • Length: between 1 and 256
                • retryOn

                  • RetryOn is a list of conditions which will cause a retry.
                  • Type: array
                    • Items
                    • Type: string
                    • The value is restricted to the following:
                      1. "Canceled"
                      2. "DeadlineExceeded"
                      3. "Internal"
                      4. "ResourceExhausted"
                      5. "Unavailable"
            • http

              • HTTP defines a configuration of retries for HTTP traffic

              • Type: object

              • Properties

                • backOff

                  • BackOff is a configuration of durations which will be used in exponentialbackoff strategy between retries.
                  • Type: object
                  • Properties
                    • baseInterval
                      • BaseInterval is an amount of time which should be taken between retries.Must be greater than zero. Values less than 1 ms are rounded up to 1 ms.
                      • Type: string
                      • Default: "25ms"
                    • maxInterval
                      • MaxInterval is a maximal amount of time which will be taken between retries.Default is 10 times the "BaseInterval".
                      • Type: string
                • hostSelection

                  • HostSelection is a list of predicates that dictate how hosts should be selectedwhen requests are retried.
                  • Type: array
                    • Items
                    • Type: object
                    • Properties
                      • predicate required
                        • Type is requested predicate mode.
                        • Type: string
                        • The value is restricted to the following:
                          1. "OmitPreviousHosts"
                          2. "OmitHostsWithTags"
                          3. "OmitPreviousPriorities"
                      • tags
                        • Tags is a map of metadata to match against for selecting the omitted hosts. Required if Type isOmitHostsWithTags
                        • Type: object
                        • This schema accepts additional properties.
                        • Properties
                      • updateFrequency
                        • UpdateFrequency is how often the priority load should be updated based on previously attempted priorities.Used for OmitPreviousPriorities.
                        • Type: integer
                        • Default: 2
                • hostSelectionMaxAttempts

                  • HostSelectionMaxAttempts is the maximum number of times host selection will bereattempted before giving up, at which point the host that was last selected willbe routed to. If unspecified, this will default to retrying once.
                  • Type: integer
                • numRetries

                  • NumRetries is the number of attempts that will be made on failed (andretriable) requests. If not set, the default value is 1.
                  • Type: integer
                • perTryTimeout

                  • PerTryTimeout is the amount of time after which retry attempt should time out.If left unspecified, the global route timeout for the request will be used.Consequently, when using a 5xx based retry policy, a request that times outwill not be retried as the total timeout budget would have been exhausted.Setting this timeout to 0 will disable it.
                  • Type: string
                • rateLimitedBackOff

                  • RateLimitedBackOff is a configuration of backoff which will be usedwhen the upstream returns one of the headers configured.
                  • Type: object
                  • Properties
                    • maxInterval
                      • MaxInterval is a maximal amount of time which will be taken between retries.
                      • Type: string
                      • Default: "300s"
                    • resetHeaders
                      • ResetHeaders specifies the list of headers (like Retry-After or X-RateLimit-Reset)to match against the response. Headers are tried in order, and matchedcase-insensitive. The first header to be parsed successfully is used.If no headers match the default exponential BackOff is used instead.
                      • Type: array
                        • Items
                        • Type: object
                        • Properties
                          • format required
                            • The format of the reset header.
                            • Type: string
                            • The value is restricted to the following:
                              1. "Seconds"
                              2. "UnixTimestamp"
                          • name required
                            • The Name of the reset header.
                            • Type: string
                            • The value must match this pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
                            • Length: between 1 and 256
                • retriableRequestHeaders

                  • RetriableRequestHeaders is an HTTP headers which must be present in the requestfor retries to be attempted.

                  • Type: array

                    • Items

                    • HeaderMatch describes how to select an HTTP route by matching HTTP requestheaders.

                    • Type: object

                    • Properties

                      • name required

                        • Name is the name of the HTTP Header to be matched. Name MUST be lower caseas they will be handled with case insensitivity (See https://tools.ietf.org/html/rfc7230#section-3.2).
                        • Type: string
                        • The value must match this pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
                        • Length: between 1 and 256
                      • type

                        • Type specifies how to match against the value of the header.
                        • Type: string
                        • The value is restricted to the following:
                          1. "Exact"
                          2. "Present"
                          3. "RegularExpression"
                          4. "Absent"
                          5. "Prefix"
                        • Default: "Exact"
                      • value

                        • Value is the value of HTTP Header to be matched.
                        • Type: string
                • retriableResponseHeaders

                  • RetriableResponseHeaders is an HTTP response headers that trigger a retryif present in the response. A retry will be triggered if any of the headermatches the upstream response headers.

                  • Type: array

                    • Items

                    • HeaderMatch describes how to select an HTTP route by matching HTTP requestheaders.

                    • Type: object

                    • Properties

                      • name required

                        • Name is the name of the HTTP Header to be matched. Name MUST be lower caseas they will be handled with case insensitivity (See https://tools.ietf.org/html/rfc7230#section-3.2).
                        • Type: string
                        • The value must match this pattern: ^[a-z0-9!#$%&'*+\-.^_\x60|~]+$
                        • Length: between 1 and 256
                      • type

                        • Type specifies how to match against the value of the header.
                        • Type: string
                        • The value is restricted to the following:
                          1. "Exact"
                          2. "Present"
                          3. "RegularExpression"
                          4. "Absent"
                          5. "Prefix"
                        • Default: "Exact"
                      • value

                        • Value is the value of HTTP Header to be matched.
                        • Type: string
                • retryOn

                  • RetryOn is a list of conditions which will cause a retry. Available values are:[5XX, GatewayError, Reset, Retriable4xx, ConnectFailure, EnvoyRatelimited,RefusedStream, Http3PostConnectFailure, HttpMethodConnect, HttpMethodDelete,HttpMethodGet, HttpMethodHead, HttpMethodOptions, HttpMethodPatch,HttpMethodPost, HttpMethodPut, HttpMethodTrace].Also, any HTTP status code (500, 503, etc.).
                  • Type: array
                    • Items
                    • Type: string
            • tcp

              • TCP defines a configuration of retries for TCP traffic
              • Type: object
              • Properties
                • maxConnectAttempt
                  • MaxConnectAttempt is a maximal amount of TCP connection attemptswhich will be made before giving up
                  • Type: integer
        • targetRef required

          • TargetRef is a reference to the resource that represents a group ofdestinations.

          • Type: object

          • Properties

            • kind

              • Kind of the referenced resource
              • Type: string
              • The value is restricted to the following:
                1. "Mesh"
                2. "MeshSubset"
                3. "MeshGateway"
                4. "MeshService"
                5. "MeshServiceSubset"
                6. "MeshHTTPRoute"
            • mesh

              • Mesh is reserved for future use to identify cross mesh resources.
              • Type: string
            • name

              • Name of the referenced resource. Can only be used with kinds: MeshService,MeshServiceSubset and MeshGatewayRoute
              • Type: string
            • proxyTypes

              • ProxyTypes specifies the data plane types that are subject to the policy. When not specified,all data plane types are targeted by the policy.

              • Type: array

              • Item Count: ≥ 1

                • Items
                • Type: string
                • The value is restricted to the following:
                  1. "Sidecar"
                  2. "Gateway"
            • tags

              • Tags used to select a subset of proxies by tags. Can only be used with kindsMeshSubset and MeshServiceSubset
              • Type: object
              • This schema accepts additional properties.
              • Properties

Generated with json-schema-md-doc Wed Jul 30 2025 03:44:09 GMT+0000 (Coordinated Universal Time)