Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/chart-render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Chart default render

# Fails when a PR changes what the chart renders with only its required
# values set, which is what every existing install gets on upgrade. Optional
# features must leave that render unchanged while they are off. When the change
# is intended (a bug fix, a version bump, a new default), add the
# default-render-change label and the check passes with the diff in its summary.

on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened, labeled, unlabeled]
paths:
- "charts/**"
- "scripts/chart-render-values.yaml"
- "scripts/diff-default-render.sh"

permissions:
contents: read

jobs:
default-render:
name: Default render matches base
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1

- name: Diff default render against base
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
ACCEPTED: ${{ contains(github.event.pull_request.labels.*.name, 'default-render-change') }}
run: |
rc=0
bash scripts/diff-default-render.sh "$BASE_SHA" > render.diff || rc=$?
cat render.diff
{
echo "## Default render"
echo
if [ "$rc" -eq 0 ]; then
echo "Unchanged against the base branch."
else
echo '```diff'
head -n 1000 render.diff
echo '```'
fi
} >> "$GITHUB_STEP_SUMMARY"
if [ "$rc" -eq 2 ]; then
exit 2
fi
if [ "$rc" -eq 1 ] && [ "$ACCEPTED" != "true" ]; then
echo "::error::The default render changed, so every existing install changes on upgrade. If that is intended, add the default-render-change label. If not, gate the change behind a value that is off by default."
exit 1
fi
3 changes: 3 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ jobs:

- name: Lint chart
run: helm lint charts/nebari-llm-serving/

- name: Render examples against the chart
run: bash scripts/check-examples-render.sh
104 changes: 103 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1 +1,103 @@
Contracts are documented in docs/architecture/contracts.md. Changing a contract updates that file in the same PR.
# AGENTS.md

Rules for anyone changing this repo, people and coding agents alike. Reviews
treat a break from a rule here as a blocker, the same as a failing test. If a
rule is wrong for your change, change this file in the same PR and say why.

## Layout

| Path | What it is |
|------|------------|
| `operator/` | The LLMModel operator (Go, kubebuilder). `make test` |
| `key-manager/` | The API key service (Go). `go test ./...` |
| `frontend/` | The key manager SPA (React). `npm test`, `npm run check` |
| `model-downloader/` | The image that pulls model weights into a PVC |
| `charts/nebari-llm-serving/` | The Helm chart that installs the pack |
| `examples/` | Manifests the docs embed and readers copy |
| `docs/` | The docs site (Astro/Starlight). `make docs-test` |
| `dev/` | The local kind cluster and end-to-end scripts |

Before you push a chart or example change, run `make chart-check-examples` and
`make chart-diff-render`. CI runs both.

## Helm chart

**Every namespace comes from the namespace helper.** Each namespaced resource
gets its namespace from `nebari-llm-serving.operatorNamespace`. Never use
`.Release.Namespace` or a hard-coded name. A subchart calls the parent's
helper rather than computing its own: named templates are shared across a
parent and its subcharts, but values are not.

**Whoever creates a namespace deletes it.** When the chart creates the pack's
Namespace, uninstall removes it and everything in it. Never put a keep
annotation on that Namespace. To keep data across an uninstall, the namespace
has to outlive the release: the user creates it and sets
`createNamespace: false`.

**Optional features are off by default and leave the default render
unchanged.** `make chart-diff-render` renders the chart with only its required
values (`scripts/chart-render-values.yaml`) and diffs it against `main`. A
non-empty diff means every existing install changes on upgrade. If that is
intended (a fix, a version bump, a new default), the PR carries the
`default-render-change` label.

**Everything works under `helm template`.** Argo CD installs the pack with
`helm template`, not `helm install`. So:

- no `lookup`, and no `.Release.Revision` or `.Release.IsUpgrade`;
- no message that only `NOTES.txt` carries, because Argo CD never shows it;
- a resource kept on delete carries both `helm.sh/resource-policy: keep` and
`argocd.argoproj.io/sync-options: Delete=false`.

**One-time setup Jobs are ordinary resources, not hooks.** Name each Job with
a hash of its full rendered pod template, so a change to any part of the pod
gives the Job a new name. A Job's pod template is immutable, and a reused name
fails the upgrade. Don't set `ttlSecondsAfterFinished`: Argo CD would recreate
the Job every time it is cleaned up.

**`fullnameOverride` and `nameOverride` name resources.** They don't choose
the namespace.

## Services

**Fail closed.** A service or UI that shows one user's data to another refuses
to start or render without sign-in. A dev mode that turns sign-in off is a
separate, explicit flag, and the service refuses it when an issuer is also
configured.

**"I can't check right now" is a 503 with `Retry-After`, not a 401.** When
the token validator has no keys yet or can't reach the issuer, the request
gets a 503. A 401 tells the client its credentials are bad, and it stops
retrying.

**New UIs sign in at the gateway.** A new UI uses the NebariApp's gateway
sign-in and reads the user from the gateway's headers. Don't add another
browser-side keycloak-js client. The key manager SPA moves to gateway sign-in
in #222.

