From 31ca11db60eadee2f60a67d787f65c5e81b57496 Mon Sep 17 00:00:00 2001 From: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Date: Sun, 23 Aug 2026 21:23:00 -0700 Subject: [PATCH] [Helm] Allow setting extra env vars on the LMCache cache server container Motivation: The LMCache cache server Deployment template had no `env:` block at all, so there was no way to pass any environment variable to the cache-server container via Helm values. This blocks the workaround several users on the OOMKilled report converged on: setting LMCACHE_CACHE_POLICY and LMCACHE_MAX_LOCAL_CPU_SIZE so the cache server evicts old entries instead of growing unbounded until the kernel OOM-kills it. This change does not itself pick an eviction policy or fix the OOM behavior for anyone by default -- it only removes the blocker that made self-configuring LMCache's own eviction knobs impossible through the chart. Approach: Add a `cacheserverSpec.env` values field (default `[]`, fully backward compatible) and render it into the container spec via `{{- with .Values.cacheserverSpec.env }} env: {{- toYaml . | nindent 12 }} {{- end }}`, mirroring the exact `env` pattern already used for `routerSpec.env` / `$container.env` elsewhere in this chart (deployment-router.yaml, deployment-vllm-multi.yaml). Also updated helm/values.schema.json and helm/README.md to document the new field, and extended the existing cacheserver_test.yaml Suite to cover it. Validation: - `helm unittest helm -f 'tests/cacheserver_test.yaml'`: 2/2 pass. - `helm unittest helm` (full suite): 142 passed, 2 failed. Both failures (tests/deployment-vllm-multi_test.yaml asserts[3]; tests/ray-cluster_test.yaml asserts[1..3]) are pre-existing and unrelated -- reproduced identically with this diff stashed out against unmodified main. - `helm lint helm`: passes (only pre-existing unrelated warnings). - `helm template` with no `cacheserverSpec.env` set renders the container with no `env:` key at all, i.e. default behavior is byte-for-byte unchanged. - `helm template --set-json 'cacheserverSpec.env=[{"name":"LMCACHE_CACHE_POLICY","value":"LRU"}]'` renders the env block correctly. - Installed the `helm-values-schema-json` plugin and ran the exact `helm-schema` pre-commit hook this repo's .pre-commit-config.yaml wires up; it passed with zero additional diff, confirming values.schema.json is byte-identical to the tool's own output. - Ran the repo's non-manual pre-commit hooks (check-json, check-yaml, end-of-file-fixer, trailing-whitespace, markdownlint, codespell) on all changed files: all passed. - Could NOT run this repo's live-cluster "Functionality test for helm chart" GitHub Actions jobs (self-hosted minikube runners) -- not available in this sandbox. Mitigated by the default-rendering check above showing this change is purely additive behind an empty-by-default list, so it cannot affect any existing values file used by that workflow. - Base branch CI (`gh run list --branch main --workflow "Functionality test for helm chart"`) is currently green. Report: https://github.com/vllm-project/production-stack/issues/923 Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5 (via Claude Code) --- helm/README.md | 1 + helm/templates/deployment-cache-server.yaml | 4 ++++ helm/tests/cacheserver_test.yaml | 13 +++++++++++++ helm/values.schema.json | 4 ++++ helm/values.yaml | 4 ++++ 5 files changed, 26 insertions(+) diff --git a/helm/README.md b/helm/README.md index 2f865f56b..6270a71ae 100644 --- a/helm/README.md +++ b/helm/README.md @@ -339,6 +339,7 @@ Set `servingEngineSpec.modelSpec[].raySpec.enabled: true` to deploy the model as | `cacheserverSpec.serviceType` | string | `"ClusterIP"` | Kubernetes service type for the cache server | | `cacheserverSpec.servicePort` | integer | `80` | Port the cache server service will listen on | | `cacheserverSpec.resources` | map | `{}` | Resource requests and limits | +| `cacheserverSpec.env` | list | `[]` | Extra environment variables for the cache server container, e.g. to configure LMCache's eviction policy via `LMCACHE_CACHE_POLICY` and `LMCACHE_MAX_LOCAL_CPU_SIZE` | | `cacheserverSpec.labels` | map | `{environment: "cache", release: "cache"}` | Customized labels for the cache server deployment | | `cacheserverSpec.strategy` | map | `{}` | Deployment strategy for the cache server pods | | `cacheserverSpec.livenessProbe` | map | `{initialDelaySeconds: 15, periodSeconds: 10, failureThreshold: 3, httpGet: {path: /health, port: 8000}}` | Configuration for the liveness probe | diff --git a/helm/templates/deployment-cache-server.yaml b/helm/templates/deployment-cache-server.yaml index cbbe613d7..ca5c46d3e 100644 --- a/helm/templates/deployment-cache-server.yaml +++ b/helm/templates/deployment-cache-server.yaml @@ -63,6 +63,10 @@ spec: - "/opt/venv/bin/lmcache_server" - "0.0.0.0" - "{{ .Values.cacheserverSpec.containerPort }}" + {{- with .Values.cacheserverSpec.env }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} {{- with .Values.cacheserverSpec.resources }} resources: {{- toYaml . | nindent 12 }} diff --git a/helm/tests/cacheserver_test.yaml b/helm/tests/cacheserver_test.yaml index 828124b2b..cdd207396 100644 --- a/helm/tests/cacheserver_test.yaml +++ b/helm/tests/cacheserver_test.yaml @@ -36,6 +36,11 @@ tests: requests: cpu: "0.5" memory: "512Mi" + env: + - name: LMCACHE_CACHE_POLICY + value: "LRU" + - name: LMCACHE_MAX_LOCAL_CPU_SIZE + value: "16" annotations: annotation-key: annotation-value labels: @@ -165,6 +170,14 @@ tests: path: spec.template.spec.containers[0].imagePullPolicy value: "Always" + - equal: + path: spec.template.spec.containers[0].env + value: + - name: LMCACHE_CACHE_POLICY + value: "LRU" + - name: LMCACHE_MAX_LOCAL_CPU_SIZE + value: "16" + - equal: path: spec.template.spec.containers[0].livenessProbe value: diff --git a/helm/values.schema.json b/helm/values.schema.json index bae9926ef..a01abeec7 100644 --- a/helm/values.schema.json +++ b/helm/values.schema.json @@ -26,6 +26,10 @@ "description": "Whether to enable the cache server", "type": "boolean" }, + "env": { + "description": "Extra environment variables for the cache server container, e.g. to configure LMCache's eviction policy via `LMCACHE_CACHE_POLICY` and `LMCACHE_MAX_LOCAL_CPU_SIZE` (https://docs.lmcache.ai/api_reference/configurations.html)", + "type": "array" + }, "image": { "description": "Image configuration for the cache Server", "type": "object", diff --git a/helm/values.yaml b/helm/values.yaml index 728cc372a..2f6e6762b 100644 --- a/helm/values.yaml +++ b/helm/values.yaml @@ -814,6 +814,10 @@ cacheserverSpec: serviceAnnotations: {} # -- Resource requests and limits for the cache server container resources: {} + # -- Extra environment variables for the cache server container, e.g. to + # configure LMCache's eviction policy via `LMCACHE_CACHE_POLICY` and + # `LMCACHE_MAX_LOCAL_CPU_SIZE` (https://docs.lmcache.ai/api_reference/configurations.html) + env: [] # -- Customized annotations for the cache server deployment annotations: {} # -- Customized labels for the cache server deployment and service