From 2c4d25239b66e5a67d5a446344e44040f5368dea Mon Sep 17 00:00:00 2001 From: Jarvis Date: Sun, 15 Nov 2026 21:22:27 +0800 Subject: [PATCH 1/5] docs(aisix): say config.proxy.workers also sizes the token-estimate pool --- charts/aisix/README.md | 2 +- charts/aisix/values.yaml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/charts/aisix/README.md b/charts/aisix/README.md index 9d2d592..acd883e 100644 --- a/charts/aisix/README.md +++ b/charts/aisix/README.md @@ -575,7 +575,7 @@ rejects. New installs set the value in its own key in `values.yaml` or under | config.proxy.request_id.accept_headers | list | `["x-aisix-request-id"]` | Headers a caller may supply its own request id in. Add `x-request-id` only when no proxy in front stamps it | | config.proxy.thread_per_core | bool | `nil` | Thread-per-core serving topology. Null uses the gateway default (on for Linux) | | config.proxy.url_rewrites | list | `[]` | Entry-level URL rewrite rules, first match wins, e.g. `[{name: per-server-mcp, match: "^/mcp-servers/([^/]+)/mcp$", rewrite: "/mcp/$1"}]` | -| config.proxy.workers | int | `nil` | Worker count. Null uses the gateway default | +| config.proxy.workers | int | `nil` | Worker count. Null uses the gateway default (the available CPUs). Also sizes the token-estimate pool, whose threads each hold their own tokenizer copy per encoding they count with (about 40 MiB per thread when both cl100k and o200k are used) | | config.ratelimit.concurrency_ttl_secs | int | `300` | Seconds a concurrency-limit slot is held at most | | config.ratelimit.redis | object | `nil` | Extra settings for the shared rate-limit Redis selected by `rateLimit.backend: redis`, e.g. `{timeout_secs: 2}` or `{mode: cluster, nodes: [...]}`. Same keys as `cache.redis`; the URL comes from `rateLimit.redis`, `username` and `password` go through `configSecrets` | | config.shutdown.min_drain_secs | int | `30` | Seconds the gateway keeps accepting after SIGTERM while `/readyz` reports 503. `terminationGracePeriodSeconds` must cover it | diff --git a/charts/aisix/values.yaml b/charts/aisix/values.yaml index a9c84d1..13ab0e2 100644 --- a/charts/aisix/values.yaml +++ b/charts/aisix/values.yaml @@ -254,7 +254,10 @@ config: # -- (bool) Thread-per-core serving topology. Null uses the gateway default (on # for Linux) thread_per_core: null - # -- (int) Worker count. Null uses the gateway default + # -- (int) Worker count. Null uses the gateway default (the available CPUs). + # Also sizes the token-estimate pool, whose threads each hold their own + # tokenizer copy per encoding they count with (about 40 MiB per thread when + # both cl100k and o200k are used) workers: null # -- Entry-level URL rewrite rules, first match wins, e.g. # `[{name: per-server-mcp, match: "^/mcp-servers/([^/]+)/mcp$", rewrite: "/mcp/$1"}]` From f16d1119df369e551fe06cbd01e615ac0bbb9950 Mon Sep 17 00:00:00 2001 From: Jarvis Date: Sun, 15 Nov 2026 23:31:08 +0800 Subject: [PATCH 2/5] docs(aisix): state measured per-encoding tokenizer memory for config.proxy.workers --- charts/aisix/README.md | 2 +- charts/aisix/values.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/charts/aisix/README.md b/charts/aisix/README.md index acd883e..d6e5fe2 100644 --- a/charts/aisix/README.md +++ b/charts/aisix/README.md @@ -575,7 +575,7 @@ rejects. New installs set the value in its own key in `values.yaml` or under | config.proxy.request_id.accept_headers | list | `["x-aisix-request-id"]` | Headers a caller may supply its own request id in. Add `x-request-id` only when no proxy in front stamps it | | config.proxy.thread_per_core | bool | `nil` | Thread-per-core serving topology. Null uses the gateway default (on for Linux) | | config.proxy.url_rewrites | list | `[]` | Entry-level URL rewrite rules, first match wins, e.g. `[{name: per-server-mcp, match: "^/mcp-servers/([^/]+)/mcp$", rewrite: "/mcp/$1"}]` | -| config.proxy.workers | int | `nil` | Worker count. Null uses the gateway default (the available CPUs). Also sizes the token-estimate pool, whose threads each hold their own tokenizer copy per encoding they count with (about 40 MiB per thread when both cl100k and o200k are used) | +| config.proxy.workers | int | `nil` | Worker count. Null uses the gateway default (the available CPUs). Also sizes the token-estimate pool: one thread per worker, each holding one tokenizer instance per encoding it has counted with (about 17 MiB cl100k, 27 MiB o200k, 39 MiB o200k_harmony) | | config.ratelimit.concurrency_ttl_secs | int | `300` | Seconds a concurrency-limit slot is held at most | | config.ratelimit.redis | object | `nil` | Extra settings for the shared rate-limit Redis selected by `rateLimit.backend: redis`, e.g. `{timeout_secs: 2}` or `{mode: cluster, nodes: [...]}`. Same keys as `cache.redis`; the URL comes from `rateLimit.redis`, `username` and `password` go through `configSecrets` | | config.shutdown.min_drain_secs | int | `30` | Seconds the gateway keeps accepting after SIGTERM while `/readyz` reports 503. `terminationGracePeriodSeconds` must cover it | diff --git a/charts/aisix/values.yaml b/charts/aisix/values.yaml index 13ab0e2..bbfd443 100644 --- a/charts/aisix/values.yaml +++ b/charts/aisix/values.yaml @@ -255,9 +255,9 @@ config: # for Linux) thread_per_core: null # -- (int) Worker count. Null uses the gateway default (the available CPUs). - # Also sizes the token-estimate pool, whose threads each hold their own - # tokenizer copy per encoding they count with (about 40 MiB per thread when - # both cl100k and o200k are used) + # Also sizes the token-estimate pool: one thread per worker, each holding one + # tokenizer instance per encoding it has counted with (about 17 MiB cl100k, + # 27 MiB o200k, 39 MiB o200k_harmony) workers: null # -- Entry-level URL rewrite rules, first match wins, e.g. # `[{name: per-server-mcp, match: "^/mcp-servers/([^/]+)/mcp$", rewrite: "/mcp/$1"}]` From 005f2c040c416d9d7e880cf3edf9d961af5b941a Mon Sep 17 00:00:00 2001 From: Jarvis Date: Thu, 19 Nov 2026 15:12:00 +0800 Subject: [PATCH 3/5] feat(aisix)!: drop default resources and refuse a utilization HPA without the matching request The gateway sizes its token-estimate pool by config.proxy.workers, one thread per worker each holding its own tokenizer (about 17/27/39 MiB resident for cl100k/o200k/o200k_harmony). With workers unset it follows every CPU the pod sees, so the chart's fixed 1Gi memory limit could OOM a pod on a large node. No single CPU or memory figure fits every deployment, so resources now defaults to {} and the operator sets requests and config.proxy.workers. An HPA with a CPU or memory utilization target needs the matching request; the render now fails instead of deploying an HPA that never scales. --- .github/scripts/aisix-render-checks.sh | 10 ++++++++++ charts/aisix/README.md | 19 +++++++++++++----- charts/aisix/README.md.gotmpl | 13 ++++++++++++- charts/aisix/templates/_helpers.tpl | 9 +++++++++ charts/aisix/values.yaml | 27 +++++++++++++------------- 5 files changed, 59 insertions(+), 19 deletions(-) diff --git a/.github/scripts/aisix-render-checks.sh b/.github/scripts/aisix-render-checks.sh index 488829c..a418b18 100644 --- a/.github/scripts/aisix-render-checks.sh +++ b/.github/scripts/aisix-render-checks.sh @@ -106,5 +106,15 @@ check "a dotted key under config is refused" \ refuses "contains a dot" --set 'config.cache\.redis\.password=x' check "configSecrets outside the allow-list is refused" \ refuses "not a credential-bearing setting" --set 'configSecrets.upstream\.timeout_ms.secretName=a' --set 'configSecrets.upstream\.timeout_ms.key=b' +check "the default render sets no resources" \ + query '"resources" not in pod["containers"][0]' +check "a CPU-utilization HPA without resources.requests.cpu is refused" \ + refuses "requires resources.requests.cpu" --set autoscaling.enabled=true +check "a memory-utilization HPA without resources.requests.memory is refused" \ + refuses "requires resources.requests.memory" --set autoscaling.enabled=true --set autoscaling.targetCPUUtilizationPercentage=null --set autoscaling.targetMemoryUtilizationPercentage=80 --set resources.requests.cpu=1 +check "an HPA renders once the matching requests are set" \ + render --set autoscaling.enabled=true --set autoscaling.targetMemoryUtilizationPercentage=80 --set resources.requests.cpu=1 --set resources.requests.memory=1Gi >/dev/null +check "an HPA with only extraMetrics needs no requests" \ + render --set autoscaling.enabled=true --set autoscaling.targetCPUUtilizationPercentage=null --set 'autoscaling.extraMetrics[0].type=Pods' >/dev/null [ "$fails" -eq 0 ] || { echo "$fails render check(s) failed"; exit 1; } diff --git a/charts/aisix/README.md b/charts/aisix/README.md index d6e5fe2..6672aa4 100644 --- a/charts/aisix/README.md +++ b/charts/aisix/README.md @@ -286,9 +286,20 @@ autoscaling: minReplicas: 2 maxReplicas: 20 targetCPUUtilizationPercentage: 70 +resources: + requests: + cpu: "2" + memory: 1Gi +config: + proxy: + workers: 2 ``` -Requires `metrics-server` in the cluster. A replica the autoscaler adds is kept out +Requires `metrics-server` in the cluster. The utilization target is measured +against `resources.requests.cpu`, which the chart does not default, so the render +fails without it (likewise `resources.requests.memory` for a memory target). The +numbers above are placeholders — size them from your own traffic, and keep +`config.proxy.workers` equal to the CPUs you request. A replica the autoscaler adds is kept out of the Service until its readiness probe passes, which happens only after it has loaded its configuration from the control plane — so a scaling event never routes traffic to a gateway that cannot serve it. @@ -575,7 +586,7 @@ rejects. New installs set the value in its own key in `values.yaml` or under | config.proxy.request_id.accept_headers | list | `["x-aisix-request-id"]` | Headers a caller may supply its own request id in. Add `x-request-id` only when no proxy in front stamps it | | config.proxy.thread_per_core | bool | `nil` | Thread-per-core serving topology. Null uses the gateway default (on for Linux) | | config.proxy.url_rewrites | list | `[]` | Entry-level URL rewrite rules, first match wins, e.g. `[{name: per-server-mcp, match: "^/mcp-servers/([^/]+)/mcp$", rewrite: "/mcp/$1"}]` | -| config.proxy.workers | int | `nil` | Worker count. Null uses the gateway default (the available CPUs). Also sizes the token-estimate pool: one thread per worker, each holding one tokenizer instance per encoding it has counted with (about 17 MiB cl100k, 27 MiB o200k, 39 MiB o200k_harmony) | +| config.proxy.workers | int | `nil` | Worker count. No default: null uses the gateway default, every CPU the process sees — the node's, unless a CPU limit caps it. Also sizes the token-estimate pool: one thread per worker, each holding one tokenizer instance per encoding it has counted with (about 17 MiB cl100k, 27 MiB o200k, 39 MiB o200k_harmony resident). Set it to the CPUs allocated to the pod, and size `resources` memory for it | | config.ratelimit.concurrency_ttl_secs | int | `300` | Seconds a concurrency-limit slot is held at most | | config.ratelimit.redis | object | `nil` | Extra settings for the shared rate-limit Redis selected by `rateLimit.backend: redis`, e.g. `{timeout_secs: 2}` or `{mode: cluster, nodes: [...]}`. Same keys as `cache.redis`; the URL comes from `rateLimit.redis`, `username` and `password` go through `configSecrets` | | config.shutdown.min_drain_secs | int | `30` | Seconds the gateway keeps accepting after SIGTERM while `/readyz` reports 503. `terminationGracePeriodSeconds` must cover it | @@ -662,9 +673,7 @@ rejects. New installs set the value in its own key in `values.yaml` or under | readinessProbe.failureThreshold | int | `3` | | | readinessProbe.periodSeconds | int | `3` | | | replicaCount | int | `2` | Number of gateway replicas. Ignored once `autoscaling.enabled` or `keda.enabled` is true — the autoscaler owns the replica count from then on and the Deployment omits `spec.replicas` so `helm upgrade` cannot reset it. | -| resources.limits.memory | string | `"1Gi"` | | -| resources.requests.cpu | string | `"500m"` | | -| resources.requests.memory | string | `"256Mi"` | | +| resources | object | `{}` | | | securityContext.allowPrivilegeEscalation | bool | `false` | | | securityContext.capabilities.add[0] | string | `"NET_BIND_SERVICE"` | | | securityContext.capabilities.drop[0] | string | `"ALL"` | | diff --git a/charts/aisix/README.md.gotmpl b/charts/aisix/README.md.gotmpl index e8c20e5..bbc14c3 100644 --- a/charts/aisix/README.md.gotmpl +++ b/charts/aisix/README.md.gotmpl @@ -280,9 +280,20 @@ autoscaling: minReplicas: 2 maxReplicas: 20 targetCPUUtilizationPercentage: 70 +resources: + requests: + cpu: "2" + memory: 1Gi +config: + proxy: + workers: 2 ``` -Requires `metrics-server` in the cluster. A replica the autoscaler adds is kept out +Requires `metrics-server` in the cluster. The utilization target is measured +against `resources.requests.cpu`, which the chart does not default, so the render +fails without it (likewise `resources.requests.memory` for a memory target). The +numbers above are placeholders — size them from your own traffic, and keep +`config.proxy.workers` equal to the CPUs you request. A replica the autoscaler adds is kept out of the Service until its readiness probe passes, which happens only after it has loaded its configuration from the control plane — so a scaling event never routes traffic to a gateway that cannot serve it. diff --git a/charts/aisix/templates/_helpers.tpl b/charts/aisix/templates/_helpers.tpl index cd5e95a..dda2795 100644 --- a/charts/aisix/templates/_helpers.tpl +++ b/charts/aisix/templates/_helpers.tpl @@ -435,6 +435,15 @@ Reject value combinations that render successfully but cannot run. {{- if and .Values.autoscaling.enabled .Values.keda.enabled }} {{- fail "autoscaling.enabled and keda.enabled are mutually exclusive: two controllers writing spec.replicas fight over the replica count" }} {{- end }} +{{- if .Values.autoscaling.enabled }} +{{- $requests := dig "requests" dict (.Values.resources | default dict) }} +{{- if and .Values.autoscaling.targetCPUUtilizationPercentage (not $requests.cpu) }} +{{- fail "autoscaling.targetCPUUtilizationPercentage requires resources.requests.cpu: utilization is measured against the request, so without one the HorizontalPodAutoscaler never scales. Set resources.requests.cpu, or set autoscaling.targetCPUUtilizationPercentage=null" }} +{{- end }} +{{- if and .Values.autoscaling.targetMemoryUtilizationPercentage (not $requests.memory) }} +{{- fail "autoscaling.targetMemoryUtilizationPercentage requires resources.requests.memory: utilization is measured against the request, so without one the HorizontalPodAutoscaler never scales. Set resources.requests.memory, or set autoscaling.targetMemoryUtilizationPercentage=null" }} +{{- end }} +{{- end }} {{- if and .Values.keda.enabled (not .Values.keda.triggers) }} {{- fail "keda.enabled requires at least one entry in keda.triggers" }} {{- end }} diff --git a/charts/aisix/values.yaml b/charts/aisix/values.yaml index bbfd443..6990f51 100644 --- a/charts/aisix/values.yaml +++ b/charts/aisix/values.yaml @@ -254,10 +254,12 @@ config: # -- (bool) Thread-per-core serving topology. Null uses the gateway default (on # for Linux) thread_per_core: null - # -- (int) Worker count. Null uses the gateway default (the available CPUs). - # Also sizes the token-estimate pool: one thread per worker, each holding one - # tokenizer instance per encoding it has counted with (about 17 MiB cl100k, - # 27 MiB o200k, 39 MiB o200k_harmony) + # -- (int) Worker count. No default: null uses the gateway default, every CPU + # the process sees — the node's, unless a CPU limit caps it. Also sizes the + # token-estimate pool: one thread per worker, each holding one tokenizer + # instance per encoding it has counted with (about 17 MiB cl100k, 27 MiB + # o200k, 39 MiB o200k_harmony resident). Set it to the CPUs allocated to the + # pod, and size `resources` memory for it workers: null # -- Entry-level URL rewrite rules, first match wins, e.g. # `[{name: per-server-mcp, match: "^/mcp-servers/([^/]+)/mcp$", rewrite: "/mcp/$1"}]` @@ -509,15 +511,14 @@ serviceAccount: # -- ServiceAccount annotations annotations: {} -## No CPU limit by default: CFS throttling adds tail latency on a proxy and -## suppresses the very CPU signal the HorizontalPodAutoscaler scales on. The -## CPU *request* is mandatory for CPU-target autoscaling and is set below. -resources: - requests: - cpu: 500m - memory: 256Mi - limits: - memory: 1Gi +## No default requests or limits: neither CPU nor memory has a value that fits +## every deployment — both depend on the cluster and the traffic, and memory +## grows with `config.proxy.workers` (each worker's token-estimate thread holds +## its own tokenizer, see that key). Set `requests` from your own load, and +## `config.proxy.workers` to the CPUs you allocate. A CPU limit throttles the +## proxy under CFS, adding tail latency. Autoscaling on a CPU or memory +## utilization target needs the matching request: the render fails without it. +resources: {} ## The image already runs as uid 10001 and declares it numerically, which is ## what `runAsNonRoot` needs to verify without the uid being repeated here. From af60bc9f3c58cd05afc5718f4f25539c5f7617bb Mon Sep 17 00:00:00 2001 From: Jarvis Date: Thu, 19 Nov 2026 15:12:19 +0800 Subject: [PATCH 4/5] docs(aisix): carry the resources rationale into the generated values table --- charts/aisix/README.md | 2 +- charts/aisix/values.yaml | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/charts/aisix/README.md b/charts/aisix/README.md index 6672aa4..100434d 100644 --- a/charts/aisix/README.md +++ b/charts/aisix/README.md @@ -673,7 +673,7 @@ rejects. New installs set the value in its own key in `values.yaml` or under | readinessProbe.failureThreshold | int | `3` | | | readinessProbe.periodSeconds | int | `3` | | | replicaCount | int | `2` | Number of gateway replicas. Ignored once `autoscaling.enabled` or `keda.enabled` is true — the autoscaler owns the replica count from then on and the Deployment omits `spec.replicas` so `helm upgrade` cannot reset it. | -| resources | object | `{}` | | +| resources | object | `{}` | Gateway container resources. No default requests or limits: neither CPU nor memory has a value that fits every deployment — both depend on the cluster and the traffic, and memory grows with `config.proxy.workers` (each worker's token-estimate thread holds its own tokenizer, see that key). Set `requests` from your own load, and `config.proxy.workers` to the CPUs you allocate. A CPU limit throttles the proxy under CFS, adding tail latency. Autoscaling on a CPU or memory utilization target needs the matching request: the render fails without it. | | securityContext.allowPrivilegeEscalation | bool | `false` | | | securityContext.capabilities.add[0] | string | `"NET_BIND_SERVICE"` | | | securityContext.capabilities.drop[0] | string | `"ALL"` | | diff --git a/charts/aisix/values.yaml b/charts/aisix/values.yaml index 6990f51..88a6d41 100644 --- a/charts/aisix/values.yaml +++ b/charts/aisix/values.yaml @@ -511,13 +511,14 @@ serviceAccount: # -- ServiceAccount annotations annotations: {} -## No default requests or limits: neither CPU nor memory has a value that fits -## every deployment — both depend on the cluster and the traffic, and memory -## grows with `config.proxy.workers` (each worker's token-estimate thread holds -## its own tokenizer, see that key). Set `requests` from your own load, and -## `config.proxy.workers` to the CPUs you allocate. A CPU limit throttles the -## proxy under CFS, adding tail latency. Autoscaling on a CPU or memory -## utilization target needs the matching request: the render fails without it. +# -- Gateway container resources. No default requests or limits: neither CPU +# nor memory has a value that fits every deployment — both depend on the +# cluster and the traffic, and memory +# grows with `config.proxy.workers` (each worker's token-estimate thread holds +# its own tokenizer, see that key). Set `requests` from your own load, and +# `config.proxy.workers` to the CPUs you allocate. A CPU limit throttles the +# proxy under CFS, adding tail latency. Autoscaling on a CPU or memory +# utilization target needs the matching request: the render fails without it. resources: {} ## The image already runs as uid 10001 and declares it numerically, which is From b11edaa6ac4252f0bb06e71799702fb2fdbedaf5 Mon Sep 17 00:00:00 2001 From: Jarvis Date: Thu, 19 Nov 2026 15:20:58 +0800 Subject: [PATCH 5/5] feat(aisix): refuse a KEDA cpu/memory Utilization trigger without the matching request KEDA measures a cpu or memory trigger with metricType Utilization (its default when metricType is omitted) against the container's request, exactly as the chart's own HPA does, so without one the HPA KEDA creates never scales. Also print the result of the render-succeeds checks, which their >/dev/null redirect was silencing. --- .github/scripts/aisix-render-checks.sh | 18 ++++++++++++++++-- charts/aisix/README.md | 5 +++++ charts/aisix/README.md.gotmpl | 5 +++++ charts/aisix/templates/_helpers.tpl | 12 ++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.github/scripts/aisix-render-checks.sh b/.github/scripts/aisix-render-checks.sh index a418b18..fda2bc4 100644 --- a/.github/scripts/aisix-render-checks.sh +++ b/.github/scripts/aisix-render-checks.sh @@ -33,6 +33,8 @@ check() { if "$@"; then echo "ok $what"; else echo "FAIL $what"; fails=$((fails + 1)); fi } +renders() { render "$@" >/dev/null; } + refuses() { local want=$1 shift @@ -113,8 +115,20 @@ check "a CPU-utilization HPA without resources.requests.cpu is refused" \ check "a memory-utilization HPA without resources.requests.memory is refused" \ refuses "requires resources.requests.memory" --set autoscaling.enabled=true --set autoscaling.targetCPUUtilizationPercentage=null --set autoscaling.targetMemoryUtilizationPercentage=80 --set resources.requests.cpu=1 check "an HPA renders once the matching requests are set" \ - render --set autoscaling.enabled=true --set autoscaling.targetMemoryUtilizationPercentage=80 --set resources.requests.cpu=1 --set resources.requests.memory=1Gi >/dev/null + renders --set autoscaling.enabled=true --set autoscaling.targetMemoryUtilizationPercentage=80 --set resources.requests.cpu=1 --set resources.requests.memory=1Gi check "an HPA with only extraMetrics needs no requests" \ - render --set autoscaling.enabled=true --set autoscaling.targetCPUUtilizationPercentage=null --set 'autoscaling.extraMetrics[0].type=Pods' >/dev/null + renders --set autoscaling.enabled=true --set autoscaling.targetCPUUtilizationPercentage=null --set 'autoscaling.extraMetrics[0].type=Pods' +check "a KEDA cpu Utilization trigger without resources.requests.cpu is refused" \ + refuses "requires resources.requests.cpu" --set keda.enabled=true --set autoscaling.enabled=false --set 'keda.triggers[0].type=cpu' --set 'keda.triggers[0].metricType=Utilization' --set 'keda.triggers[0].metadata.value=60' +check "a KEDA memory Utilization trigger without resources.requests.memory is refused" \ + refuses "requires resources.requests.memory" --set keda.enabled=true --set autoscaling.enabled=false --set 'keda.triggers[0].type=memory' --set 'keda.triggers[0].metricType=Utilization' --set 'keda.triggers[0].metadata.value=60' --set resources.requests.cpu=1 +check "a KEDA cpu trigger with metricType omitted counts as Utilization and is refused" \ + refuses "requires resources.requests.cpu" --set keda.enabled=true --set autoscaling.enabled=false --set 'keda.triggers[0].type=cpu' --set 'keda.triggers[0].metadata.value=60' +check "a KEDA cpu AverageValue trigger needs no request" \ + renders --set keda.enabled=true --set autoscaling.enabled=false --set 'keda.triggers[0].type=cpu' --set 'keda.triggers[0].metricType=AverageValue' --set 'keda.triggers[0].metadata.value=500m' +check "KEDA cpu and memory Utilization triggers render once the requests are set" \ + renders --set keda.enabled=true --set autoscaling.enabled=false --set 'keda.triggers[0].type=cpu' --set 'keda.triggers[0].metadata.value=60' --set 'keda.triggers[1].type=memory' --set 'keda.triggers[1].metadata.value=60' --set resources.requests.cpu=1 --set resources.requests.memory=1Gi +check "a KEDA prometheus trigger needs no request" \ + renders --set keda.enabled=true --set autoscaling.enabled=false --set 'keda.triggers[0].type=prometheus' --set 'keda.triggers[0].metadata.serverAddress=http://p:9090' --set 'keda.triggers[0].metadata.query=up' --set 'keda.triggers[0].metadata.threshold=1' [ "$fails" -eq 0 ] || { echo "$fails render check(s) failed"; exit 1; } diff --git a/charts/aisix/README.md b/charts/aisix/README.md index 100434d..fb67854 100644 --- a/charts/aisix/README.md +++ b/charts/aisix/README.md @@ -350,6 +350,11 @@ A streamed request is counted in `aisix_llm_requests_total` when the stream ends, not when it starts, so during a burst of long streams this signal lags by roughly one stream length. The steady-state rate is unaffected. +A KEDA `cpu` or `memory` trigger with `metricType: Utilization` — KEDA's default +when `metricType` is omitted — is measured against the matching +`resources.requests` entry, which the chart does not default, so the render fails +without it. `metricType: AverageValue` needs no request. + `autoscaling` and `keda` are mutually exclusive — enabling both fails the render rather than letting two controllers fight over the replica count. diff --git a/charts/aisix/README.md.gotmpl b/charts/aisix/README.md.gotmpl index bbc14c3..80af289 100644 --- a/charts/aisix/README.md.gotmpl +++ b/charts/aisix/README.md.gotmpl @@ -344,6 +344,11 @@ A streamed request is counted in `aisix_llm_requests_total` when the stream ends, not when it starts, so during a burst of long streams this signal lags by roughly one stream length. The steady-state rate is unaffected. +A KEDA `cpu` or `memory` trigger with `metricType: Utilization` — KEDA's default +when `metricType` is omitted — is measured against the matching +`resources.requests` entry, which the chart does not default, so the render fails +without it. `metricType: AverageValue` needs no request. + `autoscaling` and `keda` are mutually exclusive — enabling both fails the render rather than letting two controllers fight over the replica count. diff --git a/charts/aisix/templates/_helpers.tpl b/charts/aisix/templates/_helpers.tpl index dda2795..3e06728 100644 --- a/charts/aisix/templates/_helpers.tpl +++ b/charts/aisix/templates/_helpers.tpl @@ -447,6 +447,18 @@ Reject value combinations that render successfully but cannot run. {{- if and .Values.keda.enabled (not .Values.keda.triggers) }} {{- fail "keda.enabled requires at least one entry in keda.triggers" }} {{- end }} +{{- if .Values.keda.enabled }} +{{- $requests := dig "requests" dict (.Values.resources | default dict) }} +{{- range .Values.keda.triggers }} +{{- if has (toString .type) (list "cpu" "memory") }} +{{- /* KEDA defaults a resource trigger to Utilization; metadata.type is its deprecated spelling of metricType */}} +{{- $metricType := .metricType | default (dig "type" "" (.metadata | default dict)) | default "Utilization" }} +{{- if and (eq (toString $metricType) "Utilization") (not (get $requests (toString .type))) }} +{{- fail (printf "a keda.triggers %s trigger with metricType Utilization requires resources.requests.%s: utilization is measured against the request, so without one KEDA's HorizontalPodAutoscaler never scales. Set resources.requests.%s, or use metricType: AverageValue" .type .type .type) }} +{{- end }} +{{- end }} +{{- end }} +{{- end }} {{- $config := .Values.config | default dict }} {{- if eq .Values.rateLimit.backend "redis" }} {{- $mode := "single" }}