Kuadrant / kuadrant-operator

The Operator to install and manage the lifecycle of the Kuadrant components deployments.
Apache License 2.0
39 stars 33 forks source link

Enhance creation of RateLimitPolicy around missing limits. #1024

Closed Boomatang closed 1 week ago

Boomatang commented 1 week ago

Ensure the user can create a ratelimit policy without at least one limit.

closes: #1023

Validate

Try apply the following policies to the installation. They should both fail with different failure messages. Any policy where the name is toystore-*1 should be applied to the cluster.

apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-s1
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  limits: 
    "limit-per-ip":
      rates:
      - limit: 5
        window: '10s'
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-s2
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-s3
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  limits: {} 
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-d1
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  defaults:
    limits: 
      "limit-per-ip":
        rates:
        - limit: 5
          window: '10s'
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-d2
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  defaults: {}
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-d3
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  defaults:
    limits: {}
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-o1
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  overrides:
    limits: 
      "limit-per-ip":
        rates:
        - limit: 5
          window: '10s'
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-o2
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  overrides: {}
---
apiVersion: kuadrant.io/v1
kind: RateLimitPolicy
metadata:
  name: toystore-o3
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: simple-toystore
  overrides:
    limits:  {}
---
Boomatang commented 1 week ago

I miss a integration test (with actual k8s running) in tests/common/ratelimitpolicy/ratelimitpolicy_controller_test.go for the following use cases:

I can add some test no problem.