homek8s/apps/base/farrisilk
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-22 02:38:35 -05:00
..
backup.yaml apps(farrisilk): client-shaped nightly pg_dump cron + 14d retention on a 10Gi PVC 2026-11-22 02:38:35 -05:00
httproute.yaml apps(farrisilk): lab replica stack (Odoo 18 + plain Postgres + Metabase) on :8086/:8087 2026-11-22 02:15:56 -05:00
kustomization.yaml apps(farrisilk): client-shaped nightly pg_dump cron + 14d retention on a 10Gi PVC 2026-11-22 02:38:35 -05:00
metabase.yaml apps(farrisilk): lab replica stack (Odoo 18 + plain Postgres + Metabase) on :8086/:8087 2026-11-22 02:15:56 -05:00
namespace.yaml apps(farrisilk): lab replica stack (Odoo 18 + plain Postgres + Metabase) on :8086/:8087 2026-11-22 02:15:56 -05:00
odoo-init.yaml apps(farrisilk): close the metabase_ro schema-CREATE hole + README 2026-11-22 02:28:56 -05:00
odoo.yaml apps(farrisilk): name Odoo's database odoo (align with the BI grants + Metabase source) 2026-11-22 02:25:09 -05:00
postgres-init.yaml apps(farrisilk): close the metabase_ro schema-CREATE hole + README 2026-11-22 02:28:56 -05:00
postgres.yaml apps(farrisilk): lab replica stack (Odoo 18 + plain Postgres + Metabase) on :8086/:8087 2026-11-22 02:15:56 -05:00
README.md apps(farrisilk): close the metabase_ro schema-CREATE hole + README 2026-11-22 02:28:56 -05:00

farrisilk — lab replica of the Farrisilk client stack

A development/audit sandbox shaped like Farrisilk Inc.'s production stack — not a copy of their traffic, and not their architecture. Odoo 18 + a plain PostgreSQL + Metabase, WireGuard-only, in namespace farrisilk.

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.farrisilk.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-farrisilk-odoo.yaml (8086) and gateway-farrisilk-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 farrisilk/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:

POD=$(kubectl -n farrisilk get pod -l app=odoo -o name | head -1)
kubectl -n farrisilk cp ./client_module "${POD#pod/}:/mnt/extra-addons/client_module" -c odoo
kubectl -n farrisilk 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 farrisilk 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>/<sha1> inside the Odoo pod (ir_attachment.store_fname = <2-char>/<sha1>). 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 gap, stated plainly

There are no backups of this stack in the cluster, and none are being added by this card.

The client's practice is a cron-driven pg_dump of the database only — no barman/PITR, no filestore copy. The replica mirrors that shape; the follow-up card (t_8bdd3708) proves the failure mode deliberately rather than hiding it. Two consequences to keep in mind while auditing:

  1. pg_dump of odoo + metabase reproduces Odoo's database and Metabase's questions/dashboards. It does not reproduce /var/lib/odoo/filestore.
  2. A DB-only restore therefore produces an Odoo instance where the attachment list is intact and every download 404s. That is the client's real exposure too, if their cron really copies only the DB.

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-<tag> 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 farrisilk/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: farrisilk odoo → pg.farrisilk.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:

-- 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 farrisilk 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. <store>.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=farrisilk. 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.