From f6d65c5b896afb9d071ac2dc854c835bee22b255 Mon Sep 17 00:00:00 2001 From: Alejandro Avagnina Date: Thu, 18 Jan 2024 15:45:19 -0300 Subject: [PATCH] fix: added rate limiting to kong consumer --- operator/src/handlers/auth.rs | 4 +++- operator/src/handlers/mod.rs | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/operator/src/handlers/auth.rs b/operator/src/handlers/auth.rs index 4b1b501..ab25174 100644 --- a/operator/src/handlers/auth.rs +++ b/operator/src/handlers/auth.rs @@ -16,7 +16,8 @@ use std::collections::BTreeMap; use tracing::info; use crate::{ - create_resource, get_config, get_resource, kong_consumer, patch_resource, Error, KupoPort, + create_resource, get_config, get_rate_limit_name, get_resource, kong_consumer, patch_resource, + Error, KupoPort, }; pub async fn handle_auth(client: &Client, crd: &KupoPort) -> Result { @@ -140,6 +141,7 @@ fn build_consumer(crd: &KupoPort) -> Result<(ObjectMeta, JsonValue, JsonValue), "name": build_auth_name(&crd.name_any()), "annotations": { "kubernetes.io/ingress.class": config.ingress_class, + "konghq.com/plugins": get_rate_limit_name(&crd.spec.throughput_tier) }, "ownerReferences": [ { diff --git a/operator/src/handlers/mod.rs b/operator/src/handlers/mod.rs index 0e4a05d..26b9177 100644 --- a/operator/src/handlers/mod.rs +++ b/operator/src/handlers/mod.rs @@ -1 +1,5 @@ pub mod auth; + +pub fn get_rate_limit_name(tier: &str) -> String { + format!("rate-limiting-kupo-tier-{}", tier) +}