# customer1 — lab replica of the Customer 1 client stack A **development/audit sandbox** shaped like Customer 1 Inc.'s production stack — not a copy of their traffic, and not their architecture. Odoo 18 + a plain PostgreSQL + Metabase, WireGuard-only, in namespace `customer1`. | Service | URL over WireGuard | Bare IP? | Notes | |---|---|---|---| | Odoo 18 | `http://10.10.0.2:8086/` | yes, any `Host` | `http://10.10.0.2:8086/web/login` | | Metabase | `http://10.10.0.2:8087/` | yes, any `Host` | secondary instance, 1 GiB heap | | PostgreSQL | `pg.customer1.svc.cluster.local:5432` | in-cluster only | no NodePort, no gateway | `10.10.0.2` is siriussec, the only node labelled `gateway=true` (the only node running `cilium-envoy`). Nothing here has a public hostname, a tunnel entry or a DNS record — same posture as the `:8085` evaluation Metabase. ## What is deliberately *not* like the homelab The client runs **Odoo 18 + PostgreSQL on two on-prem Proxmox VMs**, plus Metabase and a Shopify integration containerised alongside. No Kubernetes. This namespace is our sandbox for developing and auditing against *their* shape: - **Postgres is a plain container (`postgres:16`) on one `local-path` volume, not a CloudNativePG Cluster.** No operator, no replicas, no WAL archive — because the client's database is a bare VM install. Do not "improve" it into CNPG; that would test an architecture they do not run. - **Odoo runs `workers=0`** (see below), where production may run several. - **One Postgres, two databases**: `odoo` (the Odoo database, owner and app role `odoo`) and `metabase` (Metabase's own application DB, owner `metabase`). ## Layout | Object | File | |---|---| | Namespace | `namespace.yaml` | | `pg` Deployment + Service + `pg-data` PVC (10Gi) | `postgres.yaml` | | First-boot roles/databases (`/docker-entrypoint-initdb.d`) | `postgres-init.yaml` | | Odoo Deployment/Service, `odoo-data` (10Gi) + `odoo-extra-addons` (5Gi) PVCs | `odoo.yaml` | | Idempotent Odoo provisioning script (initContainer) | `odoo-init.yaml` | | Metabase Deployment + Service | `metabase.yaml` | | Two hostname-less HTTPRoutes | `httproute.yaml` | Gateways live with the other internal listeners: `infrastructure/networking/internal/gateway-customer1-odoo.yaml` (8086) and `gateway-customer1-metabase.yaml` (8087). **Each bare-IP service gets its own Gateway**: Cilium renders one RouteConfiguration per Gateway and merges every hostname-less route inside it into a weighted route, so two services sharing a Gateway answer for each other at random. The host firewall (`infrastructure/networking/internal/host-firewall/`, nft on siriussec + ufw on rpi) carries 8086/8087 and was installed *before* the Gateways were pushed, so there was never a window where Envoy's `0.0.0.0` bind was open on the LAN. ## First boot / how the database comes up The `odoo` Deployment's initContainers do all provisioning — there is no separate Job to race against: 1. `render-config` renders `/etc/odoo-runtime/odoo.conf` from the ConfigMap values plus Secret `pg-users`, and fixes PVC ownership (uid 100 / gid 101). Odoo has no env-var support for `db_password`, hence the rendering step. 2. `init-db` (script in `odoo-init.yaml`): - waits for Postgres; - **if the `odoo` database has no tables**, runs `odoo -d odoo -i base,web --without-demo=all --stop-after-init`; - `CREATE EXTENSION IF NOT EXISTS unaccent` as the database owner; - (re)applies the read-only BI grants and credential-table revokes, every start, so tables added by a later module install are covered too; - sets the admin login/password from Secret `customer1/odoo-admin` via `odoo shell`. Restarting the pod is safe and visibly idempotent: `== odoo already initialised: skipping -i base ==`. Metabase's own tables are created by Metabase in database `metabase` on first start; nothing pre-creates them. ## Custom modules (the client has some) Copy the module directory into the `odoo-extra-addons` PVC, then install it through the ORM: ```bash POD=$(kubectl -n customer1 get pod -l app=odoo -o name | head -1) kubectl -n customer1 cp ./client_module "${POD#pod/}:/mnt/extra-addons/client_module" -c odoo kubectl -n customer1 exec -i deploy/odoo -c odoo -- \ odoo shell -c /etc/odoo-runtime/odoo.conf -d odoo --no-http --shell-interface=python <<'EOF' m = env['ir.module.module'].search([('name', '=', 'client_module')]) m.button_immediate_install() env.cr.commit() print(m.state) EOF ``` Then `kubectl -n customer1 delete pod -l app=odoo` once, so `init-db` re-applies the `metabase_ro` SELECT grants to the tables the module just created (grants are re-applied on every pod start; `ALTER DEFAULT PRIVILEGES` covers tables created after the grant but not before it). The PVC is why a module survives a restart: an installed module whose directory disappears from `addons_path` makes Odoo refuse to load it. `/mnt/enterprise-addons` is an **emptyDir**, already on `addons_path` and unused. Whether the client actually runs Enterprise is still an open question; drop an EE addons tree there (or turn it into a PVC) only once that is answered. ## `list_db=False`, and how to flip it `list_db = False` mirrors the client's production posture: the database manager (`/web/database/manager`, database create/duplicate/drop) is not reachable from a browser. `dbfilter = ^odoo$` pins the served database. For development work that needs the database manager (e.g. duplicating the DB before a risky migration), change the `list_db` line in the `render-config` script in `odoo.yaml` to `True`, push, let Flux roll the pod — do not `kubectl exec`-edit the rendered config, it is re-rendered on every start. Flip it back afterwards: with `list_db=True` and `proxy_mode=True` the manager is reachable by anyone on the WireGuard mesh. ## Why `workers=0` (and what production needs) `workers=0` runs Odoo as a single process (threaded). It is the honest setting for a one-user lab replica on a laptop: multi-worker needs its own gevent/bus port and much more RAM. **Production shape**: `workers = (2 × cores) + 1`, capped by available RAM at roughly **512 MB per worker** (plus the 1.5 GiB hard limit for the main process), with `max_cron_threads` counted separately. Going multi-worker here requires exposing the **gevent/bus port 8072** through its own Gateway listener *and* its own host-firewall entry — a plain `workers=N` without 8072 breaks longpolling/bus (the web client silently loses notifications). 8072 is deliberately not opened while `workers=0`. ## Filestore (where attachments actually live) `data_dir = /var/lib/odoo` on PVC `odoo-data`, so attachment bytes live at `/var/lib/odoo/filestore/odoo/<2-char>/` inside the Odoo pod (`ir_attachment.store_fname` = `<2-char>/`). Verified: an `ir.attachment` created over XML-RPC appears as a 697-byte file at exactly that path. **The DB is not the filestore.** `ir_attachment` rows hold metadata; the bytes are files. A database-only restore comes back looking healthy and every attachment, image and rendered artefact is gone. ## Backups — the client's shape, implemented and measured `backup.yaml` implements the **standard shape of the client's stated practice** (a bash script on cron that dumps the database). It is *not* a copy of the client's script — theirs has not been seen yet (Week 3 read-only audit item) — and the label matters: everything below is what the *described* method does and does not give you. ### Schedule, retention, location | Item | Value | |---|---| | CronJob | `customer1/pg-backup` | | Schedule | `17 3 * * *`, `timeZone: America/Los_Angeles` (nightly) | | Guard rails | `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 600`, `backoffLimit: 1`, `activeDeadlineSeconds: 1800`, history 3 ok / 3 failed | | Databases | `odoo` **and** `metabase`, one `pg_dump -Fc` each | | Filename | `/backups/-.dump`, e.g. `odoo-20261122T074011Z.dump` | | Retention | **14 days** (`RETENTION_DAYS=14`, `find /backups -name '*.dump' -mtime +14 -delete`) | | Storage | PVC `backup-data`, 10 Gi, `local-path`, mounted at `/backups` | | Script | ConfigMap `pg-backup-script` (`backup.sh`), no ServiceAccount/RBAC (default SA, token not mounted) | | Credentials | `pg-app` Secret via env (`PGUSER`/`PGPASSWORD`) — never in git or in the manifest | Per-run log line (the only evidence a run happened; it lands in the Job pod log): ``` backup: ok db=odoo file=odoo-20261122T074011Z.dump size=2202025B toc_entries=4876 duration=1s backup: ok db=metabase file=metabase-20261122T074011Z.dump size=1274779B toc_entries=2923 duration=0s backup: retention sweep, deleting *.dump older than 14 days backup: run complete rc=0 total=1s dumps_on_disk=2 ``` The script fails the Job (`rc=1`) if any `pg_dump` fails **or** if the archive comes back with an empty TOC — a broken backup turns red instead of silently succeeding, which a bare `pg_dump >> log 2>&1` cron does not do. **Where the dumps actually are:** `/opt/local-path-provisioner/pvc-8f164f6c-…_customer1_backup-data` on **siriussec only**. `local-path` is node-local, so the backup dies with the node. No off-box copy is implemented: the Garage S3 API at `http://10.10.0.1:3900` is reachable from a pod, but it needs a bucket plus credentials that are not part of this namespace, so it was not wired in one pass. That absence is deliberate — it is the same absence in the client's described setup. Trigger a run on demand (what the manual proof below did): ```bash kubectl -n customer1 create job --from=cronjob/pg-backup pg-backup-manual-1 kubectl -n customer1 logs job/pg-backup-manual-1 ``` ### Restore — it is TWO steps, and the second one is the one people forget **1. Database** (dumps live on the `backup-data` PVC; mount it in a throwaway pod or exec where it is mounted): ```bash createdb -h pg -U postgres pg_restore -h pg -U postgres -d /backups/odoo-.dump psql -h pg -U postgres -d -tAc 'select count(*) from res_users' ``` Restoring into the same cluster works without extra flags because the `odoo` role and the schema already exist; into a *different* cluster use `--no-owner --no-privileges` (then re-assign ownership). `-Fc` archives are also readable with `pg_restore --list` and can be inspected without touching a database. **2. Filestore** — this backup does **not** contain it. Copy the attachment bytes from the Odoo PVC by hand: ```bash # from the Odoo pod (uid 100): tar the filestore directory, not the DB kubectl -n customer1 exec deploy/odoo -- \ tar czf - -C /var/lib/odoo filestore | gzip -d | tar xzf - -C ``` The directory name is the **database name**: `/var/lib/odoo/filestore/odoo`. Restoring the dump into `odoo_restore_probe` makes Odoo look in `/var/lib/odoo/filestore/odoo_restore_probe`, which does not exist — renaming or copying the filestore tree to match the restored DB name is a required manual step. ### Proof from the 2026-11-22 run (numbers, not assertions) | Check | Result | |---|---| | Job | `pg-backup-manual-1` — `Complete 1/1`, pod `Completed` | | odoo dump | 2,202,025 B, `pg_restore --list` = **4876** entries | | metabase dump | 1,274,779 B, `pg_restore --list` = **2923** entries | | Restore probe | `createdb odoo_restore_probe` → `pg_restore -d` → **rc 0** | | Row counts | live `res_users`=**5** vs restored=**5**; live `ir_attachment`=**22** vs restored=**22** | | Cleanup | `odoo_restore_probe` dropped; probe pods deleted | | Retention sweep | 30-day-old `*.dump` deleted by the exact `find`, fresh file kept | ### The gap this method carries — demonstrated, not asserted After the restore above, the database is complete and healthy. The attachments are not: - Restored DB references **22** `ir_attachment` rows, **21** of them with a `store_fname` (file bytes). - The backup volume holds exactly **2** files: the two `.dump` archives. **0 of the 21 referenced files** exist anywhere under `/backups` (checked every `store_fname` against the volume). - `pg_restore --list` contains **0** filestore/blob entries — the dump carries rows, not bytes. - The live filestore is **23 files / 732 KiB** under `/var/lib/odoo/filestore/odoo`; none of it is in the backup. - End-to-end: the same attachment id fetched from the **live** instance and from a throwaway Odoo bound to the **restored** database: ``` live /web/content/15 -> 200 25613B (res.partner 2, image_1024) restored DB /web/content/15 -> 500 265B live /web/content/22 -> 200 447998B (web assets bundle) restored DB /web/content/22 -> 500 265B ``` and the restored instance's log names the missing file exactly: ``` FileNotFoundError: [Errno 2] No such file or directory: '/var/lib/odoo/filestore/odoo_restore_probe/a3/a305c7712711bdddb2561500d8fcab0ead92ebd6' ``` **User-visible consequence:** after a DB-only restore the database looks perfectly healthy — users, invoices and records are all there — but every invoice PDF, pricelist, product image and attachment download **404s or 500s**. The client would discover this at the moment they need the backup, not before. ### RPO / consistency statement - Nightly dump, **no WAL archiving, no PITR**: worst-case **RPO is 24 hours** of orders, invoices and attachments. Anything written after 03:17 is gone. - The dump is a single `pg_dump` per database and is **not point-in-time consistent with the filestore**: files written while the dump runs are either present on disk and absent from the DB, or referenced by the DB after the dump snapshot but missing from any earlier filestore tar — even a correct DB+filestore restore has a skew window. - There is no automated restore test, no checksum/encryption, and no alert on a failed cron run beyond the Job's own status. A silent `pg_dump` failure on a cron is invisible until the day it is needed. ### What the client's stated method does not cover (Week 3 remediation register) | # | Not covered | Impact | |---|---|---| | 1 | Filestore / attachment bytes | 22 attachment rows, 0 bytes restorable; all downloads/PDFs/images break after restore | | 2 | WAL archiving / PITR | up to 24 h data loss; no restore to a point before a bad import/delete | | 3 | Off-box copy | dumps sit on the same host as the database; host/disk/ransomware loss takes both | | 4 | Restore testing | untested dumps are hypotheses; no evidence they restore | | 5 | Point-in-time consistency DB↔filestore | skewed restores even when both are copied | | 6 | Failure alerting/verification | a failed cron dump is silent; Job status is the only signal here | | 7 | Encryption at rest / access control on dumps | plain `.dump` files readable by anyone with the volume | | 8 | Retention policy enforcement beyond 14 d | unbounded growth or, if scripts differ, no policy at all | Closing these (barman/PITR, object storage, filestore tar+checksum, scheduled restore drills) is an **architectural recommendation for the client**, not a change to this replica — no CNPG/barman is added here on purpose: the replica exists to reproduce the client's exposure. ## PDF reports The pinned image (`odoo:18.0-20261112`) ships **`wkhtmltopdf 0.12.6.1 (with patched qt)`** at `/usr/local/bin/wkhtmltopdf`, so no derived image is needed and PDF rendering is not a gap here. Proven end-to-end over the gateway: `GET /report/pdf/product.report_pricelist/1` → `200`, `application/pdf`, 16 032 bytes, 13 pages. If a future image drops wkhtmltopdf, the fix is a derived image `FROM odoo:18.0-` installing the *patched-qt* build (the Debian `wkhtmltopdf` package is not patched and renders headers/footers badly), built `runs-on: docker-amd64` and pinned by tag in `odoo.yaml`. ## Metabase (secondary instance) - Image `metabase/metabase:v0.65.6.3`, `JAVA_OPTS=-Xmx1024m`, container limit 2 GiB — this is a *second* Metabase next to the `metabase` namespace evaluation instance and does not repeat its 1.5 GiB heap on this laptop. - State lives in the same Postgres, database `metabase`, user `metabase`. - **`MB_ENCRYPTION_SECRET_KEY` is set** (Secret `customer1/metabase-secret-key`) so stored data-source passwords are not encrypted with Metabase's default key. Keep it stable: rotating it makes every stored datasource password undecryptable. - Set up entirely through the API (`/api/session/properties` → `POST /api/setup` → `POST /api/session` → `POST /api/database` → `sync_schema`), one data source: **`customer1 odoo`** → `pg.customer1.svc.cluster.local:5432/odoo` as `metabase_ro`. - Metabase has no per-database "read-only" switch for PostgreSQL sources; the read-only guarantee here is the **role**, which is stronger (see below). ### The read-only BI role (practice, not shortcut) `metabase_ro` is created by `postgres-init.yaml` and re-secured by `odoo-init.yaml` on every pod start: ```sql -- role-level defaults ALTER ROLE metabase_ro SET default_transaction_read_only = on; ALTER ROLE metabase_ro SET statement_timeout = '60s'; ALTER ROLE metabase_ro SET idle_in_transaction_session_timeout = '60s'; -- CONNECTION LIMIT 10 -- database/schema REVOKE CREATE ON SCHEMA public FROM PUBLIC; -- PG16 keeps PUBLIC=CREATE when REVOKE ALL ON SCHEMA public FROM metabase_ro; -- the DB was made by a non-superuser GRANT USAGE ON SCHEMA public TO metabase_ro; GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro; ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public GRANT SELECT ON TABLES TO metabase_ro; ``` Why the schema revokes matter: `default_transaction_read_only` is a role *default*, and the role may lift it with `SET default_transaction_read_only = off`. Without the revoke, `metabase_ro` could create tables in `public` (observed on 2026-11-22 — this was a real gap, now closed). With it, a create fails twice over: read-only transaction, and `permission denied for schema public`. Credential-bearing tables are **revoked, not just unqueried**. The set is computed at every start (a static list plus anything whose columns match `password|secret|token|api_key|private_key`) and logged: ``` metabase_ro: SELECT granted on 224 tables; revoked on ['auth_totp_wizard','change_password_own','fetchmail_server','iap_account', 'ir_attachment','ir_config_parameter','ir_mail_server','mail_guest', 'res_config_settings','res_groups','res_users_apikeys','res_users_identitycheck'] ``` `ir_config_parameter` is the one that matters most (integration API keys and tokens). `res_users` stays readable on purpose — it carries only a password *hash* and Metabase needs it for user counts. ## Secrets (out of band, in the cluster only) Created before the Kustomization applies; never in git, never printed: | Secret | Keys | Used by | |---|---|---| | `pg-app` | `username`=postgres, `password` | Postgres bootstrap superuser | | `pg-users` | `odoo_password`, `metabase_password`, `metabase_ro_password` | role passwords (initdb + workloads) | | `odoo-config` | `admin_passwd` | Odoo database master password | | `odoo-admin` | `email`, `password` | Odoo web admin login (uid 2) | | `metabase-admin` | `email`, `password` | Metabase's own login (**email**, no username) | | `metabase-data-source-creds` | `username`=metabase_ro, `password` | the `customer1 odoo` data source | | `metabase-secret-key` | `MB_ENCRYPTION_SECRET_KEY` | Metabase at-rest encryption | ## Shopify — integration surface only, blocked on client credentials Shopify is SaaS: **there is nothing to deploy in this cluster**, and this namespace deliberately contains no stub service and no unauthenticated webhook listener. What the replica needs before a connector can exist: 1. **Store domain** (e.g. `.myshopify.com`) and the store's plan — Lance has not seen the store. 2. **Admin API access token** with scopes for the resources the connector syncs (products/orders/inventory read-write; webhooks write), created in the store's custom-app settings. Stored as a Secret, never in git. 3. The **Odoo Shopify connector module** (the client has custom modules; the QSIT/Shopify connector is a separate module) copied into `/mnt/extra-addons` — see "Custom modules". 4. **Webhook path through the ingress.** Shopify must POST to a reachable HTTPS URL. This namespace is WireGuard-only, so a webhook path needs a public hostname + tunnel entry *and* HMAC verification — a decision that must be made explicitly for the replica, not inherited from prod. Status: **blocked on client credentials** (store domain + Admin API token + the connector module). Until then the Odoo side stays unconfigured on purpose. ## Deviations from the card, recorded - The card's build section names db `odoo` (owner `odoo`), §4 grants on database `odoo`, and Metabase's data source is `…:5432/odoo`, while the Odoo config bullet said `db_name=customer1`. Those cannot both hold; the stack is aligned on **`odoo`** (`db_name`, `dbfilter=^odoo$`, `ODOO_DB_NAME`, the BI grants and the Metabase source all say `odoo`). - `base,web` are installed (not `base` alone) so `/web/login` serves a real web client. `product` was installed to create the acceptance product; a fresh build installs `base,web` only.