Skip to content

feat(helm): add Helm chart for mlxcel-server - #3549

Merged
inureyes merged 5 commits into
mainfrom
feature/issue-3486-helm-chart
Nov 28, 2026
Merged

inureyes merged 5 commits into
mainfrom
feature/issue-3486-helm-chart

Conversation

@inureyes

@inureyes inureyes commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds charts/mlxcel, a Helm chart for mlxcel-server on a GPU node, plus a helm-chart CI job. One replica, Recreate, Service, optional Ingress, PDB and ServiceMonitor, PVCs for /models and (optionally) /cache. Three model modes: hf (a download initContainer, the default), pvc (snapshot already under /models) and router (--models-dir, --models-max); other combinations fail rendering with a message naming the value.

Decisions beyond the issue text

  • Default model.source: hf, so a default install works on an empty volume. The server always runs with --offline in model mode: only the initContainer fetches, HF_TOKEN never reaches the server, and --revision goes to the download only (a revision-qualified -m skips the /models store in the resolver).
  • HF_HOME/HF_HUB_CACHE point into /models/.huggingface, closing the feat(docker): add CUDA container image for mlxcel and mlxcel-server #3543 finding that HOME=/cache makes the resolver read /cache/.cache/huggingface/hub before /models without an owner check.
  • MLXCEL_CACHE_DIR=/cache/mlxcel under the trusted root /cache, fsGroup: 65532, fsGroupChangePolicy: OnRootMismatch. No root container and no values switch for one; the container security context is fixed.
  • The download initContainer inherits the server's resources (GPU limit) because the binary links the NVIDIA driver library; kubelet reuses init-container devices for the server.
  • enableServiceLinks: false (a release named mlxcel would inject MLXCEL_* variables), automountServiceAccountToken: false, and extraEnv may not repeat a chart-set name (server-side apply rejects duplicates).
  • Router mode with model.hfToken requires apiKey.existingSecret (the router's POST /models and DELETE /models are open without a key); podSecurityContext rejects uid, gid or fsGroup 0 even with schema validation skipped.
  • Files outside charts/**: a one-line pointer in docs/installation.md, scripts/ci/check_helm_chart.py (template matrix, kubeconform, invariants, rejection cases), scripts/ci/check_helm_chart_kind.sh (restricted Pod Security admission with a negative control), and the record docs/benchmark_results/helm-chart-kind-2026-11-29.md.

kind findings (kind v0.33.0, Kubernetes v1.37.0)

  • emptyDir root 2777 0:65532; kind local-path PVC root 777 0:0 (a hostPath PV, kubelet applies no fsGroup); hand-made local PV root 2775 0:65532.
  • On the local PV, Always relabeled the server-style entries on remount to 2770 dirs and 660 files; OnRootMismatch kept 2700/600. The cache rules refuse group-writable directories and entries below the trusted root, so Always would disable the cache from the second pod on (from the source, not observed with the server).

Changes during review

  • The helm-chart job installs PyYAML with uv pip: the chart-testing action puts a pip-less venv first on PATH, which failed the first CI run.
  • The router API-key requirement and the root-group rejection above came from the security review. The cache guidance in values.yaml and the README now warns against same-uid workloads on the cache volume (they pass the owner checks), not other uids (which can only turn the cache off).

Test plan

  • helm lint --strict (default and every ci/*-values.yaml) and ct lint (chart-testing v3.15.0) pass
  • scripts/ci/check_helm_chart.py passes under Helm 4.3.2 and Helm 3.16.4, kubeconform v0.8.0 strict with the ServiceMonitor CRD schema
  • scripts/ci/check_helm_chart_kind.sh on kind: default (hf), hf, pvc and router releases admitted under enforce=restricted, control pod rejected
  • actionlint 1.7.12 with CI's shellcheck floor
  • helm chart CI job passes (lint, ct lint, kubeconform, kind install under restricted Pod Security)
  • Not validated: any GPU pod (Ready on Qwen3-4B, no cache refusal line, PTX reuse after restart and pod replacement, cold/warm time to Ready), device reuse from initContainer to server, an in-cluster download. No Kubernetes cluster with a GPU was available.

Closes #3486

@inureyes inureyes added status:review Under review type:enhancement New features, capabilities, or significant additions priority:medium Medium priority platform:linux Linux (CUDA / packaging) specific labels Nov 28, 2026
@inureyes

Copy link
Copy Markdown
Member Author

Implementation Review Summary

Intent

Add an in-tree Helm chart for mlxcel-server (issue #3486) that runs with no root container under restricted Pod Security, keeps the PTX cache usable, and cannot have its model swapped through the cache volume.

Findings Addressed

  • The helm-chart CI job failed at its install step: chart-testing-action puts a venv with no pip first on PATH, so python3 -m pip install pyyaml exited. It now uses uv pip install, and the job passes (9dc372c). (HIGH)

Remaining Items

  • Every pod start in hf mode calls the HuggingFace API before the download skips present files, so an HF outage or a cluster with no egress blocks a restart even when the snapshot is already on the PVC. Workaround: switch to model.source: pvc. Worth one README sentence. (MEDIUM)
  • The helm-chart job sits between the "Workflow lint" comment block and the workflow-lint job, so that comment now reads as if it describes the helm job. (LOW)
  • router.modelsDir is not checked to be under /models, the only writable model mount. (LOW)
  • The binary assets check fails on tests/fixtures/audio/speech.flac, which this PR does not touch (it comes from main). (not in scope)

Verification

  • All stated requirements implemented (except the GPU-node criterion, which the PR body lists as not validated)
  • No placeholder/mock code remaining
  • Integrated into project code flow
  • Project conventions followed
  • Existing modules reused where applicable
  • No unintended structural changes
  • Tests pass (helm chart CI job green after the fix)

Checked against the source: /health skips API-key auth (src/server/app.rs), so the probes work when a key is set. With MLXCEL_MODELS_DIR set, no model lookup falls back to /cache, and HF_HUB_CACHE points at /models/.huggingface/hub. The legacy ./models/<basename> lookup resolves inside /models because the image sets no WORKDIR. The router skips dot directories, so it never lists .huggingface. MLXCEL_SHUTDOWN_TIMEOUT is parsed as integer seconds.

@inureyes

Copy link
Copy Markdown
Member Author

Security and Performance Review

Fixed

  • HIGH: in router mode the server exposes POST /models (download any HF repo into /models) and DELETE /models, and router_api_key_auth passes every request when no key is set. With model.hfToken the chart gave the token to that server, so any client reaching the Service or Ingress could spend it. The render now fails for router.enabled + model.hfToken.existingSecret without apiKey.existingSecret; README and a check_helm_chart.py rejection case added (5e0e91f).

Remaining (not auto-fixed)

  • MEDIUM: router mode without any API key still lets in-cluster clients download public repos into the models volume (disk fill) and delete snapshots. Consider requiring apiKey for router mode or saying so in the README.
  • MEDIUM: Ingress, NodePort or LoadBalancer with no API key exposes the API beyond the cluster; only NOTES.txt warns. A render failure with an explicit opt-out value would catch it.
  • MEDIUM: the values.yaml and README cache warning says not to share the cache volume with workloads of "another uid". Per the Rule 2 threat model in jit_module.cpp, another uid can only turn the cache off; a workload running as the same uid passes every owner check and can plant PTX. 65532 is the distroless nonroot default, so the warning should say "any other workload, in particular one running as uid 65532". The podSecurityContext comment describes Rule 1, which does not apply while MLXCEL_CACHE_TRUSTED_ROOT is set.
  • LOW: runAsGroup/fsGroup 0 is blocked only by the schema (--skip-schema-validation bypasses it); mlxcel.validate checks only runAsUser.
  • LOW: kind and kubeconform are downloaded by pinned version without a checksum check, matching the existing actionlint step; the job has contents: read and runs on pull_request, not pull_request_target. The kubeconform CRD schema comes from CRDs-catalog main, so it is not pinned.
  • LOW: the ServiceMonitor sends the bearer token over plain HTTP inside the cluster.

Checked, no issue

  • No values combination produces a root container: the container securityContext is fixed, and the pod runAsUser/runAsNonRoot are validated in the template.
  • HF_HOME/HF_HUB_CACHE under /models close the /cache/.cache/huggingface/hub substitution path. The legacy ./models/<basename> lookup resolves under /models because the image sets no WORKDIR.
  • Secrets reach containers only through secretKeyRef; the chart never renders their values.

Validation: helm lint --strict over the default values and every ci values file, plus scripts/ci/check_helm_chart.py, all pass.

@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 28, 2026
Add charts/mlxcel for running mlxcel-server from the ghcr.io/lablup/mlxcel CUDA image on a GPU node: a single-replica Recreate Deployment, Service, optional Ingress, PDB and ServiceMonitor, and PVCs for the model store and the kernel cache. Model mode is hf (a download initContainer, then the server starts with --offline), pvc (snapshot already under /models), or router (--models-dir, --models-max); invalid combinations fail rendering.

Every container runs as 65532 with fsGroup 65532 and no root step, and the default render is admitted under the restricted Pod Security Standard. The cache stays at /cache/mlxcel under the trusted root /cache, fsGroupChangePolicy defaults to OnRootMismatch because Always made cache entries 660 on remount of a local PV on kind, and HF_HOME/HF_HUB_CACHE point into /models so a writable cache volume cannot substitute the model. Probes use /health with a 30 minute startup budget; terminationGracePeriodSeconds follows the drain timeout plus 15 s.

The helm-chart CI job runs helm lint, ct lint, kubeconform with chart invariant checks (scripts/ci/check_helm_chart.py) and a kind install under restricted Pod Security (scripts/ci/check_helm_chart_kind.sh). Validated locally on kind v0.33.0; no GPU pod was run.

Closes #3486
The helm-chart job failed at its install step on the first CI run: helm/chart-testing-action exports VIRTUAL_ENV and prepends its uv-built venv to PATH, and that venv has no pip, so `python3 -m pip install pyyaml` exited with "No module named pip". Install PyYAML with `uv pip`, which targets the active venv, so check_helm_chart.py runs under the same python3.

Refs #3486
In router mode mlxcel-server serves POST /models (download any HuggingFace repo into the model store) and DELETE /models (remove a stored snapshot), and the router API-key middleware lets every request through when no key is configured. The chart hands model.hfToken to the server container in this mode, so a router install with a token and no apiKey let any client that reaches the Service, or the Ingress, spend the token on gated or private repositories and fill or empty the models volume.

mlxcel.validate now fails the render for router.enabled with model.hfToken.existingSecret and no apiKey.existingSecret. The chart README states the requirement, and check_helm_chart.py gains a failure case for it.

Validated with helm lint --strict over the default and every ci values file, and check_helm_chart.py (kubeconform plus all render and rejection cases).

Refs #3486
The security review pointed out that the cache warning named the wrong adversary: with MLXCEL_CACHE_TRUSTED_ROOT set, another uid that can write the cache volume can only turn the cache off, while a workload running as the same uid (65532 is also the distroless default) passes the owner checks and could plant kernels. values.yaml and the README now say to mount the cache volume into no other workload.

The template now also rejects podSecurityContext.runAsGroup or fsGroup 0 when the schema is skipped, the README notes that hf mode contacts the HuggingFace API on every start, and the helm-chart job moves above the workflow lint comment block it had split from its job.
Add one bullet to the CUDA container image section of docs/installation.md linking charts/mlxcel/README.md, so a reader who has the image and wants to run it on Kubernetes finds the chart. Full publishing docs stay with their own sub-issue.

Validation: helm lint --strict, scripts/ci/check_helm_chart.py, ruff, shellcheck and actionlint all pass on the PR files.

Refs #3486
@inureyes
inureyes force-pushed the feature/issue-3486-helm-chart branch from 8e24f68 to 42becb7 Compare November 28, 2026 23:45
@inureyes
inureyes marked this pull request as ready for review November 28, 2026 23:46
@inureyes
inureyes merged commit 0ecb30f into main Nov 28, 2026
14 of 15 checks passed
@inureyes
inureyes deleted the feature/issue-3486-helm-chart branch November 28, 2026 23:46
inureyes added a commit that referenced this pull request Nov 28, 2026
Resolves the ci.yml conflict with #3549 by keeping both sides: the docker and docker_tags filters and jobs from this branch and the helm_chart filter and helm-chart job from main.
inureyes added a commit that referenced this pull request Nov 30, 2026
Bilingual reports for the eight PRs of epic #3488: #3508 (graceful drain), #3509 (CUDA PTX cache trust), #3530 (ROCm hsaco cache trust), #3540 (NVRTC redistributable headers), #3543 (CUDA container image), #3549 (Helm chart), #3550 (GHCR image publishing) and #3554 (chart OCI publishing and docs).

Each report names what the PR record leaves unvalidated: a real GHCR push, a GPU pod on a cluster, the amd64 and debug images. The HuggingFace cache follow-up is #3570.
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform:linux Linux (CUDA / packaging) specific priority:medium Medium priority status:done Completed type:enhancement New features, capabilities, or significant additions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(helm): Add Helm chart for mlxcel-server

1 participant