Skip to content

feat: add spec.baseUrl to serve marimo under a path prefix - #21

Open
blarghmatey wants to merge 1 commit into
marimo-team:mainfrom
mitodl:feat/base-url
Open

blarghmatey wants to merge 1 commit into
marimo-team:mainfrom
mitodl:feat/base-url

Conversation

@blarghmatey

Copy link
Copy Markdown

Summary

We want to serve several published notebooks from one host, each under its own path (e.g. apps.example.com/<name>/), with the gateway routing each prefix to that notebook's Service. marimo supports this through --base-url. The operator builds the container args itself, though, so the only way to pass that flag today is to replace the marimo container's args wholesale through podOverrides, which means copying the operator's internal paths and auth flags into every CR.

This adds spec.baseUrl, rendered as --base-url=<value> ahead of the notebook path. The CRD pattern (^/.*[^/]$) mirrors marimo's own validator in marimo/_cli/cli_validators.py (it must start with /, must not end with /, and must not be bare /), so a bad value is rejected at admission instead of crash-looping the pod. When the field is unset, the args are unchanged and so is the pod spec hash, so existing notebooks are not recreated after an operator upgrade.

The kubectl plugin is untouched. It port-forwards to the pod directly, so it doesn't need a prefix.

Checklist

  • Any AI-generated code has been reviewed line-by-line by the human PR author.
  • Tests have been added or updated for the changes (where applicable).
  • make lint and make test pass locally (operator).
  • uv run pytest and uv run ty check kubectl_marimo pass locally (plugin). (Not applicable, the plugin is unchanged.)
  • If CRD fields changed, make manifests has been run and generated files are committed.
  • Documentation updated where relevant.

https://claude.ai/code/session_01Mznd5RYgzKGBShstpLnoFQ

A reverse proxy that routes a sub-path of a shared host to a notebook
(e.g. apps.example.com/<name>/) needs marimo started with --base-url,
otherwise asset and websocket URLs resolve against the host root and the
app fails to load. The operator builds the container args itself, so
there was no way to set it short of replacing the args wholesale through
podOverrides.

spec.baseUrl is rendered as --base-url=<value> ahead of the notebook
path. The CRD pattern mirrors marimo's own validator (leading slash, no
trailing slash, not "/"), so a bad value is rejected at admission
instead of crash-looping the pod. Unset, the args and pod spec hash are
unchanged, so existing notebooks are not recreated on upgrade.

Claude-Session: https://claude.ai/code/session_01Mznd5RYgzKGBShstpLnoFQ
Copilot AI balanced review requested due to automatic review settings October 1, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The API, generated schemas, pod construction, tests, and documentation are consistent and complete.

Review effort: Balanced
Findings: None

What changed in this PR

Adds spec.baseUrl so notebooks can be served behind path-prefixed reverse-proxy routes.

Changes:

  • Adds validated CRD/API support for baseUrl.
  • Passes the value to marimo as --base-url.
  • Adds unit/controller tests and architecture documentation.
File Description
api/​v1alpha1/​marimonotebook_types.go Defines the validated API field.
config/​crd/​bases/​marimo.io_marimos.yaml Updates the generated CRD schema.
deploy/​charts/​marimo-operator/​crds/​marimo.io_marimos.yaml Updates the Helm CRD schema.
pkg/​resources/​pod.go Adds the marimo CLI argument.
pkg/​resources/​pod_test.go Tests set and unset behavior.
internal/​controller/​marimonotebook_controller_test.go Tests reconciliation and admission validation.
docs/​ARCHITECTURE.md Documents the new field.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants