Configure timeouts for all routes in an HTTPRoute.
Change the default route-level timeout of 15 seconds with an HTTPRoute or Gloo Gateway GlooTrafficPolicy. To ensure that your apps are available even if they are temporarily unavailable, you can use timeouts alongside Retries.
notifications
The steps in this section use the Envoy-based kgateway data plane. The steps do not work with the agentgateway data plane.
Configure a timeout for a specific route by using the Kubernetes Gateway API-native configuration in an HTTPRoute or by using Gloo Gateway’s GlooTrafficPolicy. In the following example, you set a timeout of 20 seconds for httpbin’s /headers path. However, no timeout is set along the /anything path.
Create the HTTPRoute with two routes, /headers and /anything, and add an HTTPRoute rule name to each path. You use the rule name later to apply the timeout to a particular route.
Create a GlooTrafficPolicy with your timeout settings and use the targetRefs.sectionName to apply the timeout to a specific HTTPRoute rule. In this example, you apply the policy to the timeout rule that points to the /headers path in your HTTPRoute resource.
Send a request to the httpbin app along the /headers path that you configured a custom timeout for. Verify that the request succeeds and that you see a X-Envoy-Expected-Rq-Timeout-Ms header with the custom timeout of 20 seconds (20000).
Send a request to the httpbin app along the anything path that does not have a custom timeout. Verify that the request succeeds and that you see a X-Envoy-Expected-Rq-Timeout-Ms header with the default timeout of 15 seconds (15000).