Preview deployment: test a PR batch before it reaches deploy #60
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
public/wanderer#60
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Today a PR batch can only be clicked through after it is merged into
deployand an image is built. Add awanderer-previewenvironment so a branch or batch can be tested first.imageworkflow dispatch with arefinput, taggedpreview-<sha>.wanderer-previewDeployment plus Service and ingress (tailnet-only, e.g. wanderer-preview.bearoverse.com), behind the same auth as wanderer.Motivation: the 2026-11-05 batch (#52–#59) could not be clicked through before merging, and the shared browser cannot reach internal hosts by design (the browser-session NetworkPolicy is internet-only).
🤖 Generated with Claude Code
Design + prepared pieces (nothing live yet)
homelab-flux PR: jmz/homelab-flux#838 (needs Bear review):
apps/wanderer-preview/with web, db and search, allreplicas: 0.wanderer-preview-pb-data(nfs-nas) holds a copy of live pb_data. The live PVC is never mounted, so migrations in a preview (#62) touch only the copy. Search is its own Meilisearch on an emptyDir and is rebuilt from the copy on every start.wanderer-preview.bearoverse.com+wanderer-preview-pb.bearoverse.com. They use websecure on the k3s Traefik, like live, so they are tailnet/LAN only. Login is the same as live (PocketBase password or Authentik OIDC), and/_/and the_superusersAPI are denied the same way. Sign-up is off in the preview UI (PUBLIC_DISABLE_SIGNUP).kustomize.toolkit.fluxcd.io/ssa: IfNotPresent. Flux creates them once, then the script owns image and replicas. Without this, Flux would undo eachupwithin 10 minutes.Runbook / script:
/root/wanderer-preview.sh. Every changing step asks for a typedyes.refresh-datanever opens the live SQLite DB and never stops wanderer-db. On the nas it takesbtrfs subvolume snapshot -r /mnt/hdd0/@k3s, which is atomic, so data.db, its WAL and storage/ are captured at one instant (crash-consistent). It reflink-copies those files into the preview PVC and deletes the snapshot. Then, on the copy only, it runs a WAL checkpoint andintegrity_checkand rotates the token secrets of the auth collections, so preview tokens are not valid on live and live tokens are not valid on the preview.wanderer-preview-*Deployments. It fingerprints the live Deployments before and after each step and warns on any change./root/wanderer-shot.sh --host preview <path>uses the same strict allow-list, switched to the two preview hosts, with its own session cache.Cost: 0 pods when idle. When up, requests are 115m CPU / 640Mi on prodesk, which moves memory requests from 82% to 84%;
uprefuses above 90%. The disk copy is a reflink (about 260 MB logical).Open points / follow-ups:
main*/deploy*branches. Those are push-protected, and a branch's Dockerfile RUN steps can read the registry token. So a batch has to be pushed to a protected name first (e.g.git push origin batch/2026-11-05:deploy-preview, done by jmz), which then builds asdeploy-preview-<sha8>. To build any ref safely (thepreview-<sha>tag this issue asks for), image.yml would need a two-phase build: kaniko--no-push --tar-pathwith no credentials in the workspace, then a separate trusted push step. That is a separate public/wanderer change.net.nixrewrites (both names → .240), then the tailnet MagicDNS records (gen-tailnet-dns.py → homelab-fluxsites/sospel/apps/headscale/config, → .28). Cloudflare needs nothing. Optional: add the Authentik redirect URIhttps://wanderer-preview.bearoverse.com/login/redirectfor SSO on the preview. Until the DNS records exist, the script and the screenshot tool pin the preview names to the shared k3s Traefik address.🤖 Generated with Claude Code
Design update after the security review (jmz/homelab-flux#838, commit ce8b336)
The preview runs unreviewed branch code. It therefore holds no live credentials and can reach no live service. Each point below replaces the corresponding part of the earlier comment.
wanderer-preview-secrets, whichwanderer-preview.sh refresh-datagenerates with every fresh copy. It is not in git, and the script can write only that one Secret name. No value of the livewanderer-secretsis used. The live encryption key isn't needed either, because the copy's settings row (encrypted with the live key, may hold SMTP) and the ActivityPub private keys are dropped.wanderer-preview-dbService, never through Traefik._superusersincluded, gets a newtokenKey, and every auth collection gets new token secrets._superusersis emptied.users.createRule = null, so PocketBase itself refuses sign-up.up:🤖 Generated with Claude Code
First real run done 2026-11-06, the preview works end to end:
refresh-data(reworked for local-path pb_data, hf #919): an online sqlite3.backupof live in a network-less pod on prodesk, then the copy is hardened (1103 trails, 2 users); live unchanged.build deploy-preview(PR #77 heade5a57df8, web only; db = live image).up: smoke all green; tokens are separate both ways; search re-indexed.Flow for a PR: push its head to
deploy-preview(jmz, protected) ->wanderer-preview.sh build deploy-preview->up <digest>-> tests (WANDERER_TARGET=previewfor the acceptance scripts,wanderer-shot.sh --host preview) ->down.🤖 Generated with Claude Code