data-ui

Deploying a Data UI Application

From a model that fits on a napkin to a live, TLS-terminated, RBAC-backed web application, with one command.

This document explains everything about how Data UI deployment works: the big picture, the command, every moving part behind it, where the secrets live, how the cert renews itself at 3am while you sleep, and what to do on the rare day something goes sideways. It is written so that a junior programmer can follow along. If you can run a shell command and have seen a YAML file without crying, you are qualified.

Table of Contents

The Big Picture

Most deployment stories involve a wall of YAML you wrote by hand, a wiki page titled “DO NOT TOUCH unless you are Dave,” and a Dave who left the company in 2023. Data UI’s story is shorter: the model is the configuration.

Your model already declares the application’s identity:

(:title "To Do List"
  :name "todos"
  :version "0.1"
  :domain "todo.demo.data-ui.com"
  :repl t
  :types ...)

The deploy pipeline reads those five keys and derives everything from them: the Docker image tag, the Kubernetes namespace, the release directory, the HAProxy backend, the public URL. There is no separate deployment config to drift out of sync with the application, because there is no separate deployment config.

The target environment is deliberately modest: a single machine (the “deploy host”) running a k3d cluster (k3s in Docker), with HAProxy in front terminating TLS. No cloud bill, no managed Kubernetes, no Helm charts. One box, one command. There are now two production sites on that shape — evo-x2 at home and prod-2 on EC2 (see Two Production Sites) — but each site is still one box, and staging, demos, and Model Bank live only on evo-x2.

Source Environments: Three Checkouts

There are exactly three source checkouts, and only the first is ever dirty:

Neither deployment clone lives beneath ~/common-lisp (ASDF’s default source-registry search tree), and neither is a worktree, a copy of a .git, or a second .asd — each is a real clone. /data/data-ui otherwise holds runtime state (profiles, databases, uploaded files, snapshots, credentials, exposure configuration, deploy state); the only source code under it is these two clones. Selection keeps one local branch per upstream (deploy/REMOTE/BRANCH), so switching sources switches branches and never resets one branch across unrelated histories.

deploy MODEL therefore always means: fetch and fast-forward a clean production clone to the selected revision, print the source and the full SHA, then re-execute the production script there for the actual build. DRY_RUN=1 changes none of that (see Dry Runs).

Quick Start

On the deploy host (or any machine with ssh access to it; see Deploying From Another Machine):

cd data-ui
scripts/data-ui deploy todos

That’s it. The output ends with:

Deployed To Do List todos-0.1-6d8f586.
  Source:    public/master @ <full SHA>
  Domain:    https://todo.demo.data-ui.com
  NodePort:  http://172.18.0.2:30303
  Swank:     kubectl -n dataui-todos port-forward deploy/dataui-todos 4005:4005

Open the domain, log in as admin with the password from Secrets, and you are looking at your deployed application. If you’ve been developing against the dev REPL and want the app with its data in production, see First deploy of an app you’ve been developing below.

Requirements:

First deploy of an app you’ve been developing

The one command above assumes the code is already at public/master and an empty database is fine. When you’ve been developing against the dev REPL and want the app with its data in production, the code should already be committed and pushed to private/master (your normal development flow), and then:

scripts/publish-data-ui --prefer-private "SceneBook v0.6: …"  # code reaches public/master
scripts/data-ui deploy scenebook
scripts/data-ui snapshot restore dev-scenebook prd:scenebook  # dev data travels over
scripts/data-ui snapshot save prd-scenebook prd:scenebook     # optional known-good marker

Where the deployed code comes from ($DEPLOY_CHECKOUT)

deploy never builds the checkout you are standing in. It builds the production clone at /data/data-ui/repos/production — a clean, independent git clone (remotes public and private), created by deploy-bootstrap on a fresh host. The path defaults in scripts/lib/checkout.sh and can be overridden per-invocation:

DEPLOY_CHECKOUT=/some/other/clone scripts/data-ui deploy todos

The deploy fetches that clone, fast-forwards it to public/master (or exactly --from REMOTE/BRANCH), refuses a dirty tree, and re-executes the clone’s own scripts/data-ui there for the actual build. Full story: Source Environments.

The Model Bank Deploy button is the same pipeline with one difference: the model. The button’s action hook (:deploy-model) shells out to scripts/data-ui deploy — the production clone is selected, fast-forwarded, and built exactly as above — but the model the user typed into the form is handed over as MODEL_FILE (a unique file under models/local/deploy-incoming/). The engine still comes entirely from the selected revision; the typed model rides into the build context as models/local/<name>.lisp and is never committed — it is promoted to a stable copy in the production clone only after the deploy’s health gates (see VIP Deploys).

Update or take down a deployed app

scripts/data-ui deploy todos         # update to the latest public/master
scripts/data-ui deploy todos --from private/master
scripts/data-ui delete todos         # take down the app (asks; FORCE=1 skips)

Update is the same command as the first deploy: publish the new code (scripts/publish-data-ui), run deploy again, and the clone is fast-forwarded, a new image is built and rolled out, and the instance keeps its database and uploaded files. A bad release is fixed by a revert commit on the upstream followed by another deploy — never by selecting an old tag (see Selection, Locks, and Rollback). delete first saves a farewell snapshot of the instance’s last state (prd-todos-last in the snapshot pool), then removes the Kubernetes namespace and volumes, the host-side application data, the HAProxy route, and the deploy state and secrets.

Demos

A demo is not a Docker deploy but a host profile: a dataui@<profile> systemd unit running SBCL directly on the deploy host, loading code from the staging checkout (/data/data-ui/repos/staging), with its own PostgreSQL and uploaded files. All demos share the one engine checkout; the only per-demo things are profile.env, the database, and files/. The model must be committed and pushed to private (staging’s default source — publish-data-ui is not needed) and delivered by staging update before profile create can see it; a local-only model is delivered instead by profile install-model <model> from the development checkout. Two classes share the same machinery: e-demos, whose data is disposable and reset nightly, and persistent demos, which keep their data. Verb reference: docs/cli.md → e-demo / demo; host machinery: ops/README.md; snapshot slots: docs/snapshots.md; user-facing walkthroughs of the live apps: docs/demos.md.

E-demos

Ephemeral: every morning at 04:10 the nightly reset restores the profile’s stg-<profile>-golden snapshot, wiping the day’s accounts, junk rows, and uploads. Until a golden exists the reset skips the profile (bootstrap window) — so take the golden right after seeding the demo content.

git push private master                 # the model must reach staging's source
scripts/data-ui staging update          # fast-forward staging, restart running demos
scripts/data-ui profile create todos    # ports + secrets (prints admin password)
scripts/data-ui e-demo start todos      # start; enrolls in the nightly reset

