From 4450331f018c9734ca19fb6fe1e94b2e9d4c8450 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Thu, 12 Nov 2026 10:04:48 +0000 Subject: [PATCH 1/2] fix(k8s): raise the limits that 7 d of use shows are too low Raise the Grafana memory request and limit, the memory limits of the LLM gateway, alloy-metrics and alloy-logs, the CPU limits of the redis_exporter sidecars and node-exporter, and the CPU limit of the roadmap Service. The tests hold the new values. --- k8s/argocd/values.yaml | 4 +- k8s/devops/roadmap-service/deployment.yaml | 4 +- k8s/llm/gateway/deployment.yaml | 5 +- k8s/llm/valkey-devops.yaml | 4 +- k8s/llm/valkey.yaml | 4 +- k8s/monitoring/grafana-values.yaml | 5 +- k8s/monitoring/k8s-monitoring-values.yaml | 10 ++-- .../4991-raise-measured-limits/.openspec.yaml | 3 ++ .../4991-raise-measured-limits/design.md | 18 +++++++ .../4991-raise-measured-limits/proposal.md | 54 +++++++++++++++++++ .../specs/roadmap-service-deployment/spec.md | 12 +++++ .../specs/workload-resource-limits/spec.md | 22 ++++++++ .../4991-raise-measured-limits/tasks.md | 26 +++++++++ tests/ai/benchmark/test_k8s_llm_gateway.py | 2 + tests/commands/k8s/test_k8s.py | 37 ++++++++++++- .../server/routes/test_k8s_roadmap_service.py | 2 +- 16 files changed, 199 insertions(+), 13 deletions(-) create mode 100644 openspec/changes/4991-raise-measured-limits/.openspec.yaml create mode 100644 openspec/changes/4991-raise-measured-limits/design.md create mode 100644 openspec/changes/4991-raise-measured-limits/proposal.md create mode 100644 openspec/changes/4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md create mode 100644 openspec/changes/4991-raise-measured-limits/specs/workload-resource-limits/spec.md create mode 100644 openspec/changes/4991-raise-measured-limits/tasks.md diff --git a/k8s/argocd/values.yaml b/k8s/argocd/values.yaml index 6a8d518aba..51ff794050 100644 --- a/k8s/argocd/values.yaml +++ b/k8s/argocd/values.yaml @@ -91,12 +91,14 @@ redis: tag: 9.1.2-alpine exporter: enabled: true + # The exporter uses about 2m at peak, but CFS throttled it in 57% of the periods of 7 d at a + # 100m limit, and a throttled scrape is slow (#4991). resources: requests: cpu: 10m memory: 16Mi limits: - cpu: 100m + cpu: 500m memory: 64Mi metrics: enabled: true diff --git a/k8s/devops/roadmap-service/deployment.yaml b/k8s/devops/roadmap-service/deployment.yaml index 3979f601c7..7483f07d0e 100644 --- a/k8s/devops/roadmap-service/deployment.yaml +++ b/k8s/devops/roadmap-service/deployment.yaml @@ -131,12 +131,14 @@ spec: # 150 MiB each hour from about 460 MiB, so 1Gi killed the pod after # about 4 hours. #4116 holds the analysis of the leak. #4125 is the # open 6-hour flat check. Revisit the limit when the working set is flat. + # The CPU limit is 2: the container reached 1.00 core at a limit of 1 (#4991). The event + # loop uses one core, so the raise is for the bursts of subprocesses and native threads. resources: requests: cpu: 100m memory: 768Mi limits: - cpu: "1" + cpu: "2" memory: 3Gi volumes: - name: tmp diff --git a/k8s/llm/gateway/deployment.yaml b/k8s/llm/gateway/deployment.yaml index 16a5ba66dd..90eb32b6e8 100644 --- a/k8s/llm/gateway/deployment.yaml +++ b/k8s/llm/gateway/deployment.yaml @@ -117,13 +117,16 @@ spec: mountPath: /tmp - name: migrations-volume mountPath: /var/lib/litellm/migrations + # The working set grows from about 660 to 1330 MiB in 4 days between rollouts, so the + # memory limit is 4Gi (#4991). Do not set MAX_REQUESTS_BEFORE_RESTART: with one uvicorn + # worker and one replica, every model call fails until the container starts again. resources: requests: cpu: 200m memory: 512Mi limits: cpu: 1000m - memory: 2048Mi + memory: 4Gi # The proxy opens its port only after it has applied the migrations, which take longer # on an empty database. This probe holds the other two back for up to ten minutes, so # the kubelet does not kill a pod that is still migrating. diff --git a/k8s/llm/valkey-devops.yaml b/k8s/llm/valkey-devops.yaml index 5e7623bf80..ac484934db 100644 --- a/k8s/llm/valkey-devops.yaml +++ b/k8s/llm/valkey-devops.yaml @@ -130,12 +130,14 @@ spec: - name: metrics containerPort: 9121 protocol: TCP + # The exporter uses 21m or less, but CFS throttled it in more than half of the + # periods of 7 d at a 100m limit, and a throttled scrape is slow (#4991). resources: requests: cpu: 10m memory: 16Mi limits: - cpu: 100m + cpu: 500m memory: 64Mi livenessProbe: httpGet: diff --git a/k8s/llm/valkey.yaml b/k8s/llm/valkey.yaml index ec9020e42f..43ca0b0e44 100644 --- a/k8s/llm/valkey.yaml +++ b/k8s/llm/valkey.yaml @@ -130,12 +130,14 @@ spec: - name: metrics containerPort: 9121 protocol: TCP + # The exporter uses 21m or less, but CFS throttled it in more than half of the + # periods of 7 d at a 100m limit, and a throttled scrape is slow (#4991). resources: requests: cpu: 10m memory: 16Mi limits: - cpu: 100m + cpu: 500m memory: 64Mi livenessProbe: httpGet: diff --git a/k8s/monitoring/grafana-values.yaml b/k8s/monitoring/grafana-values.yaml index c1e6520f45..6e1a64dc9c 100644 --- a/k8s/monitoring/grafana-values.yaml +++ b/k8s/monitoring/grafana-values.yaml @@ -14,13 +14,14 @@ service: port: 80 targetPort: 3000 +# The 7 d peak of the working set was 1014 MiB of a 1024Mi limit (#4991). resources: requests: cpu: 100m - memory: 256Mi + memory: 512Mi limits: cpu: 500m - memory: 1024Mi + memory: 2Gi persistence: enabled: true diff --git a/k8s/monitoring/k8s-monitoring-values.yaml b/k8s/monitoring/k8s-monitoring-values.yaml index 5703ccda77..a5f8a8a23b 100644 --- a/k8s/monitoring/k8s-monitoring-values.yaml +++ b/k8s/monitoring/k8s-monitoring-values.yaml @@ -300,12 +300,14 @@ telemetryServices: - --collector.tcpstat env: DBUS_SYSTEM_BUS_ADDRESS: unix:path=/host/root/run/dbus/system_bus_socket + # CFS throttled node-exporter in 29% of the periods of 7 d at a 200m limit, and the median + # scrape took up to 1.9 s. The CPU limit is 500m (#4991). resources: requests: cpu: 50m memory: 64Mi limits: - cpu: 200m + cpu: 500m memory: 256Mi # ── Collectors ─────────────────────────────────────────────────────────────── @@ -347,13 +349,14 @@ collectors: extra: - name: alloy-wal mountPath: /var/lib/alloy + # The 7 d peak of the working set was 737 MiB, 72% of 1024Mi (#4991). resources: requests: cpu: 100m memory: 256Mi limits: cpu: 1000m - memory: 1024Mi + memory: 1536Mi alloy-singleton: # clusterEvents runs unclustered, so exactly one pod watches and ships the events. presets: @@ -376,13 +379,14 @@ collectors: - host-storage alloy: enableReporting: false + # The 7 d peak of the working set was 342 MiB, 67% of 512Mi, and it rises (#4991). resources: requests: cpu: 50m memory: 128Mi limits: cpu: 500m - memory: 512Mi + memory: 768Mi alloy-profiles: # `privileged` is deprecated in 4.5.2: `root` sets the privileged securityContext, and the eBPF # profiler needs the host PID namespace only, not the host network (#1955). diff --git a/openspec/changes/4991-raise-measured-limits/.openspec.yaml b/openspec/changes/4991-raise-measured-limits/.openspec.yaml new file mode 100644 index 0000000000..0bc22675ad --- /dev/null +++ b/openspec/changes/4991-raise-measured-limits/.openspec.yaml @@ -0,0 +1,3 @@ +schema: spec-driven +created: 2026-11-12 +skip_specs: false diff --git a/openspec/changes/4991-raise-measured-limits/design.md b/openspec/changes/4991-raise-measured-limits/design.md new file mode 100644 index 0000000000..e0108798f4 --- /dev/null +++ b/openspec/changes/4991-raise-measured-limits/design.md @@ -0,0 +1,18 @@ +# Design + +## Decisions + +- **Raise each memory limit to at least 1.5 times the 7 d peak.**: Grafana 2Gi is 2.0 times 1014 MiB, the gateway 4Gi is 3.1 times 1333 MiB (it grows about 170 MiB each day between rollouts), `alloy-metrics` 1536Mi is 2.1 times 737 MiB, and `alloy-logs` 768Mi is 2.2 times 342 MiB, which still rises. +- **Raise the Grafana memory request to 512Mi.**: The working set was 444 MiB at the time of the check, above the old request of 256Mi. The other requests stay, because the scheduler needs no change for them. +- **Raise the exporter CPU limits to 500m and keep the requests.**: The exporters use 2m to 33m, but CFS throttles them in 29% to 69% of the periods, so a short burst at the scrape waits for the next period. 500m lets a scrape burst finish in one period. A limit is not reserved on the node. +- **Raise the CPU limit of the Service to 2.**: The container reached 1.00 core at a limit of 1. The event loop uses one core, so the raise is for the bursts of subprocesses and native threads. +- **Do not set `MAX_REQUESTS_BEFORE_RESTART` on the gateway.**: The gateway runs one uvicorn worker in one replica, so a restart of the worker stops every model call until the container starts again. The comment above `resources` says so. +- **Keep Tempo at 2Gi.**: Its 7 d peak is 76% of the limit. The near-limit rule of #4993 watches it. +- **Hold the new values in the tests that already read these `resources` blocks.**: A later cut of a limit then fails a test. + +## Rejected alternatives + +- **Run KRR first and size every container from it.**: #4992 does that next. The data here already shows that these limits are too low, and Grafana is at 99% of its limit. +- **Remove the CPU limits of the exporters.**: The project sets a CPU limit on every container, and #4992 keeps that rule. +- **Raise the limits with `kubectl patch`.**: Argo CD self-heal reverts it. The live limits read the same values as git. +- **Use `MAX_REQUESTS_BEFORE_RESTART` instead of a higher gateway limit.**: With one worker and one replica, each restart fails every model call in flight. diff --git a/openspec/changes/4991-raise-measured-limits/proposal.md b/openspec/changes/4991-raise-measured-limits/proposal.md new file mode 100644 index 0000000000..f7601adcd5 --- /dev/null +++ b/openspec/changes/4991-raise-measured-limits/proposal.md @@ -0,0 +1,54 @@ +# Proposal + +## Why + +#4991: on 2026-11-12 the owner said that the cluster limits look unnecessarily low. 7 days of Prometheus data show that some memory limits are near the peak use, and that some CPU limits throttle containers that use only a few millicores. Today each limit is fixed only after a kill (#4116, #4149, #2806, #1815, #2391, #4939). This item is rank 1 of the cluster integration plan #4989. + +## What Changes + +- `k8s/monitoring/grafana-values.yaml`: the Grafana memory request goes from 256Mi to 512Mi, and the memory limit from 1024Mi to 2Gi. +- `k8s/llm/gateway/deployment.yaml`: the memory limit of container `litellm` goes from 2048Mi to 4Gi. A comment says why, and says not to set `MAX_REQUESTS_BEFORE_RESTART`. +- `k8s/monitoring/k8s-monitoring-values.yaml`: the memory limit of `alloy-metrics` goes from 1024Mi to 1536Mi, of `alloy-logs` from 512Mi to 768Mi, and the CPU limit of node-exporter from 200m to 500m. +- `k8s/llm/valkey.yaml`, `k8s/llm/valkey-devops.yaml` and `k8s/argocd/values.yaml`: the CPU limit of the redis_exporter sidecars goes from 100m to 500m. +- `k8s/devops/roadmap-service/deployment.yaml`: the CPU limit of container `service` goes from 1 to 2. +- Each changed `resources` block gets a comment with the measured value and #4991. The requests stay, except the Grafana memory request. +- Tempo stays at 2Gi (7 d peak 76%). The near-limit rule of #4993 watches it. +- Tests: `tests/commands/k8s/test_k8s.py`, `tests/ai/benchmark/test_k8s_llm_gateway.py` and `tests/server/routes/test_k8s_roadmap_service.py` hold the new values. +- The change carries spec deltas, because a manifest is observable: the new capability `workload-resource-limits` holds the memory limits and the exporter CPU limits, and `roadmap-service-deployment` changes the CPU limit of its requirement "The Service container has memory for the observed growth". +- The change fits one pull request. +- Rollout: Argo CD syncs the manifests from `main`. Each changed pod restarts once. No ConfigMap key changes. Nobody changes the cluster by hand. + +## Capabilities + +### New Capabilities + +- `workload-resource-limits`: The memory limits have room above the measured peak; the exporter CPU limits do not throttle a scrape + +### Modified Capabilities + +- `roadmap-service-deployment`: The Service container has memory for the observed growth + +## Impact + +- Manifests: `k8s/monitoring/grafana-values.yaml`, `k8s/llm/gateway/deployment.yaml`, `k8s/monitoring/k8s-monitoring-values.yaml`, `k8s/llm/valkey.yaml`, `k8s/llm/valkey-devops.yaml`, `k8s/argocd/values.yaml`, `k8s/devops/roadmap-service/deployment.yaml` +- Tests: `tests/commands/k8s/test_k8s.py`, `tests/ai/benchmark/test_k8s_llm_gateway.py`, `tests/server/routes/test_k8s_roadmap_service.py` +- Scheduling: only the Grafana memory request grows (by 256Mi). Limits are not reserved on a node. Each node had 21 GiB or more of allocatable memory that no running pod requests. + +## Feasibility + +- The values were read again from Prometheus on 2026-11-12, through the Grafana datasource, with no write to the cluster. +- `max_over_time(container_memory_working_set_bytes[7d])` against `kube_pod_container_resource_limits`: Grafana 1014 MiB of 1024 MiB (99%), `litellm` 1333 MiB of 2048 MiB (65%), `alloy-metrics` 737 MiB of 1024 MiB (72%), `alloy-logs` 342 MiB of 512 MiB (67%). +- `increase(container_cpu_cfs_throttled_periods_total[7d]) / increase(container_cpu_cfs_periods_total[7d])`: `redis-exporter` of `valkey` 69%, of `valkey-devops` 52%, the Argo CD exporter (`metrics` of `argocd-redis`) 57%, node-exporter 29%, `service` of `roadmap-service` 8%. The peak 1-minute CPU rate of the exporters is 2m to 21m and of node-exporter 33m. +- The 7 d median scrape takes 0.19 s to 0.46 s for the Valkey exporters, 0.25 s for the Argo CD exporter and up to 1.9 s for node-exporter, against 0.008 s for the Prometheus self scrape. +- `max_over_time(rate(container_cpu_usage_seconds_total{container="service"}[2m])[7d:1m])` is 1.00 core at a limit of 1. +- The live limits match git: `kube_pod_container_resource_limits` reads 1 GiB (Grafana), 2 GiB (`litellm`), 1 GiB (`alloy-metrics`), 512 MiB (`alloy-logs`), 0.1 CPU (each exporter), 0.2 CPU (node-exporter) and 1 CPU (`service`). Argo CD syncs `main` with self-heal, so a change in git is the only change that stays. +- The first run of the changed tests on the base fails for the right reason: `['100m', '100m'] != ['500m', '500m']`, `('768Mi', '3Gi', '100m', '1') != ('768Mi', '3Gi', '100m', '2')`, and the gateway tuple without `4Gi`. +- Documents that name the old values: `git grep` finds only `openspec/specs/roadmap-service-deployment/spec.md` (the CPU limit `1`), which the delta changes. `k8s/README.md` names the memory of the Service, not its CPU limit, and names no limit of the other containers. + +## Existing Tool Considered + +KRR (robusta-dev/krr, MIT) recommends requests and limits from Prometheus history. #4992 adopts it for every container after this item. This item changes only the limits that the 7 d data already shows are too low, so it does not wait for #4992. The Vertical Pod Autoscaler needs a new controller and changes requests in the cluster, but the homelab keeps every request in git (Argo CD with prune and self-heal). The change deletes no internal code. + +## Dependencies + +None. #4993 (workload alerts) and #4992 (KRR) come after this item. diff --git a/openspec/changes/4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md b/openspec/changes/4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md new file mode 100644 index 0000000000..cb1db872c3 --- /dev/null +++ b/openspec/changes/4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md @@ -0,0 +1,12 @@ +## MODIFIED Requirements + +### Requirement: The Service container has memory for the observed growth +Container `service` of `deployment/roadmap-service` SHALL request `768Mi` of memory and limit it to `3Gi`, and SHALL keep the CPU request `100m` with a CPU limit of `2`. The memory limit SHALL be at least 460 MiB plus 10 hours of growth at 150 MiB each hour, so the alert `RoadmapServiceMemoryNearLimit` fires before a kill. The comment above `resources` SHALL say that the memory raise is a stopgap and SHALL link #4116 and #4125. + +#### Scenario: The manifest is read +- **WHEN** `k8s/devops/roadmap-service/deployment.yaml` is read +- **THEN** the resources of container `service` are a memory request of `768Mi`, a memory limit of `3Gi`, a CPU request of `100m` and a CPU limit of `2` + +#### Scenario: The limit is cut +- **WHEN** the memory limit of container `service` is below 460 MiB plus 10 times 150 MiB +- **THEN** the test fails and its message names #4116 diff --git a/openspec/changes/4991-raise-measured-limits/specs/workload-resource-limits/spec.md b/openspec/changes/4991-raise-measured-limits/specs/workload-resource-limits/spec.md new file mode 100644 index 0000000000..97ba3b6b80 --- /dev/null +++ b/openspec/changes/4991-raise-measured-limits/specs/workload-resource-limits/spec.md @@ -0,0 +1,22 @@ +## Purpose +The resource limits of the long-running workloads in the cluster manifests: each limit has room above the peak use that Prometheus measured over 7 days, so the kernel does not kill a container for memory and CFS does not throttle a container that uses only a few millicores. + +## ADDED Requirements + +### Requirement: The memory limits have room above the measured peak +The manifests SHALL give Grafana (`k8s/monitoring/grafana-values.yaml`) a memory request of `512Mi` and a memory limit of `2Gi`, the container `litellm` of `deployment/llm-gateway` (`k8s/llm/gateway/deployment.yaml`) a memory limit of `4Gi`, and the collectors of `k8s/monitoring/k8s-monitoring-values.yaml` the memory limits `1536Mi` (`alloy-metrics`) and `768Mi` (`alloy-logs`). The other requests and limits of these containers SHALL stay. + +#### Scenario: The monitoring manifests are read +- **WHEN** `k8s/monitoring/grafana-values.yaml` and `k8s/monitoring/k8s-monitoring-values.yaml` are read +- **THEN** Grafana requests `100m` of CPU and `512Mi` of memory and limits them to `500m` and `2Gi`, `alloy-metrics` limits its memory to `1536Mi`, and `alloy-logs` limits its memory to `768Mi` + +#### Scenario: The gateway manifest is read +- **WHEN** `k8s/llm/gateway/deployment.yaml` is read +- **THEN** the first container of the Deployment requests `200m` of CPU and limits it to `1000m`, and limits its memory to `4Gi` + +### Requirement: The exporter CPU limits do not throttle a scrape +The `redis-exporter` sidecars of the Deployments `valkey` and `valkey-devops` in `k8s/llm/`, the Valkey exporter of Argo CD (`redis.exporter` in `k8s/argocd/values.yaml`) and node-exporter (`telemetryServices.node-exporter` in `k8s/monitoring/k8s-monitoring-values.yaml`) SHALL have a CPU limit of `500m`. Their CPU requests SHALL stay. + +#### Scenario: The exporter manifests are read +- **WHEN** `k8s/llm/valkey.yaml`, `k8s/llm/valkey-devops.yaml`, `k8s/argocd/values.yaml` and `k8s/monitoring/k8s-monitoring-values.yaml` are read +- **THEN** each of the four exporters has a CPU limit of `500m` diff --git a/openspec/changes/4991-raise-measured-limits/tasks.md b/openspec/changes/4991-raise-measured-limits/tasks.md new file mode 100644 index 0000000000..05285589c7 --- /dev/null +++ b/openspec/changes/4991-raise-measured-limits/tasks.md @@ -0,0 +1,26 @@ +# Tasks + +## 1. Hold the measured limits in the tests + +Kind: other + +Reads: `tests/commands/k8s/test_k8s.py`, `tests/ai/benchmark/test_k8s_llm_gateway.py`, `tests/server/routes/test_k8s_roadmap_service.py`. Changes: `tests/commands/k8s/test_k8s.py`, `tests/ai/benchmark/test_k8s_llm_gateway.py`, `tests/server/routes/test_k8s_roadmap_service.py`. + +- [x] 1.1 In `test_k8s_workload_resource_limits_and_probes`, hold the CPU limit `500m` of the three Valkey exporters and node-exporter, the memory limits `1536Mi` (`alloy-metrics`) and `768Mi` (`alloy-logs`), and the Grafana resources (request `100m` and `512Mi`, limit `500m` and `2Gi`). Hold the gateway memory limit `4Gi` and the Service CPU limit `2`. See the three tests fail on the base + - Verification: `$ uv run devops ci fail-to-pass --base origin/main` + +## 2. Raise the limits in the manifests + +Kind: other + +Reads: `k8s/monitoring/grafana-values.yaml`, `k8s/llm/gateway/deployment.yaml`, `k8s/monitoring/k8s-monitoring-values.yaml`, `k8s/llm/valkey.yaml`, `k8s/llm/valkey-devops.yaml`, `k8s/argocd/values.yaml`, `k8s/devops/roadmap-service/deployment.yaml`. Changes: the same files. + +- [x] 2.1 Set the values of the table of #4991, and write above each changed `resources` block a comment with the measured value and #4991. In the gateway comment, say not to set `MAX_REQUESTS_BEFORE_RESTART` + - Verification: `$ uv run devops ci test tests/commands/k8s/test_k8s.py tests/ai/benchmark/test_k8s_llm_gateway.py tests/server/routes/test_k8s_roadmap_service.py` +- [x] 2.2 Check the rendered manifests and the change + - Verification: `$ uv run devops ci --check --only k8s,openspec` + +## Workflow follow-up + +- Pending a person: 7 d after the merge, read the peak working set against the new limit and the throttled share of each container, and record them in a comment on the pull request. +- #4992 sizes every container with KRR, and #4993 adds the workload alerts. Both come after this item. diff --git a/tests/ai/benchmark/test_k8s_llm_gateway.py b/tests/ai/benchmark/test_k8s_llm_gateway.py index b45b7094be..8fb1bb686b 100644 --- a/tests/ai/benchmark/test_k8s_llm_gateway.py +++ b/tests/ai/benchmark/test_k8s_llm_gateway.py @@ -398,6 +398,7 @@ def test_gateway_deployment_security_and_resources(self) -> None: container["ports"][0]["containerPort"], container["resources"]["requests"]["cpu"], container["resources"]["limits"]["cpu"], + container["resources"]["limits"]["memory"], ) == ( "llm", True, @@ -405,6 +406,7 @@ def test_gateway_deployment_security_and_resources(self) -> None: 4000, "200m", "1000m", + "4Gi", ) def test_gateway_configmap_virtual_models(self) -> None: diff --git a/tests/commands/k8s/test_k8s.py b/tests/commands/k8s/test_k8s.py index 7b7d23de3b..516d618a7d 100644 --- a/tests/commands/k8s/test_k8s.py +++ b/tests/commands/k8s/test_k8s.py @@ -1157,6 +1157,22 @@ def test_k8s_workload_resource_limits_and_probes() -> None: valkey_res = valkey_dep["spec"]["template"]["spec"]["containers"][0]["resources"] assert valkey_res["limits"]["memory"] == "2048Mi" + # The redis_exporter sidecars use 21m or less, but CFS throttled them in 52 to 69% of + # the periods of 7 d at a 100m limit, and a throttled scrape is slow (#4991). + devops_valkey_docs = list( + yaml.safe_load_all( + (REPO_ROOT / "k8s" / "llm" / "valkey-devops.yaml").read_text(encoding="utf-8") + ) + ) + devops_valkey_dep = next(d for d in devops_valkey_docs if d and d.get("kind") == "Deployment") + exporter_cpu_limits = [ + container["resources"]["limits"]["cpu"] + for dep in (valkey_dep, devops_valkey_dep) + for container in dep["spec"]["template"]["spec"]["containers"] + if container["name"] == "redis-exporter" + ] + assert exporter_cpu_limits == ["500m", "500m"] + # 3. Tempo: memory limit >= 2048Mi tempo_values = yaml.safe_load( (REPO_ROOT / "k8s" / "otel" / "tempo-values.yaml").read_text(encoding="utf-8") @@ -1171,6 +1187,7 @@ def test_k8s_workload_resource_limits_and_probes() -> None: assert argo_values["repoServer"]["resources"]["limits"]["memory"] == "4096Mi" assert argo_values["server"]["resources"]["limits"]["memory"] == "1024Mi" assert argo_values["redis"]["resources"]["limits"]["memory"] == "1024Mi" + assert argo_values["redis"]["exporter"]["resources"]["limits"]["cpu"] == "500m" # 6. Open WebUI values: elevated CPU and memory limits webui_values = yaml.safe_load( @@ -1193,7 +1210,9 @@ def test_k8s_workload_resource_limits_and_probes() -> None: assert loki_values["singleBinary"]["resources"]["limits"]["cpu"] == "1000m" assert loki_values["singleBinary"]["resources"]["limits"]["memory"] == "2048Mi" - # 10. K8s monitoring stack values: elevated requests and limits to eliminate OOM kills + # 10. K8s monitoring stack values: elevated requests and limits to eliminate OOM kills, and a + # node-exporter CPU limit that does not throttle the scrape. The Alloy limits are 2 times + # the 7 d peak or more (#4991). k8s_mon_values = yaml.safe_load( (REPO_ROOT / "k8s" / "monitoring" / "k8s-monitoring-values.yaml").read_text( encoding="utf-8" @@ -1202,22 +1221,36 @@ def test_k8s_workload_resource_limits_and_probes() -> None: ksm_res = k8s_mon_values["telemetryServices"]["kube-state-metrics"]["resources"] node_res = k8s_mon_values["telemetryServices"]["node-exporter"]["resources"] alloy_metrics_res = k8s_mon_values["collectors"]["alloy-metrics"]["alloy"]["resources"] + alloy_logs_res = k8s_mon_values["collectors"]["alloy-logs"]["alloy"]["resources"] assert ( ksm_res["requests"]["memory"], ksm_res["limits"]["memory"], node_res["requests"]["memory"], node_res["limits"]["memory"], + node_res["limits"]["cpu"], alloy_metrics_res["requests"]["memory"], alloy_metrics_res["limits"]["memory"], + alloy_logs_res["limits"]["memory"], ) == ( "64Mi", "256Mi", "64Mi", "256Mi", + "500m", "256Mi", - "1024Mi", + "1536Mi", + "768Mi", ) + # Grafana: its 7 d peak was 1014 MiB of a 1024Mi limit (#4991). + grafana_values = yaml.safe_load( + (REPO_ROOT / "k8s" / "monitoring" / "grafana-values.yaml").read_text(encoding="utf-8") + ) + assert grafana_values["resources"] == { + "requests": {"cpu": "100m", "memory": "512Mi"}, + "limits": {"cpu": "500m", "memory": "2Gi"}, + } + # 11. GPU Feature Discovery DaemonSet: Burstable QoS requests and limits gfd_docs = list( yaml.safe_load_all( diff --git a/tests/server/routes/test_k8s_roadmap_service.py b/tests/server/routes/test_k8s_roadmap_service.py index 67f3515314..0a703ad8e4 100644 --- a/tests/server/routes/test_k8s_roadmap_service.py +++ b/tests/server/routes/test_k8s_roadmap_service.py @@ -113,7 +113,7 @@ def test_deployment_memory_is_sized_for_the_observed_growth() -> None: resources["limits"]["memory"], resources["requests"]["cpu"], resources["limits"]["cpu"], - ) == ("768Mi", "3Gi", "100m", "1") + ) == ("768Mi", "3Gi", "100m", "2") assert limit >= needed, ( f"The memory limit {limit // MIB} MiB is below {needed // MIB} MiB, the working set after " f"{HOURS_TO_RUN_BEFORE_A_KILL} hours of growth. Fix the leak (#4116) before you cut the limit." From 72ee0e58197414924b0fd7a81b32c4b34bf2cb93 Mon Sep 17 00:00:00 2001 From: Daniel Petty Date: Thu, 12 Nov 2026 10:10:33 +0000 Subject: [PATCH 2/2] docs(openspec): archive 4991-raise-measured-limits --- .../.openspec.yaml | 0 .../design.md | 0 .../proposal.md | 0 .../specs/roadmap-service-deployment/spec.md | 0 .../specs/workload-resource-limits/spec.md | 0 .../tasks.md | 0 .../specs/roadmap-service-deployment/spec.md | 4 ++-- .../specs/workload-resource-limits/spec.md | 24 +++++++++++++++++++ 8 files changed, 26 insertions(+), 2 deletions(-) rename openspec/changes/{4991-raise-measured-limits => archive/2026-11-12-4991-raise-measured-limits}/.openspec.yaml (100%) rename openspec/changes/{4991-raise-measured-limits => archive/2026-11-12-4991-raise-measured-limits}/design.md (100%) rename openspec/changes/{4991-raise-measured-limits => archive/2026-11-12-4991-raise-measured-limits}/proposal.md (100%) rename openspec/changes/{4991-raise-measured-limits => archive/2026-11-12-4991-raise-measured-limits}/specs/roadmap-service-deployment/spec.md (100%) rename openspec/changes/{4991-raise-measured-limits => archive/2026-11-12-4991-raise-measured-limits}/specs/workload-resource-limits/spec.md (100%) rename openspec/changes/{4991-raise-measured-limits => archive/2026-11-12-4991-raise-measured-limits}/tasks.md (100%) create mode 100644 openspec/specs/workload-resource-limits/spec.md diff --git a/openspec/changes/4991-raise-measured-limits/.openspec.yaml b/openspec/changes/archive/2026-11-12-4991-raise-measured-limits/.openspec.yaml similarity index 100% rename from openspec/changes/4991-raise-measured-limits/.openspec.yaml rename to openspec/changes/archive/2026-11-12-4991-raise-measured-limits/.openspec.yaml diff --git a/openspec/changes/4991-raise-measured-limits/design.md b/openspec/changes/archive/2026-11-12-4991-raise-measured-limits/design.md similarity index 100% rename from openspec/changes/4991-raise-measured-limits/design.md rename to openspec/changes/archive/2026-11-12-4991-raise-measured-limits/design.md diff --git a/openspec/changes/4991-raise-measured-limits/proposal.md b/openspec/changes/archive/2026-11-12-4991-raise-measured-limits/proposal.md similarity index 100% rename from openspec/changes/4991-raise-measured-limits/proposal.md rename to openspec/changes/archive/2026-11-12-4991-raise-measured-limits/proposal.md diff --git a/openspec/changes/4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md b/openspec/changes/archive/2026-11-12-4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md similarity index 100% rename from openspec/changes/4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md rename to openspec/changes/archive/2026-11-12-4991-raise-measured-limits/specs/roadmap-service-deployment/spec.md diff --git a/openspec/changes/4991-raise-measured-limits/specs/workload-resource-limits/spec.md b/openspec/changes/archive/2026-11-12-4991-raise-measured-limits/specs/workload-resource-limits/spec.md similarity index 100% rename from openspec/changes/4991-raise-measured-limits/specs/workload-resource-limits/spec.md rename to openspec/changes/archive/2026-11-12-4991-raise-measured-limits/specs/workload-resource-limits/spec.md diff --git a/openspec/changes/4991-raise-measured-limits/tasks.md b/openspec/changes/archive/2026-11-12-4991-raise-measured-limits/tasks.md similarity index 100% rename from openspec/changes/4991-raise-measured-limits/tasks.md rename to openspec/changes/archive/2026-11-12-4991-raise-measured-limits/tasks.md diff --git a/openspec/specs/roadmap-service-deployment/spec.md b/openspec/specs/roadmap-service-deployment/spec.md index 3ef6b94e45..5c023d4d3d 100644 --- a/openspec/specs/roadmap-service-deployment/spec.md +++ b/openspec/specs/roadmap-service-deployment/spec.md @@ -76,11 +76,11 @@ The ConfigMap template `k8s/devops/configmap.example.yaml` SHALL name `deepseek- - **THEN** they name #4204, the date 2026-11-09, the cost of 0.27 USD for each stage case, and #3874 as the rule to return to ### Requirement: The Service container has memory for the observed growth -Container `service` of `deployment/roadmap-service` SHALL request `768Mi` of memory and limit it to `3Gi`, and SHALL keep the CPU request `100m` and the CPU limit `1`. The memory limit SHALL be at least 460 MiB plus 10 hours of growth at 150 MiB each hour, so the alert `RoadmapServiceMemoryNearLimit` fires before a kill. The comment above `resources` SHALL say that the raise is a stopgap and SHALL link #4116 and #4125. +Container `service` of `deployment/roadmap-service` SHALL request `768Mi` of memory and limit it to `3Gi`, and SHALL keep the CPU request `100m` with a CPU limit of `2`. The memory limit SHALL be at least 460 MiB plus 10 hours of growth at 150 MiB each hour, so the alert `RoadmapServiceMemoryNearLimit` fires before a kill. The comment above `resources` SHALL say that the memory raise is a stopgap and SHALL link #4116 and #4125. #### Scenario: The manifest is read - **WHEN** `k8s/devops/roadmap-service/deployment.yaml` is read -- **THEN** the resources of container `service` are a memory request of `768Mi`, a memory limit of `3Gi`, a CPU request of `100m` and a CPU limit of `1` +- **THEN** the resources of container `service` are a memory request of `768Mi`, a memory limit of `3Gi`, a CPU request of `100m` and a CPU limit of `2` #### Scenario: The limit is cut - **WHEN** the memory limit of container `service` is below 460 MiB plus 10 times 150 MiB diff --git a/openspec/specs/workload-resource-limits/spec.md b/openspec/specs/workload-resource-limits/spec.md new file mode 100644 index 0000000000..4fed38631d --- /dev/null +++ b/openspec/specs/workload-resource-limits/spec.md @@ -0,0 +1,24 @@ +# workload-resource-limits Specification + +## Purpose +The resource limits of the long-running workloads in the cluster manifests: each limit has room above the peak use that Prometheus measured over 7 days, so the kernel does not kill a container for memory and CFS does not throttle a container that uses only a few millicores. + +## Requirements + +### Requirement: The memory limits have room above the measured peak +The manifests SHALL give Grafana (`k8s/monitoring/grafana-values.yaml`) a memory request of `512Mi` and a memory limit of `2Gi`, the container `litellm` of `deployment/llm-gateway` (`k8s/llm/gateway/deployment.yaml`) a memory limit of `4Gi`, and the collectors of `k8s/monitoring/k8s-monitoring-values.yaml` the memory limits `1536Mi` (`alloy-metrics`) and `768Mi` (`alloy-logs`). The other requests and limits of these containers SHALL stay. + +#### Scenario: The monitoring manifests are read +- **WHEN** `k8s/monitoring/grafana-values.yaml` and `k8s/monitoring/k8s-monitoring-values.yaml` are read +- **THEN** Grafana requests `100m` of CPU and `512Mi` of memory and limits them to `500m` and `2Gi`, `alloy-metrics` limits its memory to `1536Mi`, and `alloy-logs` limits its memory to `768Mi` + +#### Scenario: The gateway manifest is read +- **WHEN** `k8s/llm/gateway/deployment.yaml` is read +- **THEN** the first container of the Deployment requests `200m` of CPU and limits it to `1000m`, and limits its memory to `4Gi` + +### Requirement: The exporter CPU limits do not throttle a scrape +The `redis-exporter` sidecars of the Deployments `valkey` and `valkey-devops` in `k8s/llm/`, the Valkey exporter of Argo CD (`redis.exporter` in `k8s/argocd/values.yaml`) and node-exporter (`telemetryServices.node-exporter` in `k8s/monitoring/k8s-monitoring-values.yaml`) SHALL have a CPU limit of `500m`. Their CPU requests SHALL stay. + +#### Scenario: The exporter manifests are read +- **WHEN** `k8s/llm/valkey.yaml`, `k8s/llm/valkey-devops.yaml`, `k8s/argocd/values.yaml` and `k8s/monitoring/k8s-monitoring-values.yaml` are read +- **THEN** each of the four exporters has a CPU limit of `500m`