**Shared code stays shared.** Token validation and API clients that more than
one module needs live in one shared module that each module imports. Don't
copy them into a module.

## Docs and examples

**Contracts are documented in `docs/architecture/contracts.md`.** Changing a
contract updates that file in the same PR.

**A change to a value, default, name or namespace updates the docs in the
same PR.** That means `docs/src/content/docs/configuration.mdx`, every page
that mentions the old behavior, and every example under `examples/`. Search
for the old name and the old default, not only the new one.

**A change that needs action on upgrade gets an entry on the Upgrading page**
(`docs/src/content/docs/upgrading.mdx`, under "Release-specific steps"). A
renamed resource or namespace always needs action: Helm deletes whatever is
missing from the new render.

**Examples render against the chart in the same commit.** `make
chart-check-examples` renders each Argo CD Application's chart values with the
local chart. It checks that the pinned chart version matches `Chart.yaml` and
that `destination.namespace` matches the pack's namespace. A placeholder pin
such as `"<version>"`, for an example that needs a release not yet cut, skips
the version check. A release PR that bumps `Chart.yaml` bumps the examples'
pins with it.
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# nebari-llm-serving-pack
#
# Tasks for the Astro/Starlight documentation site (lives in docs/).
# Run `make help` to list targets.
# Tasks for the Astro/Starlight documentation site (lives in docs/) and
# render checks for the Helm chart. Run `make help` to list targets.
#
# For the local kind dev cluster, see the separate dev/Makefile
# (`cd dev && make help`). For Go tests, see operator/ and key-manager/.

DOCS_DIR := docs

.DEFAULT_GOAL := help
.PHONY: help docs docs-install docs-build docs-preview docs-test docs-check-links
.PHONY: help docs docs-install docs-build docs-preview docs-test docs-check-links chart-check-examples chart-diff-render

help: ## List available targets
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
Expand All @@ -33,3 +33,9 @@ docs-test: ## Run the docs unit tests (vitest)

docs-check-links: ## Build the site and verify every internal link resolves
bash scripts/check-links.sh

chart-check-examples: ## Render every example's chart values against the chart
bash scripts/check-examples-render.sh

chart-diff-render: ## Diff the chart's default render against BASE (default origin/main)
bash scripts/diff-default-render.sh $(or $(BASE),origin/main)
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spec:
# Source 1: LLM serving pack Helm chart
- repoURL: quay.io/nebari/charts
chart: nebari-llm-serving
targetRevision: "0.1.2"
targetRevision: "0.1.4"
helm:
releaseName: nebari-llm-serving
values: |
Expand Down Expand Up @@ -80,8 +80,14 @@ spec:
issuerURL: "https://keycloak.your-cluster.example.com/realms/nebari"
groupsClaim: groups

frontend:
keycloak:
url: "https://keycloak.your-cluster.example.com"

keyManager:
enabled: true
nebariApp:
hostname: "llm-keys.your-cluster.example.com"

