Compare commits

...

2 commits

Author SHA1 Message Date
bom
d2bf694e4e Implement burst-rate for simple-ingress 2024-05-17 16:02:35 +02:00
bom
dd897c7364 Fix variable names 2024-05-17 16:00:11 +02:00
3 changed files with 9 additions and 8 deletions

View file

@ -31,9 +31,9 @@
[coll cp/map-or-seq?
match-value string?
replace-value cp/str-or-number?]
(clojure.walk/postwalk #(if (and (= (type value-to-match) (type %))
(= value-to-match %))
value-to-replace
(clojure.walk/postwalk #(if (and (= (type match-value) (type %))
(= match-value %))
replace-value
%)
coll))

View file

@ -17,7 +17,7 @@
(s/def ::burst-rate ::int/burst-rate)
(def simple-ingress? (s/keys :req-un [::fqdns ::service-name ::service-port]
:opt-un [::issuer ::average-rate ::ns/namespace]))
:opt-un [::issuer ::average-rate ::burst-rate ::ns/namespace]))
(def ingress? (s/keys :req-un [::fqdns ::app-name ::ingress-name ::service-name ::service-port]
:opt-un [::issuer ::cert-name ::rate-limit-name ::ns/namespace]))
@ -32,7 +32,8 @@
(def default-config
(merge ns/default-config
{:issuer "staging"
:average-rate 10}))
:average-rate 10
:burst-rate 20}))
(defn-spec generate-certificate map?
@ -70,10 +71,10 @@
:rate-limit-name service-name}
default-config
config)
{:keys [average-rate]} final-config]
{:keys [average-rate burst-rate]} final-config]
[(int/generate-certificate final-config)
(int/generate-rate-limit-middleware {:rate-limit-name service-name
:namespace (:namespace final-config)
:average-rate average-rate
:burst-rate average-rate})
:burst-rate burst-rate})
(int/generate-ingress final-config)]))

View file

@ -101,7 +101,7 @@
:kind "Middleware",
:metadata {:name "web-ratelimit"
:namespace "default"},
:spec {:rateLimit {:average 10, :burst 10}}}
:spec {:rateLimit {:average 10, :burst 20}}}
{:apiVersion "networking.k8s.io/v1",
:kind "Ingress",
:metadata