# After you've added data
scripts/data-ui snapshot save stg-todos-golden stg:todos

# Makes it visible to the world at the host name specified by the model's
# :domain-stg key.
scripts/data-ui profile expose todos 

Update is staging update again — it rebuilds the frontend and restarts every active demo on the new code, health-gated; demo data is untouched. Delete is e-demo stop todos (saves stg-todos-last first), then profile delete todos (asks; FORCE=1 skips).

Persistent demos

Same verbs with demo in place of e-demo, same machinery — the only difference is class: no nightly reset, and the golden stays a manual safety copy. demo reset <profile> restores the golden on demand. Model Bank is the persistent-class example.

What deploy Actually Does, Step by Step

scripts/data-ui deploy runs the following phases, in order. Each phase is a shell function in scripts/data-ui, so the script is the authoritative reference; this is the guided tour. (Phase 0, before all of these: the outer arm selects the production checkout and re-executes its script — see Source Environments; what follows is the inner, production-side body.)

Immediately before the compile gate (and only when the compile runs — a registry hit or a recorded release skips this along with the compile), the deploy fast-forwards the Roswell local-projects clones under ~/.roswell/local-projects/macnod/ — the second source stratum, which the host-side compile resolves :rbac, :p-log, and the other macnod libraries through on a host without a ~/common-lisp dev tree (prod-2; on evo-x2 the dev tree masks the clones, and the refresh is hygiene). The repo list is parsed from the checkout Dockerfile’s ros install lines, in file order. Per repo:

1. Compile the model (the gate)

compile_model

Before anything ships, the model in models/<model-name>.lisp must compile. The script starts a throwaway PostgreSQL container (its own container name and port 5446, so it never collides with your dev REPL database on 5444 or the test database on 5445), initializes the schema, and runs the compilation phase of set-model (validation, SQL generation, lambda compilation) against it. Then the container and its volume are destroyed.

If the model doesn’t compile, the deploy dies right here, before a tag, an image, or a manifest exists. A broken model never gets anywhere near the cluster.

2. Read identity from the model

gather_deploy_facts

The script asks the model for its :name, :title, :version, :domain, and :repl values (via a tiny Lisp helper, lisp/deployment.lisp). From those plus the git short hash, it derives:

Fact Example
TAG todos-0.1-6d8f586
IMAGE macnod/data-ui:todos-0.1-6d8f586
NAMESPACE dataui-todos
RELEASE_NAME To Do List todos-0.1-6d8f586
OUT_DIR /data/data-ui/deploy/todos/releases/0.1-6d8f586

3. Tag the release

create_deploy_tag

An annotated git tag (todos-0.1-6d8f586) is created at HEAD. If the tag already exists and points at HEAD, it is reused (re-deploying the same commit is fine). If it exists and points elsewhere, the deploy aborts: a tag must never silently change meaning.

4. Allocate a NodePort

assign_node_port

Each instance gets a stable NodePort (starting at 30303; 30300–30302 are reserved for k3d’s published loopback hops). The assignment is cached in /data/data-ui/deploy/ports.lock, but the cache is not the source of truth; the cluster is. If the lock file is missing, the port is recovered from the live Service. Only when neither exists is a new port assigned (lowest free port ≥ 30303, checked against both the lock file and every NodePort in the cluster).

5. Ensure instance secrets

ensure_instance_secrets

See Secrets. Same cache-vs-truth design: file missing → recover from the live Kubernetes Secret; no live Secret either → generate fresh credentials. Credentials are never regenerated for an existing instance, because the PostgreSQL volume keeps the old password and new credentials would lock the app out of its own database.

6. Render the manifests

generate_manifests

