Skip to content

Conversation

@bjee19
Copy link
Contributor

@bjee19 bjee19 commented Nov 27, 2025

Proposed changes

Problem: A design is needed for the RateLimitPolicy.

Solution: Create an implementable RateLimitPolicy enhancement proposal.

Closes #4059

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.


@github-actions github-actions bot added the documentation Improvements or additions to documentation label Nov 27, 2025
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.29%. Comparing base (775388b) to head (5855156).
⚠️ Report is 91 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4346      +/-   ##
==========================================
+ Coverage   86.10%   86.29%   +0.18%     
==========================================
  Files         132      132              
  Lines       14342    14859     +517     
  Branches       35       35              
==========================================
+ Hits        12349    12822     +473     
- Misses       1790     1816      +26     
- Partials      203      221      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale Pull requests/issues with no activity label Dec 16, 2025
@bjee19 bjee19 removed the stale Pull requests/issues with no activity label Dec 16, 2025
@bjee19
Copy link
Contributor Author

bjee19 commented Dec 17, 2025

Update: going to be scaling back this design to match more closely whats described in the story. Global rate limiting and Conditional rate limiting will be future work.

@bjee19 bjee19 marked this pull request as ready for review December 17, 2025 23:29
@bjee19 bjee19 requested review from a team as code owners December 17, 2025 23:29
- `Accepted`: Indicates whether the policy has been accepted by the controller. This condition uses the reasons defined in the [PolicyCondition API](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/policy_types.go).
- `Programmed`: Indicates whether the policy configuration has been propagated to the data plane. This helps users understand if their policy changes are active.

Note: The `Programmed` condition is part of the updated GEP-713 specification and should be implemented for this policy. Existing policies (ClientSettingsPolicy, UpstreamSettingsPolicy, ObservabilityPolicy) may not have implemented this condition yet and should be updated in future work.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't yet have an issue to track this for our existing policies, lets make one now while we're thinking about it. I can see us forgetting about this in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

- When a `RateLimitPolicy` is attached to a Gateway, generate a singular `limit_req_zone` directive, unique to that policy and Gateway, at the `http` block, and a `limit_req` directive at each of the `location` blocks generated by Routes attached to the Gateway.
- When a `RateLimitPolicy` is attached to an HTTPRoute or GRPCRoute, generate a singular `limit_req_zone`, unique to that policy and Route, directive at the `http` block, and a `limit_req` directive at each of the `location` blocks generated for the Route.
- When multiple `RateLimitPolicies` are attached to a Gateway, generate a unique `limit_req_zone` for each policy-gateway pair.
- When a `RateLimitPolicy` is attached to a Gateway, and there exists a Route which is attached to that Gateway which also has a `RateLimitPolicy` attached to it, the `location` blocks generated for that Route will have the `limit_req` directive with the Gateway `RateLimitPolicy` zone, and whatever `limit_req` directives generated by the `RateLimitPolicy` attached to the Route.
Copy link
Contributor

@shaun-nx shaun-nx Dec 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this point

It reads it like this for me:
"If a Route has its won RL policy, with its own RL Rate, that is different to the RL rate defined in the RL policy attached to the gateway, the limit_req directives for the location block will use the zone generated by the Gateway's RL policy"

If that's true, that doesn't make sense. It feels like it defeats the purpose of having a custom RL policy at the Route level.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the wording is kind of confusing here, but there will be two limit_req_zones made and two limit_req directives used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also sort of related, but a reason why we don't overwrite a Gateway level policy by attaching a policy at the Route level is related to the gateway api personas. The cluster operator (gateway level) should know their nginx loadbalancer capabilities better than an application developer, meaning the gateway level policy shouldn't be overwritten by one from the route level. And there shouldn't be a way for a route level policy to "cancel" a Gateway level one.

- `Accepted`: Indicates whether the policy has been accepted by the controller. This condition uses the reasons defined in the [PolicyCondition API](https://github.com/kubernetes-sigs/gateway-api/blob/main/apis/v1alpha2/policy_types.go).
- `Programmed`: Indicates whether the policy configuration has been propagated to the data plane. This helps users understand if their policy changes are active.

Note: The `Programmed` condition is part of the updated GEP-713 specification and should be implemented for this policy. Existing policies (ClientSettingsPolicy, UpstreamSettingsPolicy, ObservabilityPolicy) may not have implemented this condition yet and should be updated in future work.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

@sjberman sjberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

Design Rate Limiting

7 participants