wso2 / apk

Official Repository for APK distribution
Apache License 2.0
153 stars 92 forks source link

Subscription Rate limit support #2447

Closed Krishanx92 closed 4 weeks ago

Krishanx92 commented 1 month ago

Problem

Subscription Rate Limit Policies define the usage quotas and limits for API consumers. Before consuming an API, consumers must subscribe to it under a specific subscription policy. Currently, APK supports subscribing to APIs but does not support applying subscription policies. As a part of AI Gateway Ratelimit policy we need to bring this to APK

Solution

We suggest leveraging the existing Envoy Rate Limiter-based functionality, which is already implemented for API-Level and Resource-Level policies, to support subscription rate limit policies at the organization level.

apiVersion: cp.wso2.com/v1alpha1 kind: Subscription metadata: name: sample-subscription spec: environment: ** api: name : pizzaAPI version: 1.0.0
subscriptionStatus: UNBLOCKED organization: carbon.super ratelimitRef: name : api-subscription-ratelimit level: org/application

Propose changes to Ratalimit CR

apiVersion: dp.wso2.com/v1alpha1 kind: RateLimitPolicy metadata: name: api-subscription-ratelimit spec: override: Subscription: stopOnQuotaReach: true organization: carbon.super requestCount: requestsPerUnit: 4 unit: Minute burstControl: requestsPerUnit: 4 unit: Minute targetRef: kind: Subscription group: gateway.networking.k8s.io

Krishanx92 commented 1 month ago