diff --git a/adapter/internal/operator/config/webhook/manifests.yaml b/adapter/internal/operator/config/webhook/manifests.yaml index b13c9e7c4..e8cd2e25b 100644 --- a/adapter/internal/operator/config/webhook/manifests.yaml +++ b/adapter/internal/operator/config/webhook/manifests.yaml @@ -204,6 +204,26 @@ webhooks: resources: - interceptorservices sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha3-ratelimitpolicy + failurePolicy: Fail + name: mratelimitpolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - ratelimitpolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: @@ -430,6 +450,26 @@ webhooks: resources: - interceptorservices sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-dp-wso2-com-v1alpha3-ratelimitpolicy + failurePolicy: Fail + name: vratelimitpolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - ratelimitpolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/common-controller/go.mod b/common-controller/go.mod index d5707c7a8..a2b34d9c8 100644 --- a/common-controller/go.mod +++ b/common-controller/go.mod @@ -22,7 +22,7 @@ require ( github.com/pelletier/go-toml v1.9.5 github.com/redis/go-redis/v9 v9.2.1 github.com/wso2/apk/adapter v0.0.0-20231214082511-af2c8b8a19f1 - github.com/wso2/apk/common-go-libs v0.0.0-20240304050809-a382bc6b0d82 + github.com/wso2/apk/common-go-libs v0.0.0-20240923143402-ff7fdb0366f9 google.golang.org/grpc v1.65.0 ) diff --git a/common-controller/internal/operator/config/webhook/manifests.yaml b/common-controller/internal/operator/config/webhook/manifests.yaml index 233b8cad7..d34315615 100644 --- a/common-controller/internal/operator/config/webhook/manifests.yaml +++ b/common-controller/internal/operator/config/webhook/manifests.yaml @@ -204,6 +204,26 @@ webhooks: resources: - interceptorservices sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha3-ratelimitpolicy + failurePolicy: Fail + name: mratelimitpolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - ratelimitpolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: @@ -430,6 +450,26 @@ webhooks: resources: - interceptorservices sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /validate-dp-wso2-com-v1alpha3-ratelimitpolicy + failurePolicy: Fail + name: vratelimitpolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - ratelimitpolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/common-controller/internal/operator/operator.go b/common-controller/internal/operator/operator.go index 6ab3078c6..77684918c 100644 --- a/common-controller/internal/operator/operator.go +++ b/common-controller/internal/operator/operator.go @@ -147,6 +147,11 @@ func InitOperator(metricsConfig config.Metrics) { "Unable to create webhook for Ratelimit, error: %v", err)) } + if err = (&dpv1alpha3.RateLimitPolicy{}).SetupWebhookWithManager(mgr); err != nil { + loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2637, logging.MAJOR, + "Unable to create webhook for Ratelimit, error: %v", err)) + } + if err = (&dpv1alpha3.APIPolicy{}).SetupWebhookWithManager(mgr); err != nil { loggers.LoggerAPKOperator.ErrorC(logging.PrintError(logging.Error2638, logging.MAJOR, "Unable to create webhook for APIPolicy, error: %v", err)) diff --git a/common-go-libs/config/webhook/manifests.yaml b/common-go-libs/config/webhook/manifests.yaml index f4a9f4cd1..34dcc46bd 100644 --- a/common-go-libs/config/webhook/manifests.yaml +++ b/common-go-libs/config/webhook/manifests.yaml @@ -184,6 +184,46 @@ webhooks: resources: - interceptorservices sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha3-ratelimitpolicy + failurePolicy: Fail + name: mratelimitpolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - ratelimitpolicies + sideEffects: None +- admissionReviewVersions: + - v1 + clientConfig: + service: + name: webhook-service + namespace: system + path: /mutate-dp-wso2-com-v1alpha3-ratelimitpolicy + failurePolicy: Fail + name: mratelimitpolicy.kb.io + rules: + - apiGroups: + - dp.wso2.com + apiVersions: + - v1alpha3 + operations: + - CREATE + - UPDATE + resources: + - ratelimitpolicies + sideEffects: None - admissionReviewVersions: - v1 clientConfig: diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml index f254504fd..a33cdac0e 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-mutating-webhook-config.yaml @@ -112,14 +112,14 @@ webhooks: service: name: {{ template "apk-helm.resource.prefix" . }}-common-controller-service namespace: {{ .Release.Namespace }} - path: /mutate-dp-wso2-com-v1alpha1-ratelimitpolicy + path: /mutate-dp-wso2-com-v1alpha3-ratelimitpolicy failurePolicy: Fail name: mratelimitpolicy.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1alpha1 + - v1alpha3 operations: - CREATE - UPDATE diff --git a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml index 3bec9878d..df7f197b7 100644 --- a/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml +++ b/helm-charts/templates/data-plane/gateway-components/common-controller/webhook/adapter-validation-webhook-config.yaml @@ -112,14 +112,14 @@ webhooks: service: name: {{ template "apk-helm.resource.prefix" . }}-common-controller-service namespace: {{ .Release.Namespace }} - path: /validate-dp-wso2-com-v1alpha1-ratelimitpolicy + path: /validate-dp-wso2-com-v1alpha3-ratelimitpolicy failurePolicy: Fail name: vratelimitpolicy.kb.io rules: - apiGroups: - dp.wso2.com apiVersions: - - v1alpha1 + - v1alpha3 operations: - CREATE - UPDATE diff --git a/test/cucumber-tests/CRs/artifacts.yaml b/test/cucumber-tests/CRs/artifacts.yaml index 2bbeb801a..a4a64a574 100644 --- a/test/cucumber-tests/CRs/artifacts.yaml +++ b/test/cucumber-tests/CRs/artifacts.yaml @@ -773,7 +773,7 @@ spec: --- -apiVersion: "dp.wso2.com/v1alpha1" +apiVersion: "dp.wso2.com/v1alpha3" kind: "RateLimitPolicy" metadata: name: "api-subscription-ratelimit" @@ -912,10 +912,30 @@ spec: name: "Semantic Versioning API" version: "v\\d+(\\.\\d+)?" ratelimitRef: - name: api-subscription-ratelimit + name: api--sem-subscription-ratelimit level: application --- +apiVersion: "dp.wso2.com/v1alpha3" +kind: "RateLimitPolicy" +metadata: + name: "api--sem-subscription-ratelimit" +spec: + override: + subscription: + stopOnQuotaReach: true + organization: "default" + requestCount: + requestsPerUnit: 50 + unit: "Minute" + burstControl: + requestsPerUnit: 50 + unit: "Minute" + targetRef: + kind: Subscription + name: "7416c241a121b844392d447f00ff6709cb9c932b" + group: gateway.networking.k8s.io +--- apiVersion: cp.wso2.com/v1alpha2 kind: ApplicationMapping metadata: