Mesh Timeout (beta)

This policy uses new policy matching algorithm and is in beta state, it should not be mixed with Timeout policy.

TargetRef support matrix

TargetRef typetop leveltofrom
Mesh
MeshSubset
MeshService
MeshServiceSubset
MeshHTTPRoute

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

Configuration

This policy enables Kuma to set timeouts on the inbound and outbound connections depending on the protocol. Using this policy you can configure TCP and HTTP timeouts. Timeout configuration is split into two sections: common configuration and HTTP configuration. Common config is applied to both HTTP and TCP communication. HTTP timeout are only applied when service is marked as http. More on this in protocol support section.

MeshTimeout policy lets you configure multiple timeouts:

  • connectionTimeout
  • idleTimeout
  • http requestTimeout
  • http streamIdleTimeout
  • http maxStreamDuration
  • http maxConnectionDuration

Timeouts explained

Connection timeout

Connection timeout specifies the amount of time DP will wait for a TCP connection to be established.

Idle timeout

For TCP connections idle timeout is the amount of time that the DP will allow a connection to exist with no inbound or outbound activity. On the other hand when connection in HTTP time at which a inbound or outbound connection will be terminated if there are no active streams

HTTP request timeout

Request timeout lets you configure how long the data plane proxy should wait for the full response. In details it spans between the point at which the entire request has been processed by DP and when the response has been completely processed by DP.

HTTP stream idle timeout

Stream idle timeout is the amount of time that the data plane proxy will allow a HTTP/2 stream to exist with no inbound or outbound activity. This timeout is strongly recommended for all requests (not just streaming requests/responses) as it additionally defends against a peer that does not open the stream window once an entire response has been buffered to be sent to a downstream client.

Stream timeouts apply even when you are only using HTTP/1.1 in you services. This is because every connection between data plane proxies is upgraded to HTTP/2.

HTTP max stream duration

Max stream duration is the maximum time that a stream’s lifetime will span. You can use this functionality when you want to reset HTTP request/response streams periodically.

HTTP max connection duration

Max connection duration is the time after which an inbound or outbound connection will be drained and/or closed, starting from when it was first established. If there are no active streams, the connection will be closed. If there are any active streams, the drain sequence will kick-in, and the connection will be force-closed after 5 seconds.

Examples

Simple outbound HTTP configuration

This configuration will be applied to all data plane proxies inside of Mesh.

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTimeout
  3. metadata:
  4. name: timeout-global
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: Mesh
  11. to:
  12. - targetRef:
  13. kind: Mesh
  14. default:
  15. idleTimeout: 20s
  16. connectionTimeout: 2s
  17. http:
  18. requestTimeout: 2s
  1. type: MeshTimeout
  2. name: timeout-global
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: Mesh
  7. to:
  8. - targetRef:
  9. kind: Mesh
  10. default:
  11. idleTimeout: 20s
  12. connectionTimeout: 2s
  13. http:
  14. requestTimeout: 2s

Simple TCP configuration

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTimeout
  3. metadata:
  4. name: tcp-timeout
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: Mesh
  11. to:
  12. - targetRef:
  13. kind: Mesh
  14. default:
  15. idleTimeout: 20s
  16. connectionTimeout: 2s
  1. type: MeshTimeout
  2. name: tcp-timeout
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: Mesh
  7. to:
  8. - targetRef:
  9. kind: Mesh
  10. default:
  11. idleTimeout: 20s
  12. connectionTimeout: 2s

Simple configuration for inbound applied to specific service

This configuration will be applied to backend service inbound.

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTimeout
  3. metadata:
  4. name: inboud-timeout
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshService
  11. name: backend
  12. from:
  13. - targetRef:
  14. kind: Mesh
  15. default:
  16. idleTimeout: 20s
  17. connectionTimeout: 2s
  1. type: MeshTimeout
  2. name: inboud-timeout
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: MeshService
  7. name: backend
  8. from:
  9. - targetRef:
  10. kind: Mesh
  11. default:
  12. idleTimeout: 20s
  13. connectionTimeout: 2s

