Configure on Services
Use MeshHTTPRoute to split an HTTP traffic between different MeshServices.
Configuration
apiVersion: kuma.io/v1alpha1
kind: MeshRateLimit
metadata:
  name: backend-rate-limit
  namespace: kuma-demo
  labels:
    kuma.io/mesh: default
spec:
  targetRef:
    kind: Dataplane
    labels:
      app: backend
  rules:
  - default:
      local:
        http:
          requestRate:
            num: 5
            interval: 10s
          onRateLimit:
            status: 423
            headers:
              set:
              - name: x-kuma-rate-limited
                value: 'true'
Copied!
type: MeshRateLimit
mesh: default
name: backend-rate-limit
spec:
  targetRef:
    kind: Dataplane
    labels:
      app: backend
  rules:
  - default:
      local:
        http:
          requestRate:
            num: 5
            interval: 10s
          onRateLimit:
            status: 423
            headers:
              set:
              - name: x-kuma-rate-limited
                value: 'true'
Copied!
Please adjust konnect_mesh_control_plane.my_meshcontrolplane.id and konnect_mesh.my_mesh.name according to your current configuration.
resource "konnect_mesh_rate_limit" "backend_rate_limit" {
  provider = konnect-beta
  type = "MeshRateLimit"
  name = "backend-rate-limit"
  spec = {
    target_ref = {
      kind = "Dataplane"
      labels = {
        app = "backend"
      }
    }
    rules = [
      {
        default = {
          local = {
            http = {
              request_rate = {
                num = "5"
                interval = "10s"
              }
              on_rate_limit = {
                status = "423"
                headers = {
                  set = [
                    {
                      name = "x-kuma-rate-limited"
                      value = "true"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    ]
  }
  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!
