Retry HTTP requests that fail with 5xx
Use MeshRetry to retry requests from frontend to backend when the destination returns a 5xx or does not respond.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshRetry
metadata:
name: frontend-to-backend-http
namespace: kong-mesh-demo
labels:
kuma.io/mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
default:
http:
numRetries: 3
perTryTimeout: 2s
retryOn:
- 5xx
- ResetCopied!
type: MeshRetry
name: frontend-to-backend-http
mesh: default
spec:
targetRef:
kind: Dataplane
labels:
app: frontend
to:
- targetRef:
kind: MeshService
labels:
kuma.io/display-name: backend
default:
http:
numRetries: 3
perTryTimeout: 2s
retryOn:
- 5xx
- ResetCopied!
Adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_retry" "frontend_to_backend_http" {
provider = konnect-beta
type = "MeshRetry"
name = "frontend-to-backend-http"
spec = {
target_ref = {
kind = "Dataplane"
labels = {
app = "frontend"
}
}
to = [
{
target_ref = {
kind = "MeshService"
labels = {
"kuma.io/display-name" = "backend"
}
}
default = {
http = {
num_retries = 3
per_try_timeout = "2s"
retry_on = [
"5xx",
"Reset"
]
}
}
}
]
}
labels = {
"kuma.io/mesh" = konnect_mesh.my_mesh.name
}
cp_id = konnect_mesh_control_plane.my_meshcontrolplane.id
mesh = konnect_mesh.my_mesh.name
}
Copied!