Full config applied to inbound and outboud of specific service

This timeout configuration will be applied to all inbound connections to frontend and outbound connections from frontend to backend service

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshTimeout
  3. metadata:
  4. name: inboud-timeout
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshService
  11. name: frontend
  12. from:
  13. - targetRef:
  14. kind: Mesh
  15. default:
  16. idleTimeout: 60s
  17. connectionTimeout: 2s
  18. http:
  19. requestTimeout: 10s
  20. streamIdleTimeout: 1h
  21. maxStreamDuration: 30m
  22. maxConnectionDuration: 30m
  23. to:
  24. - targetRef:
  25. kind: MeshService
  26. name: backend
  27. default:
  28. idleTimeout: 60s
  29. connectionTimeout: 1s
  30. http:
  31. requestTimeout: 5s
  32. streamIdleTimeout: 1h
  33. maxStreamDuration: 30m
  34. maxConnectionDuration: 30m
  1. type: MeshTimeout
  2. name: inboud-timeout
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: MeshService
  7. name: frontend
  8. from:
  9. - targetRef:
  10. kind: Mesh
  11. default:
  12. idleTimeout: 60s
  13. connectionTimeout: 2s
  14. http:
  15. requestTimeout: 10s
  16. streamIdleTimeout: 1h
  17. maxStreamDuration: 30m
  18. maxConnectionDuration: 30m
  19. to:
  20. - targetRef:
  21. kind: MeshService
  22. name: backend
  23. default:
  24. idleTimeout: 60s
  25. connectionTimeout: 1s
  26. http:
  27. requestTimeout: 5s
  28. streamIdleTimeout: 1h
  29. maxStreamDuration: 30m
  30. maxConnectionDuration: 30m

Target MeshHTTPRoute

Timeouts like http.requestTimeout and http.streamIdleTimeout are configurable per route. If a MeshHTTPRoute creates routes on the outbound listener of the service then MeshTimeout policy can configure timeouts on these routes.

In the following example the MeshHTTPRoute policy route-to-backend-v2 redirects all requests to /v2* to backend instances with version: v2 tag. MeshTimeout backend-v2 configures timeouts only for requests that are going through route-to-backend-v2 route.

  1. apiVersion: kuma.io/v1alpha1
  2. kind: MeshHTTPRoute
  3. metadata:
  4. name: route-to-backend-v2
  5. namespace: kuma-system
  6. labels:
  7. kuma.io/mesh: default
  8. spec:
  9. targetRef:
  10. kind: MeshService
  11. name: frontend_kuma-demo_svc_8080
  12. to:
  13. - targetRef:
  14. kind: MeshService
  15. name: backend_kuma-demo_svc_3001
  16. rules:
  17. - matches:
  18. - path:
  19. type: PathPrefix
  20. value: "/v2"
  21. default:
  22. backendRef:
  23. - kind: MeshServiceSubset
  24. name: backend_kuma-demo_svc_3001
  25. tags:
  26. version: v2
  1. type: MeshHTTPRoute
  2. name: route-to-backend-v2
  3. mesh: default
  4. spec:
  5. targetRef:
  6. kind: MeshService
  7. name: frontend_kuma-demo_svc_8080
  8. to:
  9. - targetRef:
  10. kind: MeshService
  11. name: backend_kuma-demo_svc_3001
  12. rules:
  13. - matches:
  14. - path:
  15. type: PathPrefix
  16. value: "/v2"
  17. default:
  18. backendRef:
  19. - kind: MeshServiceSubset
  20. name: backend_kuma-demo_svc_3001
  21. tags:
  22. version: v2

Defaults

Propertydefault
idleTimeout1h
connectionTimeout5s
http.requestTimeout15s
http.streamIdleTimeout30m
http.maxStreamDuration0s
http.maxConnectionDuration0s

All policy options