Repository: envoyproxy/gateway

Issue:
Increase number of rules that can be set for rate limiting in backend traffic policy
Currently we can set only 64 rate-limit rules in backend traffic policy. And one HTTPRoute can only have one backend traffic policy currently,

This "64" rule limit is insufficient if the HTTPRoute is supporting request for many paths prefix and each path prefix need there own rate limits. 

In our case we hade backend service called agent and it  had around 17 path prefix like  /health , /transport , /finance etc. each of this had 4 limit.  (1. per day , per user limit, 2. per day , across user limit , 3. per min , per user limit
4. per min , across user limit. ) so I ended up having 84 limits and hit the issue.  
 
```[BackendTrafficPolicy.gateway.envoyproxy.io](http://backendtrafficpolicy.gateway.envoyproxy.io/) "agentic-route-btp" is invalid: [spec.rateLimit.global.rules: Too many: 84: must have at most 64 items.```

please increase this limit  
thanks


Discussion:
@github-actions: This issue has been automatically marked as stale because it has not had activity in the last 30 days.@vamen95: any update here @arkodg: +1 to increasing it to 128

Solution patch:
diff --git a/api/v1alpha1/ratelimit_types.go b/api/v1alpha1/ratelimit_types.go
index acf55c9ca..dee9155c1 100644
--- a/api/v1alpha1/ratelimit_types.go
+++ b/api/v1alpha1/ratelimit_types.go
@@ -49,7 +49,7 @@ type GlobalRateLimit struct {
 	// matches two rules, one rate limited and one not, the final decision will be
 	// to rate limit the request.
 	//
-	// +kubebuilder:validation:MaxItems=64
+	// +kubebuilder:validation:MaxItems=128
 	Rules []RateLimitRule `json:"rules"`
 }
 
diff --git a/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
index 579072a89..1cb740927 100644
--- a/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
+++ b/charts/gateway-crds-helm/templates/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
@@ -1097,7 +1097,7 @@ spec:
                           required:
                           - limit
                           type: object
-                        maxItems: 64
+                        maxItems: 128
                         type: array
                     required:
                     - rules
diff --git a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
index b04848bfa..a70d81672 100644
--- a/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
+++ b/charts/gateway-helm/crds/generated/gateway.envoyproxy.io_backendtrafficpolicies.yaml
@@ -1096,7 +1096,7 @@ spec:
                           required:
                           - limit
                           type: object
-                        maxItems: 64
+                        maxItems: 128
                         type: array
                     required:
                     - rules



Test patch:
diff --git a/test/cel-validation/backendtrafficpolicy_test.go b/test/cel-validation/backendtrafficpolicy_test.go
index 24b36a65b..162fd3240 100644
--- a/test/cel-validation/backendtrafficpolicy_test.go
+++ b/test/cel-validation/backendtrafficpolicy_test.go
@@ -1116,7 +1116,7 @@ func TestBackendTrafficPolicyTarget(t *testing.T) {
 		{
 			desc: "valid count of Global rate limit rules items",
 			mutate: func(btp *egv1a1.BackendTrafficPolicy) {
-				rules := make([]egv1a1.RateLimitRule, 64)
+				rules := make([]egv1a1.RateLimitRule, 128)
 				rule := egv1a1.RateLimitRule{
 					Limit: egv1a1.RateLimitValue{
 						Requests: 10,
@@ -1150,7 +1150,7 @@ func TestBackendTrafficPolicyTarget(t *testing.T) {
 		{
 			desc: "invalid count of Global rate limit rules items",
 			mutate: func(btp *egv1a1.BackendTrafficPolicy) {
-				rules := make([]egv1a1.RateLimitRule, 65)
+				rules := make([]egv1a1.RateLimitRule, 129)
 				rule := egv1a1.RateLimitRule{
 					Limit: egv1a1.RateLimitValue{
 						Requests: 10,
@@ -1180,7 +1180,7 @@ func TestBackendTrafficPolicyTarget(t *testing.T) {
 				}
 			},
 			wantErrors: []string{
-				`[spec.rateLimit.global.rules: Too many: 65: must have at most 64 items, <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation]`,
+				`[spec.rateLimit.global.rules: Too many: 129: must have at most 128 items, <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation]`,
 			},
 		},
 		{
diff --git a/test/helm/gateway-crds-helm/all.out.yaml b/test/helm/gateway-crds-helm/all.out.yaml
index 54318f8cc..7be6cde2b 100644
--- a/test/helm/gateway-crds-helm/all.out.yaml
+++ b/test/helm/gateway-crds-helm/all.out.yaml
@@ -22098,7 +22098,7 @@ spec:
                           required:
                           - limit
                           type: object
-                        maxItems: 64
+                        maxItems: 128
                         type: array
                     required:
                     - rules
diff --git a/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml b/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml
index 4be1eff25..a7fe0eda8 100644
--- a/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml
+++ b/test/helm/gateway-crds-helm/envoy-gateway-crds.out.yaml
@@ -1442,7 +1442,7 @@ spec:
                           required:
                           - limit
                           type: object
-                        maxItems: 64
+                        maxItems: 128
                         type: array
                     required:
                     - rules