Timeout

This policy enables Kuma to set timeouts on the outbound connections depending on the protocol.

Usage

Specify the proxy to configure with the sources selector, and the outbound connections from the proxy with the destinations selector.

The policy lets you configure timeouts for HTTP, GRPC, and TCP protocols.

Example

  1. apiVersion: kuma.io/v1alpha1
  2. kind: Timeout
  3. mesh: default
  4. metadata:
  5. name: timeouts-backend
  6. spec:
  7. sources:
  8. - match:
  9. kuma.io/service: '*'
  10. destinations:
  11. - match:
  12. kuma.io/service: 'backend_default_svc_80'
  13. conf:
  14. # connectTimeout defines time to establish connection, 'connect_timeout' on Cluster, default 10s
  15. connectTimeout: 10s
  16. tcp:
  17. # 'idle_timeout' on TCPProxy, disabled by default
  18. idleTimeout: 1h
  19. http:
  20. # 'timeout' on Route, disabled by default
  21. requestTimeout: 5s
  22. # 'idle_timeout' on Cluster, disabled by default
  23. idleTimeout: 1h
  24. grpc:
  25. # 'stream_idle_timeout' on HttpConnectionManager, disabled by default
  26. streamIdleTimeout: 5m
  27. # 'max_stream_duration' on Cluster, disabled by default
  28. maxStreamDuration: 30m

We will apply the configuration with kubectl apply -f [..].

  1. type: Timeout
  2. mesh: default
  3. name: timeouts-backend
  4. sources:
  5. - match:
  6. kuma.io/service: '*'
  7. destinations:
  8. - match:
  9. kuma.io/service: 'backend'
  10. conf:
  11. # connectTimeout defines time to establish connection, 'connect_timeout' on Cluster, default 10s
  12. connectTimeout: 10s
  13. tcp:
  14. # 'idle_timeout' on TCPProxy, disabled by default
  15. idleTimeout: 1h
  16. http:
  17. # 'timeout' on Route, disabled by default
  18. requestTimeout: 5s
  19. # 'idle_timeout' on Cluster, disabled by default
  20. idleTimeout: 1h
  21. grpc:
  22. # 'stream_idle_timeout' on HttpConnectionManager, disabled by default
  23. streamIdleTimeout: 5m
  24. # 'max_stream_duration' on Cluster, disabled by default
  25. maxStreamDuration: 30m

We will apply the configuration with kumactl apply -f [..] or via the HTTP API.

Matching

Timeout is an Outbound Connection Policy. The only supported value for destinations.match is kuma.io/service.

Builtin Gateway support

Timeouts are connection policies and are supported by configuring the timeout parameters on the target Envoy cluster. Request timeouts are configured on the Envoy routes and may select a different Timeout policy when a route backend forwards to more than one distinct service.

Mesh configures an idle timeout on the HTTPConnectionManager, but doesn’t consistently use the Timeout policy values for this, so the semantica are ambiguous. There’s no policy that configures the idle timeout for downstream connections to the Gateway.