The templates in deploy/templates/*.yaml.tpl are rendered with plain sed substitution of ``: no templating engine, no dependencies, nothing to install. Two special cases:

Rendered manifests land in the release directory (OUT_DIR above), so every release’s exact manifests are preserved for inspection or rollback.

7. Build and import the image

build_image

A multi-stage Docker build:

The image is then imported into the k3d cluster with k3d image import, so nothing leaves the machine. On evo-x2 (no IMAGE_REGISTRY) that is the whole story and no registry is involved. On prod-2 the registry path wraps the same steps: before the compile, a probe pulls the content-addressed image from ECR (data-ui/<app>:deploy-<arch>-<git sha>-<model sha256>) — a hit skips the compile and the build (only the k3d import runs); a miss builds exactly as above and pushes the image back as a best-effort cache fill (a push failure warns, never fails the deploy; REBUILD=1 force-builds and re-pushes over the same tag).

8. Apply the manifests

apply_manifests

kubectl apply -f $OUT_DIR, then wait for the PostgreSQL rollout, then the app rollout. First boot initializes the database (RBAC tables, roles, permissions, admin/guest users), which is why the app’s startupProbe allows up to five minutes before the liveness probe is allowed to have opinions.

9. Update HAProxy

update_haproxy

The only step that needs sudo. Details in How HAProxy Routing Works.

The Model Drives Everything

Worth repeating with the actual flow drawn out:

models/<model-name>.lisp
    :name "todos" ──────────┬─→ namespace  dataui-todos
    :version "0.1" ────────┼─→ tag        todos-0.1-<git-hash>
    :domain "todo.demo..." ┼─→ HAProxy map entry + backend
    :repl t ───────────────┴─→ Swank port in the manifest (or not)

Change :domain in the model and redeploy: the new domain routes to the app. Bump :version: new tag, new release directory. Set :repl nil: the Swank listener vanishes from the deployment. The model is not input to the configuration; it is the configuration.

(Note the TODO in the example model: :repl should be nil in production. The Swank port is never exposed through a Service either way; it is reachable only via kubectl port-forward, which requires cluster credentials.)

Environments

An environment is where a running instance lives. There are three: development, staging, and production. The word “mode” and ad-hoc “local”/”deployed” phrasing are retired in favor of these.

The environment is a property of the launch path, never stored in the model:

One model may run in all three environments simultaneously, and each instance has its own database by construction:

Convention: one instance per model per environment; a second copy in the same environment is a new model. Data: development is volatile (snapshots only); staging and production are persistent — staging is not disposable. The admin password is static in development (admin / admin-password-1, by convention — see docs/snapshots.md) and generated per instance in staging (profile.env) and production (cluster secrets). Snapshot restore re-stamps the destination’s own admin password hash, so a restored database always answers to its environment’s password (see docs/snapshots.md → Password re-stamping). During the MVP, staging is the flagship environment: it hosts Model Bank and has the Deploy button, which production lacks. Staging does not mirror production’s substrate (host process vs k8s); passing staging is not a substrate guarantee. An environment is not a “tier”: tiers are product offerings; environments are where an instance runs.

PUBLIC_ORIGIN (public pages)

The public pages (/p/, the sitemap, the feed) build every absolute URL — canonical, og:url, article:published_time, feed guid, Sitemap: line — from one configured origin, never from the request’s Host. It is an absolute http/https origin with no path, query, or fragment:

A bad value is a 500 on /p/ (the log names PUBLIC_ORIGIN); the authenticated API keeps working. Public pages are rendered on request and need no rebuild after a snapshot restore.

:domain-stg

The model’s :domain remains the canonical production FQDN, used by deploy. Staging exposure (profile expose) reads :domain-stg; when the author omits it, the compiler derives it by suffixing -stg onto the first DNS label of :domain (todo.demo.data-ui.com → todo-stg.demo.data-ui.com). An explicit :domain-stg always wins; it must differ from :domain (one HAProxy map line, one owner) and requires :domain when written. The deploy-button exception is modelbank: staging keeps the clean canonical URL (modelbank.demo.data-ui.com) and production takes the -p suffix — both explicit. -stg hosts and modelbank’s two names all live under the existing *.demo.data-ui.com wildcard (DNS + TLS), so no new zone or certificate is involved.

Generate-button prompt log

Every real :generate-model LLM call (the Generate button on Model Bank) writes its full prompt — system message, user message, LLM model, temperature, record name, timestamp — as one org-mode file to the shared host directory /data/k8s/data-ui/generate-log/, named <app-name>-<record-name>-<timestamp>.org. Format: one level-1 org heading per field (the former JSON keys); the * system-prompt heading carries two level-2 children mirroring the prompt’s two parts — ** Model Syntax Reference (docs/model-reference.md verbatim in a #+begin_src markdown block) and ** Examples (the framing prose, then every demo in one #+begin_src lisp block). Both blocks are org-comma-escaped so a C-c ' edit round-trips; in the JSON body the two parts ride one system string, with part 2 opening under a # Examples markdown heading. (2026-09-27: the prompt’s NUL pollution — a u:slurp UTF-8 bug that sent ~233 literal NULs to the LLM — was fixed at the source in dc-eclectic.) Unconditional and best-effort: a logging failure (missing dir, full disk) is logged and never fails Generate; test runs using the LLM override write nothing. The API key is a header and never rides the logged body. The directory is host-level today (every host instance runs as the same user); /data/k8s/ placement means extending it to deployed production apps later is a pure ops change — mount a hostPath PV at the same path into app pods, zero code delta. The instance cannot yet name its environment (a backlog item), so dev and staging generations are distinguished only by app + record name.

Deployment State: Where Things Live

Deployment state lives outside the repository, in /data/data-ui/deploy/ on the deploy host:

/data/data-ui/deploy/
├── ports.lock                      # name env port, one per line
└── todos/
    ├── secrets.env                 # instance credentials (0600)
    └── releases/
        ├── 0.1-c13571a/            # every release's manifests, kept
        └── 0.1-6d8f586/
            ├── 00-namespace.yaml
            ├── 05-secrets.yaml
            ├── 10-pv.yaml
            ├── 15-pvc.yaml
            ├── 20-init-sql.yaml
            ├── 30-postgres.yaml
            ├── 40-data-ui.yaml
            ├── haproxy-backend.cfg
            └── haproxy-map-entry

Why outside the repo? Because rendered manifests are derived output (rebuildable from model + templates + state) and secrets are, well, secret. The repo holds source; the state directory holds facts about one particular machine’s cluster. Deleting the whole state directory is recoverable: ports and secrets are re-read from the live cluster on the next deploy.

Application data lives in a third place: the k3d cluster binds /data/k8s (host, on the SSD) into the node at the same path, and each instance’s PersistentVolumes use /data/k8s/data-ui/<name>-<env>/{db,files}. So even k3d cluster delete cannot destroy application data; it survives on the host filesystem.

Three layers, three lifetimes:

Layer Lives Survives
Source (model, templates) git repo everything
Deploy state (secrets, ports) /data/data-ui/deploy cluster recreation
App data (database, files) /data/k8s/data-ui cluster deletion

Secrets, and How to Get the Admin Password

Each instance has exactly three secrets, generated once at first deploy:

Getting the admin password

The easy way (on the deploy host):

grep ADMIN_PASSWORD /data/data-ui/deploy/todos/secrets.env

The canonical way (works even if the secrets file is gone, from any machine with cluster access):

kubectl get secret -n dataui-todos dataui-todos-secrets \
    -o jsonpath='{.data.admin-password}' | base64 -d; echo

Both should agree. If they don’t, trust the cluster: the file is a cache; the Secret is the truth. (This is a recurring design theme. When a cache and the cluster disagree, the cluster wins, the same way the dictionary wins at Scrabble.)

A war story, so you don’t repeat it: the very first end-to-end deploy “failed” with a wall of 401s. Backend verified healthy, JWTs verified valid, much head-scratching: the operator was logging in with the old admin password from a previous instance’s secrets. If your freshly deployed app rejects you, read the password again, slowly.

Password re-stamping on snapshot restore

The snapshot machinery (dev + staging profiles, and production via prd: addresses) re-stamps the destination’s own admin password hash after every restore, so the env and the database never disagree. For a prd:<name> destination the working password after a restore is the cluster Secret’s admin-password — restore reads it live from the Secret (never the secrets.env cache) and re-stamps with exactly that value. See snapshots.md → Production for the full prd: story (deploy-host-only, scale-to-0 restore, prerestore slot, the EXIT trap’s failure modes).

Password format trivia

ADMIN_PASSWORD is generated as $(openssl rand -hex 8)-a1. The -a1 suffix is not decoration: the rbac library’s password policy requires at least one letter, one digit, and one punctuation character, and sixteen random hex characters can satisfy the first two but never the third. The suffix guarantees all three, and the sixteen random hex chars provide the entropy. Yes, this was learned the hard way. No, the instance that taught us is no longer with us.

Rotation

There is no rotation tooling yet. If you must rotate manually: update the Kubernetes Secret, update secrets.env, restart the deployment, and for DB_PASSWORD also ALTER USER dataui PASSWORD ... inside postgres (in that order of caution). For a demo instance, the clean-slate procedure below is honestly less error-prone.

Production Backups: Off-Site on S3

The snapshot pool lives on the same SSD as the databases it protects, which makes it a convenience, not a disaster recovery plan. Two production instances have data that must survive the machine: SceneBook (the first paying customer’s continuity data) and the Backlog app (the project’s own memory). For those, host-side timers upload fresh snapshots off the machine entirely — into a private, versioned S3 bucket. The pool can burn with the house; the S3 copy cannot. (Until November 2026 this role was filled by a Google-Drive folder synced by Insync — but the folder lived on the same host’s /data, so a dead host took its only off-site copy with it, the 2026-11-18 outage class. The Drive folders remain as a read-only legacy archive; nothing new depends on them.)

The target is one bucket, data-ui-backups-232168665831 (us-east-1, private, public-access-blocked, SSE-S3, versioned). Retention is lifecycle rules, never scripts — deletion is S3’s job, and the backup credentials cannot delete at all. The key prefix carries the host and the tier:

Key prefix (s3://<bucket>/…) Contents Expires
evo-x2/backlog/hourly/ full triple per hour 1 day
evo-x2/backlog/daily/ server-side copy of one hourly triple 30 days
evo-x2/scenebook/rpo/ .dump + .meta per 30 min 1 day
evo-x2/scenebook/daily/ full triple incl. photos tar 30 days
evo-x2/backlog/model/, evo-x2/scenebook/model/ the model file never (noncurrent after 90 d)
prod-2/<app>/… the same tiers, written by prod-2’s timers same (the lifecycle rules are cloned onto prod-2/)
prod-2/site/… release records + the per-site manifest 90 d noncurrent

The site prefix is parameterized (BACKUP_SITE, default the site marker, else evo-x2): prod-2’s timers write prod-2/, evo-x2’s stay evo-x2/. RESTORE_SITE (default BACKUP_SITE) retargets restore/recover reads — the move runbook stages evo-x2’s set onto prod-2 with RESTORE_SITE=evo-x2, and the reverse (staging prod-2’s set on evo-x2, e.g. for a drill or a move back) is RESTORE_SITE=prod-2. On prod-2 the instance role carries the credentials (the env file holds only AWS_REGION and AWS_BUCKET); on evo-x2 the dataui-backup-evo-x2 IAM user remains.

Lifecycle filters are full key prefixes (evo-x2/ first) — a filter like backlog/hourly/ matches nothing under evo-x2/backlog/hourly/… and the rule never fires. Versioning is the backstop for the no-delete posture: every rule carries a NoncurrentVersionExpiration too (1 day for the data tiers, 90 days for the model prefixes), or the bucket would grow forever behind delete markers.

The machinery is not part of scripts/data-ui — it is host machinery, one script per app shipped in the repo under ops/ (ops/backlog-backup, ops/scenebook-backup) and run from ~/bin/<unit> as a symlink into the production clone’s copy, driven by user-level systemd timers (lingering is enabled for the user, so they run at boot with no login session). Each app installs five units: the base .service/.timer pair, a -daily.service/-daily.timer pair (OnCalendar=*-*-* 03:20:00, Persistent=true), and one shared -fail.service:

Each app’s daily cycle also syncs the model file into <prefix>/model/ (resolved in the production checkout with set-model’s shadow order: models/<name>.lisp first, else models/local/<name>.lisp). Snapshots do not carry the model, and VIP models live in gitignored models/local/ — the model rides the backup so a cold host never dies mid-crisis for lack of it. A missing model file fails the daily run loudly.

The scripts live in git under ops/ and reach the host through a symlink: ~/bin/<unit> → /data/data-ui/repos/production/ops/<unit>. The repo home gives them history, review, and a cold-host rebirth path (clone the repo, re-link, start); the stable ~/bin name keeps the public verbs, the PATH, and the units’ ExecStart unchanged. A symlink into a local clone carries none of the old Drive-symlink hazard — that risk was the Insync daemon behind the link, not symlink-ness. The coupling to accept: backup-machinery changes ride the normal deploy train, so a routine deploy pull updates the running scripts (each change lands reviewed and versioned, where untracked real files in ~/bin had neither).

One base cycle: snapshot save the timestamped triple via the production clone’s scripts/data-ui (downtime-free), verify all three files, upload .meta (+ .files.tar.gz where the tier holds it) then .dump last, head-verify each object’s size, then rm the pool triple and prune the pool. S3 objects are atomic — there is no half-written-file hazard. The prune matches only names whose suffix parses as YYYYMMDD-HHMM (the name is the save time; mtimes are never consulted), so word-named snapshots (-final, keep-* copies) and the machinery’s own slots (-last, -prerestore, the bare prd-<name>) are immune; the S3 side is never pruned by a script — lifecycle owns remote retention.

The aws CLI is stateless (no agent, no local sync state; the script is the sync) and lives in /snap/bin — the scripts put a PATH that includes it after the inherited one, because systemd user units would not find it otherwise. Credentials live in ~/.config/data-ui-backup.env (mode 600, not synced): on evo-x2 AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_BUCKET — the dataui-backup-evo-x2 IAM user, scoped to the evo-x2/ prefix of this bucket for writes and reads (PutObject/GetObject + the five multipart actions, ListBucket conditioned to the prefix), plus read-only on prod-2/* (GetObject, and ListBucket conditioned to that prefix) so a reverse move or cross-site drill can stage prod-2’s sets on evo-x2. No DeleteObject, no lifecycle or bucket admin — a buggy script cannot destroy history. On prod-2 the key pair is optional: the instance role carries the credentials (the env file there holds only region and bucket), scoped to prod-2/* with read on evo-x2/* for the moves.

If a cycle fails, the shared OnFailure fail unit pings Mattermost (the macnod-bot user, Water Bottle channel) naming the failed service, with the journal tail. Its credentials live in ~/.config/<unit>.env (mode 600, not synced); a missing or incomplete file degrades the ping to a stderr line — it never blocks a backup or a stop.

Verbs

scenebook-backup status      # timer states, last-run results, newest object per tier, model sync date
scenebook-backup run         # one base cycle now (what the timer runs)
scenebook-backup run daily   # the daily cycle (full save / promotion + model sync)
scenebook-backup restore     # newest daily-tier backup -> snapshot pool
scenebook-backup restore prd-scenebook-daily-20261119-1000
scenebook-backup restore prd-scenebook-20261119-1000 rpo   # a specific RPO-tier backup
scenebook-backup location    # print the S3 backup prefix
scenebook-backup stop        # disable both timers, remove the five units (S3 objects stay)

(backlog-backup takes the same verbs; its tiers are daily and hourly.) Restoring downloads the tier’s objects back into the snapshot pool, where snapshot list sees it; from there the normal snapshot restore machinery takes over. The pool is the interface — S3 is just another place triples live. The tier is the second argument or a --tier flag, never a bare snapshot-name slot. The printed follow-up command targets prd:<app> by default; RESTORE_PRINT_TARGET=<address> retargets it (drills and gates point it at a scratch profile) — it changes only the printed text, never where anything lands.

<unit>-backup recover          # select the freshest COMPLETE set, download it, print the restore order
<unit>-backup recover --check  # select + verify completeness without downloading (rebirth preflight)

recover never relies on key order across tiers: candidates group by exact basename per tier, sidecars complete a candidate only from the same tier, and the newest complete candidate wins — a newest candidate missing files.tar.gz falls back to the older complete triple. Backlog prefers the hourly tier when its newest complete triple is newer than the daily’s. SceneBook picks the newest complete daily triple, then applies the newest rpo dump+meta pair on top only when its timestamp is newer; the daily-files / rpo-database age gap is printed verbatim first (which files tree accompanies which database, and how far apart). The printed restore: <name> lines are the restore order — scripts/data-ui rebirth --fresh-data runs them itself.

Example: pull the latest production backlog backup onto evo-x2

Backlog runs on prod-2, so its freshest triple is in the prod-2/ prefix, not on evo-x2. recover stages into the snapshot pool of the host it runs on; it does not touch the live app, and S3 keeps its copy. Log into prod-2 and run:

~/bin/backlog-backup status
~/bin/backlog-backup recover

status is the look; recover is the pull. It prints the name it staged (a run on 2026-11-22 picked prd-backlog-20261122-2300, newer than that day’s daily). Back on evo-x2, copy that triple into the local pool — substitute the printed name:

scp prod-2:/data/data-ui/snapshots/prd-backlog-20261122-2300.dump \
    prod-2:/data/data-ui/snapshots/prd-backlog-20261122-2300.files.tar.gz \
    prod-2:/data/data-ui/snapshots/prd-backlog-20261122-2300.meta \
    /data/data-ui/snapshots/

Confirm it landed, then restore it into the local dev instance. Postgres has to be up first (scripts/data-ui db or repl):

scripts/data-ui snapshot list
scripts/data-ui snapshot restore prd-backlog-20261122-2300 dev:backlog

Do not restore to prd:backlog from evo-x2. That instance lives on prod-2, and a prd: restore scales the app to 0. A model mismatch is a hard refuse, not a warning.

The gap to know about

Coverage is per app and explicit. A newly deployed production instance has no off-site backup until someone installs a timer for it (copy the script from ops/, change its per-app constants — PREFIX, APP_PROFILE, S3_APP_PREFIX, MODEL_NAME — and the unit name, symlink it into ~/bin, add the app’s tier prefixes and lifecycle rules, and run start); nothing in deploy creates one. If an app’s data matters, its backup timer is part of its definition of done.

The Kubernetes Manifests

Each instance is fully isolated in its own namespace, dataui-<name>. The manifests, in apply order:

File What it creates
00-namespace.yaml The namespace dataui-<name>
05-secrets.yaml dataui-<name>-secrets (the three credentials)
10-pv.yaml Two hostPath PersistentVolumes: db (2Gi), files (5Gi)
15-pvc.yaml The matching PersistentVolumeClaims
20-init-sql.yaml ConfigMap with the schema init SQL
30-postgres.yaml PostgreSQL 16 Deployment + postgres Service
40-data-ui.yaml The app Deployment + NodePort Service

Highlights of 40-data-ui.yaml:

How HAProxy Routing Works

HAProxy was already serving other domains on this host, so Data UI had to move in without rearranging the furniture. The design adds exactly one line to the existing config, once, and after that new instances never touch the main config at all.

Three pieces:

1. The map file: /etc/haproxy/data-ui.map

A plain text file mapping hostnames to backend names:

todo.demo.data-ui.com dataui-todos
parts.demo.data-ui.com dataui-parts     # (a future instance)

2. One routing rule in the https frontend (added once)

use_backend %[req.hdr(host),lower,map(/etc/haproxy/data-ui.map)] \
    if { req.hdr(host),lower,map(/etc/haproxy/data-ui.map) -m found }

In English: lowercase the Host header, look it up in the map; if found, route to that backend. One line handles every current and future Data UI instance. The deploy script inserts it (idempotently) just above the existing default_backend line.

3. Per-instance backend drop-ins: /etc/haproxy/conf.d/dataui-<name>.cfg

backend dataui-todos
    mode http
    option forwardfor
    option httpchk GET /health
    server dataui-todos 172.18.0.2:30303 check inter 2000 rise 2 fall 3

That points at the k3d node’s IP and the instance’s NodePort, with an active health check against the same /health endpoint the Kubernetes probes use. (assign_backend_target is fail-closed on the k3d-published loopback hop 127.0.0.1:<NodePort+1000> — e.g. 127.0.0.1:31303 — since 2026-09-30: if the hop does not answer, the deploy dies rather than render a bridge-IP target that goes stale when docker reassigns node IPs.) The conf.d directory is enabled via EXTRAOPTS in /etc/default/haproxy (also a one-time, idempotent step).

On every deploy, the script: installs/updates the backend file, upserts the map entry, validates the whole config (haproxy -c across the main file and conf.d), and only then reloads. If validation fails, nothing is reloaded and the old routing keeps working.

Locally-run host profiles (scripts/data-ui profile expose) use the same machinery with a different backend name: dataui-profile-<name> points at 127.0.0.1:<HTTP_PORT> on the host instead of a k3d NodePort (the model :name values profile and profile-* are reserved so the two can never collide). One domain, one backend: profile expose refuses a map line owned by a deployed instance, and a deploy refuses a map line owned by a profile exposure — neither stops the other side’s pods; delete (undeploy) first, then profile expose. profile unexpose (and profile delete) remove the exposure.

One subtlety, learned in production (where else): systemctl reload haproxy re-execs the master process with its original command line. If EXTRAOPTS was just modified to add -f /etc/haproxy/conf.d, a reload will not pick that up: the running master has never heard of conf.d, and your shiny new backend 503s while the NodePort works perfectly. The script handles this: the deploy that first enables conf.d does a full systemctl restart; every subsequent deploy does the gentler reload.

4. The demo directory and the 404 page (demo404)

Hosts under *.demo.data-ui.com that the map does not know about (typos, retired demos) used to be redirected to data-ui.com — a 301 browsers cache forever, which stranded visitors after a rename. They now get a real 404 page that names the requested host and lists the demos that are running. The bare apex, demo.data-ui.com, serves the same list as a normal 200 page — the directory.

HAProxy has no CGI, so the page comes from a tiny local service, demo-directory.service: a stdlib-only Python HTTP server on 127.0.0.1:8484 (hardened: DynamicUser, ProtectSystem=strict), wired in as the host-owned demo404 backend (ops/demo404.cfg; no dataui- prefix, so the profile/deploy tooling never touches it). Two use_backend demo404 rules in the https frontend cover the apex and the unmapped-host fallthrough; everything routed by the map is unaffected.

The list can never go stale: the service re-reads /etc/haproxy/data-ui.map on every request, so profile expose / unexpose and deploys are reflected instantly, with no restart. Hosts listed in the EXCLUDE set at the top of the script (currently chat, which is infrastructure, not a demo) stay routed but are never listed.

It survives reboots on both sides: the unit is enabled (a Wants symlink into multi-user.target) with Restart=on-failure, and HAProxy loads conf.d — and with it demo404.cfg — at boot via the EXTRAOPTS line in /etc/default/haproxy. If the service is down anyway, unmapped hosts get a plain HAProxy 503 (backend down); mapped demos keep working.

Sources live in ops/ (demo-directory.py, demo-directory.service, demo404.cfg); the installed copies are targets, never edited in place. Everything is managed by the demo-directory CLI (source: ops/demo-directory, installed to /usr/local/bin/demo-directory; checkout override via DATA_UI_CHECKOUT):

# one-time: install the CLI itself, then everything else
sudo install -m 755 ops/demo-directory \
     /usr/local/bin/demo-directory
demo-directory install    # script + unit + HAProxy backend,
                          # enable --now, validate, reload
demo-directory status     # enabled/active/health/demo list
demo-directory start|stop

Making a change to the page

There are two copies of the script: the source (ops/demo-directory.py in the repo) and the installed target (/opt/demo-directory/demo-directory.py, the one systemd runs). Edit the repo copy, then push it live with one command:

demo-directory update

It syntax-checks the script (refusing to install a broken file), installs it over the target, restarts the service (Python loaded the old code at startup), and health-checks the result. Never edit /opt directly — the next update would silently overwrite it.

Verification: the 404 page is served no-store, so a bogus host shows changes instantly (curl -s https://no-such-demo.demo.data-ui.com/); the 200 directory page at the apex caches in a browser for 60s. If the service refuses to come up, systemctl status demo-directory / journalctl -u demo-directory show the startup line.

TLS: Certificates That Renew Themselves

All demo instances live under *.demo.data-ui.com, so a single wildcard certificate covers every app, present and future. Adding a new instance requires zero TLS work. That is the entire point.

The moving parts

One-time setup

deploy/setup-tls.sh does the whole dance idempotently: installs the IAM credentials for root (renewals run as root), installs the renewal hook, runs certbot certonly --dns-route53 for demo.data-ui.com + *.demo.data-ui.com, builds the combined pem, patches the bind line, validates, reloads. Run it once per deploy host and forget it.

Note the wildcard covers anything.demo.data-ui.com but not the bare demo.data-ui.com; that’s why the cert requests both names.

Renewal (the part where you do nothing)

The certbot.timer systemd unit fires twice a day. When the cert is within 30 days of expiry, certbot renews it via DNS-01 and then runs the deploy hook installed at /etc/letsencrypt/renewal-hooks/deploy/haproxy-pem.sh (source: deploy/letsencrypt-haproxy-hook.sh), which:

  1. concatenates fullchain.pem + privkey.pem into /etc/haproxy/certs/demo.data-ui.com.pem (HAProxy wants one file; written atomically via a .new + mv, mode 600),
  2. reloads HAProxy.

To rehearse the whole thing without touching the real certificate:

sudo certbot renew --dry-run

If that passes, future-you has nothing to do, ever. Past-you already did it.

Docker Credentials: Headless Deploys

Deploys are triggered two ways: from a shell (interactive, you are present) and by the Deploy button on Model Bank, which runs the deploy script from inside the app’s process — a headless systemd context with nobody watching. The second way must never depend on a human answering a prompt. One of the two prompt traps was fixed with the NOPASSWD sudoers rule for HAProxy; the other is Docker’s credential helper, and it bites quietly:

~/.docker/config.json says "credsStore": "pass", so every registry operation — including the anonymous-looking pulls of node:22-slim and ubuntu inside docker build — consults docker-credential-pass, which decrypts ~/.password-store with the user’s GPG key. If gpg-agent’s cache is cold, gpg pops a pinentry dialog on the host desktop and waits. Nobody answers (it’s a guest’s deploy; the dialog isn’t even on their screen), the helper times out or gets a wrong passphrase, and the build dies with:

getting credentials - err: exit status 1, out: `exit status 2:
gpg: public key decryption failed: Bad passphrase
gpg: decryption failed: Bad passphrase`
ERROR: Docker build failed.

A wrong passphrase in that dialog — typed in haste at the desktop — produces exactly this. A correct one only buys you gpg-agent’s cache TTL; the next guest, hours later, hangs again.

The fix on this host (done, 2026-09-30)

The password store now encrypts to a dedicated passphrase-less GPG key. Decryption never prompts, so credential lookups work in any context — cold boot, systemd, ssh, cron. The tradeoff: the store’s contents are readable by anyone who can read ~/.password-store (file permissions, not cryptography, protect them). That’s acceptable here because the store holds nothing but the Docker Hub token; the protecting passphrase was guarding nearly nothing, while the prompt was breaking guest deploys entirely.

What was done:

# dedicated no-passphrase key (encryption subkey, never expires)
gpg --batch --passphrase '' --quick-generate-key \
    "data-ui-docker-creds (pass store, no passphrase)" default default never
FPR=$(gpg --list-secret-keys --with-colons "data-ui-docker-creds" \
      | awk -F: '/^fpr:/ {print $10; exit}')
gpg --batch --passphrase '' --quick-add-key "$FPR" default encr never

# two stale artifacts of an old docker login (index.docker.io/v1/
# access-token and refresh-token subpaths) — the helper only needs
# the plain index.docker.io/v1/ entry
pass rm -f 'docker-credential-helpers/<b64>/macnod'   # x2, the stale ones

# re-encrypt the store (prompts once for the old key's passphrase)
pass init "$FPR"

If the one-time pinentry times out during pass init (nobody at the keyboard), just re-run it — the .gpg-id is already updated and each retry re-encrypts what remains.

The check (run after any credential change)

# must print JSON, no dialog, no delay — even right after
# gpgconf --kill gpg-agent (i.e. with nothing cached)
gpgconf --kill gpg-agent
echo "https://index.docker.io/v1/" | docker-credential-pass get

That kills gpg-agent first on purpose: a warm cache can mask a broken setup, which is exactly how the first button deploys passed and a later guest deploy failed.

Notes for the future

Deploying From Another Machine

You don’t have to be on the deploy host. If hostname doesn’t match $DEPLOY_HOST (default evo-x2), the script becomes a thin forwarder — nothing more:

  1. it validates its arguments (the same fail-fast grammar as a local deploy),
  2. optionally snapshots + SHA-256-checks a MODEL_FILE, transfers it non-interactively to a fresh mode-700 host temp directory outside both checkouts, and verifies type, size, and hash there (a host-side trap cleans the temp directory; cleanup after a network partition is best-effort),
  3. ssh-es to the deploy host (-t, so sudo and delete confirmations can prompt) and runs a host-side launcher: /data/data-ui/repos/production/scripts/data-ui if it exists and is executable, otherwise $DEPLOY_BOOTSTRAP_CHECKOUT/scripts/data-ui. A missing launcher fails before any mutation.

The caller never selects a local production clone, never inspects or clean-checks its own repo, and never derives a SHA, writes facts or tags, pushes, or queries origin — including under DRY_RUN=1. The host-side outer deploy then does everything a local invocation does. After first bootstrap, the bootstrap checkout is never consulted; its dirt and branch are never inspected.

The whole remote command travels as one bash -c <quoted> argument through exactly one reparse, and only an environment allowlist is forwarded (DRY_RUN, FORCE, checkout/state/source overrides, cluster configuration) — never secrets on a command line.

One host, for now

Staging and production must name the same host (STAGING_HOST == DEPLOY_HOST; a differing pair is rejected before any lockfile, Git, npm, SSH, or systemd mutation). This is load-bearing, not a simplification: get-deployed-admin-password is a plain local read of $DATA_UI_STATE/deploy/<name>/secrets.env written by the deploy on the deploy host, so Model Bank’s deploy-model-record-secret works only on one machine; profile HAProxy operations are host-local too. Splitting the hosts (including remote secret retrieval) is a separate item.

The second production site does not split them: prod-2 is production-only (staging, demo, e-demo, and profile verbs are refused there outright), so STAGING_HOST == DEPLOY_HOST == evo-x2 continues to hold for everything staging-shaped. See Two Production Sites.

Two Production Sites

Production runs on two sites, partitioned by app sensitivity. evo-x2 (the home machine) keeps staging, demos, Model Bank, the Deploy button, and the less-sensitive production apps. prod-2 (a single EC2 instance, t4g.xlarge, Ubuntu 26.04 arm64, us-east-1) hosts the sensitive apps — Backlog first, then SceneBook — so a power outage at home can no longer take the paying customer’s app dark. Every app instance is owned by exactly one site; there is no active/active (no transactions today). Moving an app is a one-way migration: snapshot-replicate → restore → swing DNS.

The move runbook (per app; E = evo-x2, P = prod-2)

  1. Deploy, unpublished: DEPLOY_HOST=prod-2 scripts/data-ui deploy <app> (from evo-x2; DNS still answers from evo-x2).
  2. Trial restore, no downtime: on prod-2 RESTORE_SITE=evo-x2 ~/bin/<app>-backup recover, then snapshot restore <name> prd:<app> per printed name; verify row counts, the files tree, an admin login, and pinned health. Each per-name snapshot restore is its own process and the sweep is automatic: a NOT-SAFE verdict exits 1 after the “Restored snapshot” line — the restore itself did not roll back, the database is the dump, and the prerestore slot still holds the destination’s previous state (restoring that slot is the deliberate undo if the operator wants it); the operator heals per the sweep’s report or judges, and a multi-name trial continues by running the next printed name. “Earlier restores only warn” is the rebirth loop’s rule and only its rule — never this runbook’s.
  3. Stop the source timers (E): ~/bin/<app>-backup stop.
  4. Fence — downtime starts (E): scale the app to 0 and wait for the pod to go (kubectl -n dataui-<app> scale deploy/dataui-<app> --replicas=0; kubectl -n dataui-<app> wait --for=delete pod -l app=dataui-<app> --timeout=120s). PostgreSQL stays up; snapshot save works against a scaled-down app.
  5. Final backup (E): ~/bin/<app>-backup run (SceneBook: run daily); confirm the triple in S3.
  6. Final restore (P): as step 2 (per-name snapshot restore, automatic sweep, NOT-SAFE verdicts fatal per name); row counts must now equal the fenced source.
  7. Cutover — downtime ends as resolvers converge (≤ 300 s) (P): scripts/data-ui cutover <app>.
  8. Verify the public view (E): dig +short A <domain> @1.1.1.1 shows the Elastic IP; curl -fsS --resolve <domain>:443:<EIP> https://<domain>/health; a login from outside the home network.
  9. Teach the home LAN: a per-name router override (<domain> → the Elastic IP) and, immediately, the same line in evo-x2’s /etc/hosts — the home LAN’s split-horizon DNS otherwise keeps resolving the name to evo-x2 (the agents’ backlog wrapper depends on this step).
  10. Backups on the new site (P): ~/bin/<app>-backup start plus one run; verify fresh objects under prod-2/<app>/.
  11. Retire the source (E): scripts/data-ui delete <app> (the farewell snapshot prd-<app>-last stays in evo-x2’s pool).

Before step 7 nothing is public and everything can be put back; after step 7 never un-fence evo-x2 — fix forward on prod-2, or reverse deliberately.

Troubleshooting (two-site)

Legacy VIP identity migration

deploy-bootstrap (beyond creating/validating the production clone) also migrates legacy VIP identities: it inventories models/local/*.lisp in every checkout production historically deployed from (the bootstrap/development checkout, plus any existing production clone), cross-checks them against live dataui-* namespaces, and copies each file bytes-intact (SHA-256 verified) to the production clone’s models/local/<declared-name>.lisp under the production lock. It refuses to overwrite a different destination file, rejects malformed names, declared-name mismatches, conflicting duplicates, and symlink sources for operator resolution, and never modifies the legacy checkout. An empty inventory is printed and is fine. An instance whose identity cannot be inventoried requires MODEL_FILE=<archived model file> scripts/data-ui delete NAME.

Configuration knobs (environment variables, all with defaults):

Variable Default Meaning
DEPLOY_HOST evo-x2 (the site marker on a stamped host defaults it to that site) ssh destination & site identity (production)
STAGING_HOST evo-x2 staging host (must equal DEPLOY_HOST)
DEPLOY_CHECKOUT /data/data-ui/repos/production production clone
STAGING_CHECKOUT /data/data-ui/repos/staging staging clone
DEPLOY_BOOTSTRAP_CHECKOUT ~/common-lisp/data-ui last-resort launcher on a host with no production clone
CHECKOUT_LOCK_ROOT /data/data-ui/repos deploy/staging lock directory
DATA_UI_PUBLIC_URL / DATA_UI_PRIVATE_URL canonical GitHub URLs clone URLs (prod-2’s site default is the anonymous HTTPS URL)
DEPLOY_STATE_DIR /data/data-ui/deploy state directory
DATA_UI_STATE /data/data-ui root for deploy state (and the site marker, <root>/site)
MODEL_FILE (unset) explicit model file (VIP deploys and delete identity)
K3D_CLUSTER evo-x2 (site default on prod-2: prod-2) k3d cluster name
IMAGE_REGISTRY (unset; site default on prod-2: the ECR registry) registry cache for deploy images
REBUILD (unset) 1 skips the registry probe, builds, and pushes over the same content tag
MOVE (unset) 1 overrides the wrong-site guard and pins gate 2 to loopback
SITE_DNS_MODE wildcard (site default on prod-2: explicit) how publication works on this site
SITE_DNS_ZONE_ID (unset; prod-2: Z0152779JVWMFEK6RAKU) Route 53 hosted zone for per-app records
SITE_WILDCARD_ZONE (unset; stamped evo-x2: demo.data-ui.com) arms the wrong-site guard
SITE_STATE_URI (unset; prod-2: s3://data-ui-backups-232168665831/prod-2/site) S3 prefix for release records and the manifest
SITE_PRODUCTION_ONLY (unset; prod-2: 1) refuse staging/demo/profile verbs outright
SITE_PUBLIC_IP / SITE_HEALTH_IP (unset; IMDSv2 on prod-2) pin the site’s address / the health gates
DEPLOY_RECORDED_RELEASE (unset) 1 = redeploy the recorded image (the rebirth path)
REBIRTH_APPS / REBIRTH_ALLOW_BUILD / REBIRTH_ALLOW_POPULATED_FILES (unset) rebirth overrides (see Two Production Sites)
DRY_RUN (unset) see Dry Runs
STAGING_HEALTH_TIMEOUT 300 per-profile restart gate deadline (seconds)
MODELBANK_DRAIN_TIMEOUT 600 Model Bank drain deadline (seconds)

Selection, Locks, and Rollback

The Build Context: a Curated Archive

The Docker context is never the raw checkout (Dockerfile uses COPY ., and ignored stale VIP models under models/local/ would ride into canonical images). Instead the inner deploy builds a fresh restrictive temp directory populated by git archive <full SHA>:

VIP Deploys: Handoff, Promotion, Recovery

A VIP deploy’s model text crosses as data: the Model Bank worker writes a unique file models/local/deploy-incoming/<token>.lisp in its staging checkout (exclusive create; no worker ever mutates another’s input), and the outer deploy snapshots and validates it (regular file, ≤1 MiB, no symlinks, SHA-256) before any Git or network mutation, then installs its own candidate at the same relative path in the production checkout — under the production lock, the only writer. The inner arm compiles, builds, and rolls out from that candidate.

Dry Runs

DRY_RUN=1 scripts/data-ui deploy todos

A dry run is not side-effect-free: it still fetches and fast-forwards the production checkout, compiles the model through the throwaway database, and writes deploy state (manifests, ports.lock, secrets cache). It skips tagging, image build, and cluster mutation, and never waives cleanliness or source verification. With a handoff it runs the same validation path and its exit trap removes the temporary candidate, so models/local/deploy-incoming/ ends byte-identical and nothing is promoted.

Connecting a REPL to the Live App

If the model was deployed with :repl t, the container runs a Swank server on port 4005, reachable only through Kubernetes port forwarding (it is never exposed via Service, NodePort, or HAProxy):

kubectl -n dataui-todos port-forward deploy/dataui-todos 4005:4005

Then in Emacs: M-x slime-connect RET localhost RET 4005, and you have a live REPL inside the running production container. Inspect the compiled model, poke RBAC state, debug a hook: the full Lisp experience against the deployed instance. With great power, et cetera: this is the expert-tier escape hatch, and production models should ship :repl nil.

Troubleshooting

A diagnostic ladder

Work from the inside out; each rung isolates one layer:

# 1. Are the pods up?
kubectl -n dataui-todos get pods

# 2. Does the app answer inside the cluster? (NodePort, bypasses HAProxy)
curl http://<node-ip>:30303/health        # expect: OK

# 3. Does HAProxy route it? (full path: TLS, map, backend)
curl https://todo.demo.data-ui.com/health # expect: OK

# 4. Does login work? (POST the real admin password; see Secrets)
curl -s -X POST https://todo.demo.data-ui.com/api/login \
  -H 'Content-Type: application/json' \
  -d '{"username":"admin","password":"<see Secrets section>"}'

# 5. Login still 401s? Read the Secrets section again — a deploy
#    never rewrites admin credentials, so the password is exactly
#    what the cluster Secret says.

If (2) works and (3) doesn’t, it’s HAProxy: check /etc/haproxy/data-ui.map for the domain, /etc/haproxy/conf.d/ for the backend file, and remember the reload-vs-restart subtlety above.

Reading the app logs

kubectl -n dataui-todos logs deploy/dataui-todos            # current
kubectl -n dataui-todos logs deploy/dataui-todos --previous # last crash

The app logs structured JSON lines. A crash prints a full backtrace and exits (--disable-debugger), so the evidence is always in --previous.

Known failure modes

Rate limiting

scripts/data-ui traffic reports the HAProxy per-IP rate-limit counters (stick-table in the https frontend) and flags clients near or over the limits. It needs sudo for the HAProxy admin socket.

Starting Over: the Clean-Slate Procedure

The fast path: delete the whole instance with one command:

scripts/data-ui delete todos

It deletes the namespace and PVs, wipes the instance’s data on the host, removes the HAProxy backend and map entry, and removes the deploy state (including secrets), then prompts you to type the instance name before doing any of it (set FORCE=1 to skip the prompt, e.g. in a deploy/record/delete rehearsal loop). Before destroying anything it saves a farewell snapshot of the instance’s last state to the shared pool as prd-<name>-last (the prd twin of the stop verb’s -last slot; FORCE=1 skips that too, and a failed save aborts the delete with the data still intact). Docker images, git release tags, and the farewell snapshot are left alone. A failed delete can simply be re-run; every step tolerates already-deleted resources, and the re-run skips the farewell (nothing left to save).

The manual equivalent, if you want to do it piecewise (or only partway; steps 1–3 are enough for a clean redeploy of the same instance):

# 1. Remove the app and its namespace
kubectl delete namespace dataui-todos

# 2. PVs are cluster-scoped with Retain policy; delete them explicitly
kubectl delete pv dataui-todos-demo-db-pv dataui-todos-demo-files-pv

# 3. Wipe the instance's data on the host (root-owned; same path
#    on host and node via the /data/k8s bind)
sudo rm -rf /data/k8s/data-ui/todos-demo

# 4. Optional: drop cached secrets to get fresh credentials
rm /data/data-ui/deploy/todos/secrets.env

# 5. Deploy
scripts/data-ui deploy todos

Steps 2 and 3 are the ones people forget. A Released PV refuses to bind to a new claim, and stale postgres data under /data/k8s/data-ui will be happily adopted by the new instance, old password and all. (Or skip the list entirely and use scripts/data-ui delete, which forgets nothing — except the farewell snapshot it deliberately leaves in the pool.)


That’s the machine. A napkin’s worth of model in, a running application out: database, API, RBAC, frontend, TLS, DNS, all of it derived, none of it hand-maintained. The 10,000 lines you didn’t write are the feature.