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
MeshGatewayRoute

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

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

  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

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

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

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

  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

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

Simple configuration for inboud 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_kuma-test_svc_80
  12. from:
  13. - targetRef:
  14. kind: Mesh
  15. default:
  16. idleTimeout: 60s
  17. connectionTimeout: 1s
  18. http:
  19. requestTimeout: 5s

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

  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

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

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: fontend_kuma-test_svc_80
  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_kuma-test_svc_80
  27. default:
  28. idleTimeout: 60s
  29. connectionTimeout: 1s
  30. http:
  31. requestTimeout: 5s
  32. streamIdleTimeout: 1h
  33. maxStreamDuration: 30m
  34. maxConnectionDuration: 30m

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

  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

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

Defaults

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

If you don’t specify from or to section defaults from Timeout policy will be used. This is known bug and will be fixed in the next version.