Skip to content

Commit

Permalink
fix: added rate limiting to kong consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
avatxus committed Jan 18, 2024
1 parent 3d5e8b0 commit f6d65c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion operator/src/handlers/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Error> {
Expand Down Expand Up @@ -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": [
{
Expand Down
4 changes: 4 additions & 0 deletions operator/src/handlers/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
pub mod auth;

pub fn get_rate_limit_name(tier: &str) -> String {
format!("rate-limiting-kupo-tier-{}", tier)
}

0 comments on commit f6d65c5

Please sign in to comment.