# Source 2: LLMModel CRs from your cluster config repo
- repoURL: https://github.com/your-org/your-cluster-config.git
Expand Down
5 changes: 4 additions & 1 deletion docs/src/content/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ spec:
source:
repoURL: quay.io/nebari/charts
chart: nebari-llm-serving
targetRevision: "0.1.2"
targetRevision: "0.1.4"
helm:
releaseName: nebari-llm-serving
values: |
Expand Down Expand Up @@ -1110,6 +1110,9 @@ spec:
oidc:
issuerURL: "https://keycloak.<baseDomain>/realms/nebari"
groupsClaim: groups
frontend:
keycloak:
url: "https://keycloak.<baseDomain>"
keyManager:
enabled: true
nebariApp:
Expand Down
4 changes: 2 additions & 2 deletions docs/test/docs-examples.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,11 @@ describe('manifest reconciliation (NIC source of truth)', () => {
expect(m).not.toMatch(/oci:\/\//);
expect(m).toMatch(/repoURL:\s*docker\.io\/envoyproxy\b/);
});
it('installation.md installs the pack from the published OCI chart (0.1.2)', () => {
it('installation.md installs the pack from the published OCI chart (0.1.4)', () => {
const page = readPage('installation.md');
expect(page).toMatch(/repoURL:\s*quay\.io\/nebari\/charts\b/);
expect(page).toMatch(/chart:\s*nebari-llm-serving\b/);
expect(page).toMatch(/targetRevision:\s*"0\.1\.2"/);
expect(page).toMatch(/targetRevision:\s*"0\.1\.4"/);
expect(page).not.toMatch(/path:\s*charts\/nebari-llm-serving\b/);
expect(page).not.toMatch(/targetRevision:\s*v0\.1\.0-alpha\.9\b/);
});
Expand Down
13 changes: 13 additions & 0 deletions scripts/chart-render-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# chart-render-values.yaml - the smallest values file the chart renders with.
#
# The chart's own defaults leave two values empty that are required, so
# `helm template` on the defaults alone fails. scripts/diff-default-render.sh
# renders the chart with this file and nothing else, so its output is the
# "default render". Set only what the chart requires here: anything more
# hides a change to a default.
frontend:
keycloak:
url: "https://keycloak.example.com"
keyManager:
nebariApp:
hostname: "llm-keys.example.com"
96 changes: 96 additions & 0 deletions scripts/check-examples-render.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
# check-examples-render.sh - Render every example's chart values against the
# chart in this checkout.
#
# Finds each Argo CD Application source under examples/ that installs this
# chart (chart nebari-llm-serving, or a path ending charts/nebari-llm-serving)
# with helm.values, renders the local chart with those values and the source's
# releaseName, and checks that the pack's namespace matches the Application's
# destination.namespace and that a pinned chart version matches Chart.yaml.
# A placeholder pin such as "<version>" (an example for a release not yet
# cut) skips the version check; its values are still rendered.
# A failed render means a reader who copies the example gets a failed sync.
#
# Needs helm and yq (mikefarah v4). Exits 0 on success; exits 1 and lists
# offenders on failure.
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CHART="$REPO_ROOT/charts/nebari-llm-serving"
VERSION="$(yq '.version' "$CHART/Chart.yaml")"
WORK="$(mktemp -d)"
trap 'rm -rf "$WORK"' EXIT

# The release workflow sets these image tags when it publishes the chart, and
# some are empty in this checkout (the OpenMeter images use `required`), so an
# example renders against the local chart as the published one would only with
# them set. They come before the example's values, which still win.
RELEASE_TAGS="$WORK/release-tags.yaml"
echo '{}' > "$RELEASE_TAGS"
while IFS= read -r path; do
[ -n "$path" ] || continue
V="$VERSION" yq -i ".$path = strenv(V)" "$RELEASE_TAGS"
done < <(yq '.jobs.*.with.tag-paths | select(. != null)' "$REPO_ROOT/.github/workflows/release.yaml")

failed=0
checked=0

while IFS= read -r -d '' file; do
rel="${file#"$REPO_ROOT"/}"
# One line per source of this chart with helm values: <doc>\t<source>.
if ! pairs="$(yq eval-all -o=tsv '
select(.kind == "Application") | . as $app | $app.spec.sources // [$app.spec.source]
| to_entries | .[]
| select(.value.chart == "nebari-llm-serving" or ((.value.path // "") | test("charts/nebari-llm-serving/?$")))
| select(.value.helm.values != null)
| [document_index, .key]' "$file" 2> "$WORK/err.txt")"; then
echo "FAIL $rel: yq could not read the file:" >&2
sed 's/^/ /' "$WORK/err.txt" >&2
failed=1
continue
fi
[ -n "$pairs" ] || continue

while IFS=$'\t' read -r doc idx; do
checked=$((checked + 1))
label="$rel (document $doc, source $idx)"
q="select(document_index == $doc) | (.spec.sources // [.spec.source])[$idx]"
yq eval-all "$q | .helm.values" "$file" > "$WORK/values.yaml"
release="$(yq eval-all "$q | .helm.releaseName // \"\"" "$file")"
[ -n "$release" ] || release="$(yq eval-all "select(document_index == $doc) | .metadata.name" "$file")"
dest="$(yq eval-all "select(document_index == $doc) | .spec.destination.namespace // \"\"" "$file")"
pin="$(yq eval-all "$q | select(.chart != null) | .targetRevision // \"\"" "$file")"

if [[ -n "$pin" && "$pin" != "<"*">" && "$pin" != "$VERSION" ]]; then
echo "FAIL $label: pins chart $pin but Chart.yaml is $VERSION" >&2
failed=1
continue
fi

if ! helm template "$release" "$CHART" --namespace "$dest" \
-f "$RELEASE_TAGS" -f "$WORK/values.yaml" > "$WORK/out.yaml" 2> "$WORK/err.txt"; then
echo "FAIL $label: helm template failed:" >&2
sed 's/^/ /' "$WORK/err.txt" >&2
failed=1
continue
fi

# The pack's namespace is the namespace of the operator's Deployment.
ns="$(yq eval-all 'select(.kind == "Deployment" and .metadata.name == "*operator*") | .metadata.namespace' "$WORK/out.yaml" | head -n1)"
if [ "$ns" != "$dest" ]; then
echo "FAIL $label: chart renders the pack into '$ns' but destination.namespace is '$dest'" >&2
failed=1
continue
fi
echo "ok $label"
done <<< "$pairs"
done < <(find "$REPO_ROOT/examples" -name '*.yaml' -print0 | sort -z)

if [ "$checked" -eq 0 ]; then
echo "ERROR: found no example with chart values - the yq query is likely stale." >&2
exit 1
fi
if [ "$failed" -ne 0 ]; then
exit 1
fi
echo "EXAMPLES_OK ($checked rendered)"
Loading
Loading