Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 696edddcaf | |||
|
|
ae22aab330 | ||
|
|
f9888c63f0 | ||
|
|
f5cb4ec22a | ||
|
|
955f886d36 | ||
|
|
5b26ecd823 | ||
|
|
cc50d1c231 | ||
|
|
648516af71 | ||
|
|
82f0d83243 | ||
| 01db28dec5 | |||
|
|
79206e0487 | ||
|
|
530320bbfe | ||
|
|
96404c96e1 | ||
|
|
03fb50c3d7 | ||
|
|
f658bfabe9 | ||
|
|
4891694f6f | ||
|
|
7f7f806616 | ||
|
|
930752152e | ||
| a0fc373e34 | |||
|
|
0e5ba18377 | ||
| f83b0cb246 | |||
|
|
1e9253c147 | ||
| 243f113c1f | |||
|
|
f0a82f85de | ||
| d5514c6ed4 | |||
|
|
f326735a8b | ||
| 0e6fa0d738 | |||
|
|
e63c14641d | ||
| 2380cfb6ac | |||
|
|
c2cdc2d5c1 | ||
| 7da7a8c5d4 | |||
| 2d38e1a3f7 | |||
|
|
b55ec826c9 | ||
|
|
f969dcf4ca | ||
| 19fd7be914 | |||
| 9ad79263ab | |||
| 7fbc4c177a | |||
|
|
e63ba14791 | ||
| fea3b44eb5 | |||
|
|
24785a54e8 | ||
| 91ce65637d | |||
|
|
7ae4ac2ee3 | ||
| a1d81d55ee | |||
|
|
1b27ad1120 | ||
| 30243561e3 | |||
|
|
c6e0081217 | ||
| 20c52cad97 | |||
|
|
4ffe40e6ca | ||
| 53a38fe022 | |||
|
|
4c90eba08b | ||
| cdc3f7093e | |||
|
|
c45255242b | ||
| a9fcc0f3da | |||
|
|
f3a8233e37 | ||
| 32a59e1051 | |||
|
|
953be9f3cf | ||
| 95d807852c |
70 changed files with 4354 additions and 74 deletions
423
apps/base/customer1/README.md
Normal file
423
apps/base/customer1/README.md
Normal file
|
|
@ -0,0 +1,423 @@
|
||||||
|
# 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>/<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 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/<db>-<UTC ts>.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 <target_db>
|
||||||
|
pg_restore -h pg -U postgres -d <target_db> /backups/odoo-<ts>.dump
|
||||||
|
psql -h pg -U postgres -d <target_db> -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 <restore-data-dir>
|
||||||
|
```
|
||||||
|
|
||||||
|
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-<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 `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. `<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=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.
|
||||||
171
apps/base/customer1/backup.yaml
Normal file
171
apps/base/customer1/backup.yaml
Normal file
|
|
@ -0,0 +1,171 @@
|
||||||
|
# Nightly logical backup of BOTH databases — the *standard shape* of the client's
|
||||||
|
# stated practice (bash script on cron that dumps the database).
|
||||||
|
#
|
||||||
|
# This is NOT a copy of the client's script: theirs has not been seen yet
|
||||||
|
# (Week 3 read-only audit item). It implements what Lance described — a nightly
|
||||||
|
# `pg_dump` per database, timestamped files, an age-based retention sweep and a
|
||||||
|
# per-run log line — and nothing more.
|
||||||
|
#
|
||||||
|
# Deliberately absent, because the client's method has none of it:
|
||||||
|
# - WAL archiving / PITR -> worst-case RPO is 24 h (see README)
|
||||||
|
# - filestore (attachment bytes)-> the dump carries rows, not files (see README)
|
||||||
|
# - off-box copy -> dumps live on siriussec's local-path disk
|
||||||
|
# (the Garage S3 API at http://10.10.0.1:3900 is reachable from a pod, but it
|
||||||
|
# needs a bucket + credentials that are not part of this namespace; copy is
|
||||||
|
# therefore NOT implemented and backups die with the node — on purpose, so
|
||||||
|
# the replica shows the real exposure.)
|
||||||
|
#
|
||||||
|
# No RBAC: the default ServiceAccount, with its token not even mounted. This pod
|
||||||
|
# talks to Postgres over the ClusterIP Service and writes to its own PVC.
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: backup-data
|
||||||
|
namespace: customer1
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
storageClassName: local-path
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: pg-backup-script
|
||||||
|
namespace: customer1
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
data:
|
||||||
|
backup.sh: |
|
||||||
|
#!/bin/sh
|
||||||
|
# Nightly pg_dump -Fc of each database + age-based retention.
|
||||||
|
# Exit non-zero if ANY dump fails or comes back with an empty TOC, so a
|
||||||
|
# broken backup turns the Job red instead of silently succeeding.
|
||||||
|
set -eu
|
||||||
|
: "${PGHOST:=pg}"
|
||||||
|
: "${PGPORT:=5432}"
|
||||||
|
: "${PGUSER:=postgres}"
|
||||||
|
: "${BACKUP_DIR:=/backups}"
|
||||||
|
: "${RETENTION_DAYS:=14}"
|
||||||
|
DATABASES="${DATABASES:-odoo metabase}"
|
||||||
|
|
||||||
|
ts="$(date -u +%Y%m%dT%H%M%SZ)"
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
run_start="$(date +%s)"
|
||||||
|
rc=0
|
||||||
|
|
||||||
|
echo "backup: run start ts=$ts databases='$DATABASES' retention=${RETENTION_DAYS}d dir=$BACKUP_DIR"
|
||||||
|
for db in $DATABASES; do
|
||||||
|
file="$BACKUP_DIR/$db-$ts.dump"
|
||||||
|
start="$(date +%s)"
|
||||||
|
if pg_dump -h "$PGHOST" -p "$PGPORT" -U "$PGUSER" -d "$db" -Fc -f "$file"; then
|
||||||
|
dur=$(( $(date +%s) - start ))
|
||||||
|
bytes="$(stat -c %s "$file")"
|
||||||
|
toc="$(pg_restore --list "$file" | wc -l)"
|
||||||
|
if [ "$toc" -gt 0 ]; then
|
||||||
|
echo "backup: ok db=$db file=$db-$ts.dump size=${bytes}B toc_entries=$toc duration=${dur}s"
|
||||||
|
else
|
||||||
|
echo "backup: FAIL db=$db file=$db-$ts.dump empty archive TOC" >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "backup: FAIL db=$db pg_dump did not complete" >&2
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "backup: retention sweep, deleting *.dump older than ${RETENTION_DAYS} days"
|
||||||
|
find "$BACKUP_DIR" -maxdepth 1 -type f -name '*.dump' -mtime +"$RETENTION_DAYS" -print -delete || rc=1
|
||||||
|
|
||||||
|
echo "backup: run complete rc=$rc total=$(( $(date +%s) - run_start ))s dumps_on_disk=$(ls -1 "$BACKUP_DIR"/*.dump 2>/dev/null | wc -l)"
|
||||||
|
exit "$rc"
|
||||||
|
---
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: CronJob
|
||||||
|
metadata:
|
||||||
|
name: pg-backup
|
||||||
|
namespace: customer1
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
spec:
|
||||||
|
# Parked with the stack (see odoo.yaml): no dumps while Postgres is at 0.
|
||||||
|
suspend: true
|
||||||
|
# 03:17 America/Los_Angeles — one run per night, off the hour so it does not
|
||||||
|
# collide with Odoo's own cron threads or Metabase syncs at :00.
|
||||||
|
schedule: "17 3 * * *"
|
||||||
|
timeZone: America/Los_Angeles
|
||||||
|
concurrencyPolicy: Forbid
|
||||||
|
startingDeadlineSeconds: 600
|
||||||
|
successfulJobsHistoryLimit: 3
|
||||||
|
failedJobsHistoryLimit: 3
|
||||||
|
jobTemplate:
|
||||||
|
spec:
|
||||||
|
backoffLimit: 1
|
||||||
|
activeDeadlineSeconds: 1800
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: pg-backup
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
spec:
|
||||||
|
restartPolicy: Never
|
||||||
|
automountServiceAccountToken: false
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: siriussec
|
||||||
|
tolerations:
|
||||||
|
- key: dedicated
|
||||||
|
operator: Exists
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
# local-path hands out root-owned directories; the pod writes the PVC
|
||||||
|
# as root. It only runs pg_dump + pg_restore (client tools) and find.
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 0
|
||||||
|
runAsGroup: 0
|
||||||
|
containers:
|
||||||
|
- name: pg-dump
|
||||||
|
image: postgres:16
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command: ["/bin/sh", "/opt/backup/backup.sh"]
|
||||||
|
env:
|
||||||
|
- name: PGHOST
|
||||||
|
value: pg.customer1.svc.cluster.local
|
||||||
|
- name: PGPORT
|
||||||
|
value: "5432"
|
||||||
|
- name: PGUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: username
|
||||||
|
- name: PGPASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: password
|
||||||
|
- name: RETENTION_DAYS
|
||||||
|
value: "14"
|
||||||
|
- name: TZ
|
||||||
|
value: America/Los_Angeles
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 50m
|
||||||
|
memory: 128Mi
|
||||||
|
limits:
|
||||||
|
memory: 512Mi
|
||||||
|
volumeMounts:
|
||||||
|
- name: backups
|
||||||
|
mountPath: /backups
|
||||||
|
- name: script
|
||||||
|
mountPath: /opt/backup
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: backups
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: backup-data
|
||||||
|
- name: script
|
||||||
|
configMap:
|
||||||
|
name: pg-backup-script
|
||||||
|
defaultMode: 0555
|
||||||
44
apps/base/customer1/httproute.yaml
Normal file
44
apps/base/customer1/httproute.yaml
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
# Two separate HTTPRoutes and two separate Gateways, on purpose.
|
||||||
|
#
|
||||||
|
# A hostname-less route answers on the bare WireGuard address
|
||||||
|
# (http://10.10.0.2:8086/ and :8087/) for ANY Host header, because a phone
|
||||||
|
# cannot edit /etc/hosts. Cilium renders ONE RouteConfiguration per Gateway and
|
||||||
|
# merges every hostname-less route in it into a single weighted route, so two
|
||||||
|
# services sharing one Gateway serve each other's traffic at random regardless
|
||||||
|
# of listener port. Hence gateway-customer1-odoo.yaml (8086) and
|
||||||
|
# gateway-customer1-metabase.yaml (8087) in infrastructure/networking/internal/.
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: HTTPRoute
|
||||||
|
metadata:
|
||||||
|
name: odoo
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
parentRefs:
|
||||||
|
- name: customer1-odoo
|
||||||
|
namespace: internal
|
||||||
|
rules:
|
||||||
|
- matches:
|
||||||
|
- path:
|
||||||
|
type: PathPrefix
|
||||||
|
value: /
|
||||||
|
backendRefs:
|
||||||
|
- name: odoo
|
||||||
|
port: 8069
|
||||||
|
---
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: HTTPRoute
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
parentRefs:
|
||||||
|
- name: customer1-metabase
|
||||||
|
namespace: internal
|
||||||
|
rules:
|
||||||
|
- matches:
|
||||||
|
- path:
|
||||||
|
type: PathPrefix
|
||||||
|
value: /
|
||||||
|
backendRefs:
|
||||||
|
- name: metabase
|
||||||
|
port: 3000
|
||||||
20
apps/base/customer1/kustomization.yaml
Normal file
20
apps/base/customer1/kustomization.yaml
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
# Secrets are created out of band, before this Kustomization applies:
|
||||||
|
# customer1/pg-app basic-auth, postgres superuser
|
||||||
|
# customer1/pg-users odoo/metabase/metabase_ro role passwords
|
||||||
|
# customer1/odoo-config admin_passwd (database master password)
|
||||||
|
# customer1/odoo-admin email, password (web admin login)
|
||||||
|
# customer1/metabase-admin email, password (Metabase's own login)
|
||||||
|
# customer1/metabase-data-source-creds username=metabase_ro + password
|
||||||
|
# customer1/metabase-secret-key MB_ENCRYPTION_SECRET_KEY
|
||||||
|
# None of them appear in git; they are not managed (or pruned) by Flux.
|
||||||
|
- postgres-init.yaml
|
||||||
|
- postgres.yaml
|
||||||
|
- odoo-init.yaml
|
||||||
|
- odoo.yaml
|
||||||
|
- metabase.yaml
|
||||||
|
- backup.yaml
|
||||||
|
- httproute.yaml
|
||||||
108
apps/base/customer1/metabase.yaml
Normal file
108
apps/base/customer1/metabase.yaml
Normal file
|
|
@ -0,0 +1,108 @@
|
||||||
|
# Metabase for the lab replica — its own state in the SAME plain Postgres
|
||||||
|
# (database `metabase`), one data source: `customer1 odoo` as `metabase_ro`.
|
||||||
|
#
|
||||||
|
# This is a SECOND instance next to the evaluation one in namespace `metabase`.
|
||||||
|
# The laptop is on a marginal USB-C supply, so it does not repeat that
|
||||||
|
# instance's 1.5 GiB heap: 1 GiB heap, 2 GiB container limit.
|
||||||
|
#
|
||||||
|
# MB_ENCRYPTION_SECRET_KEY is set here on purpose. Without it Metabase encrypts
|
||||||
|
# stored data-source passwords with a key derived from its own default, so a
|
||||||
|
# copy of the app DB is enough to read them. The key lives in Secret
|
||||||
|
# `customer1/metabase-secret-key` and must stay stable for the life of the app
|
||||||
|
# DB — rotating it makes every stored datasource password undecryptable.
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
# Parked 2026-11-22 (power budget) — see apps/base/customer1/odoo.yaml.
|
||||||
|
replicas: 0
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: metabase
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: metabase
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
spec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: siriussec
|
||||||
|
tolerations:
|
||||||
|
- key: dedicated
|
||||||
|
operator: Exists
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
containers:
|
||||||
|
- name: metabase
|
||||||
|
image: metabase/metabase:v0.65.6.3
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 3000
|
||||||
|
env:
|
||||||
|
- name: JAVA_OPTS
|
||||||
|
value: "-Xmx1024m"
|
||||||
|
- name: MB_DB_TYPE
|
||||||
|
value: postgres
|
||||||
|
- name: MB_DB_HOST
|
||||||
|
value: pg.customer1.svc.cluster.local
|
||||||
|
- name: MB_DB_PORT
|
||||||
|
value: "5432"
|
||||||
|
- name: MB_DB_DBNAME
|
||||||
|
value: metabase
|
||||||
|
- name: MB_DB_USER
|
||||||
|
value: metabase
|
||||||
|
- name: MB_DB_PASS
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-users
|
||||||
|
key: metabase_password
|
||||||
|
- name: MB_ENCRYPTION_SECRET_KEY
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: metabase-secret-key
|
||||||
|
key: MB_ENCRYPTION_SECRET_KEY
|
||||||
|
- name: MB_JETTY_PORT
|
||||||
|
value: "3000"
|
||||||
|
- name: TZ
|
||||||
|
value: America/Los_Angeles
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 20
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 120
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 3
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 1Gi
|
||||||
|
limits:
|
||||||
|
# Capped with the main Metabase: see apps/base/metabase/deployment.yaml
|
||||||
|
cpu: "1"
|
||||||
|
memory: 2Gi
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: metabase
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 3000
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
7
apps/base/customer1/namespace.yaml
Normal file
7
apps/base/customer1/namespace.yaml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: customer1
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
sirius.dev/purpose: lab-replica-of-client-stack
|
||||||
172
apps/base/customer1/odoo-init.yaml
Normal file
172
apps/base/customer1/odoo-init.yaml
Normal file
|
|
@ -0,0 +1,172 @@
|
||||||
|
# Odoo provisioning, run as an initContainer on every pod start — idempotent by
|
||||||
|
# construction, so a restart never re-initialises a live database.
|
||||||
|
#
|
||||||
|
# 1. wait for Postgres
|
||||||
|
# 2. if the `odoo` database has no tables: `odoo -i base,web
|
||||||
|
# --without-demo=all --stop-after-init` (the "init once" step, done by the
|
||||||
|
# pod rather than by a separate Job so there is exactly one thing to wait
|
||||||
|
# on and no ordering race between a Job and the Deployment)
|
||||||
|
# 3. CREATE EXTENSION unaccent, as the database owner
|
||||||
|
# 4. (re)apply the read-only BI grants over every table Odoo just created,
|
||||||
|
# including revoking the tables that carry credentials
|
||||||
|
# 5. set the admin login/password from Secret `customer1/odoo-admin`
|
||||||
|
#
|
||||||
|
# Step 4 runs unconditionally, not only on first install: it is what picks up
|
||||||
|
# tables added by a later module install (`-i`/`-u` from /mnt/extra-addons), and
|
||||||
|
# `ALTER DEFAULT PRIVILEGES` alone does not cover tables created before the
|
||||||
|
# grant. Nothing here writes a credential to stdout.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: odoo-init
|
||||||
|
namespace: customer1
|
||||||
|
data:
|
||||||
|
init_db.py: |
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Idempotent first-run provisioning of the Customer 1 lab Odoo database."""
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
|
import psycopg2
|
||||||
|
|
||||||
|
HOST = os.environ["DB_HOST"]
|
||||||
|
PORT = int(os.environ.get("DB_PORT", "5432"))
|
||||||
|
SUPER_USER = os.environ["PG_SUPERUSER"]
|
||||||
|
SUPER_PW = os.environ["PG_SUPERPASS"]
|
||||||
|
DB = os.environ.get("ODOO_DB_NAME", "odoo")
|
||||||
|
CONF = "/etc/odoo-runtime/odoo.conf"
|
||||||
|
ADMIN_LOGIN = os.environ["ODOO_ADMIN_LOGIN"]
|
||||||
|
ADMIN_PASSWORD = os.environ["ODOO_ADMIN_PASSWORD"]
|
||||||
|
|
||||||
|
# Tables that hold credentials looking like data. `ir_config_parameter` is
|
||||||
|
# the one the card calls out (API keys/tokens for integrations); the rest
|
||||||
|
# are the same class of column. `res_users` is deliberately NOT in this
|
||||||
|
# list: it carries a password *hash* only, and Metabase needs it for user
|
||||||
|
# counts. Everything found by inspection at runtime is added and logged.
|
||||||
|
CREDENTIAL_TABLES = [
|
||||||
|
"ir_config_parameter",
|
||||||
|
"ir_mail_server",
|
||||||
|
"fetchmail_server",
|
||||||
|
"res_users_apikeys",
|
||||||
|
"payment_provider",
|
||||||
|
"res_users_identitycheck",
|
||||||
|
]
|
||||||
|
|
||||||
|
def connect(dbname, user, password):
|
||||||
|
conn = psycopg2.connect(
|
||||||
|
host=HOST, port=PORT, dbname=dbname, user=user, password=password,
|
||||||
|
connect_timeout=10,
|
||||||
|
)
|
||||||
|
conn.autocommit = True
|
||||||
|
return conn
|
||||||
|
|
||||||
|
def wait_for_pg():
|
||||||
|
for _ in range(90):
|
||||||
|
try:
|
||||||
|
connect("postgres", SUPER_USER, SUPER_PW).close()
|
||||||
|
return
|
||||||
|
except psycopg2.Error:
|
||||||
|
time.sleep(2)
|
||||||
|
sys.exit("postgres unreachable")
|
||||||
|
|
||||||
|
def tables(cur):
|
||||||
|
cur.execute(
|
||||||
|
"select table_name from information_schema.tables "
|
||||||
|
"where table_schema = 'public' and table_type = 'BASE TABLE'"
|
||||||
|
)
|
||||||
|
return {r[0] for r in cur.fetchall()}
|
||||||
|
|
||||||
|
def run(cmd, **kw):
|
||||||
|
print("+ " + " ".join(cmd), flush=True)
|
||||||
|
subprocess.run(cmd, check=True, **kw)
|
||||||
|
|
||||||
|
wait_for_pg()
|
||||||
|
|
||||||
|
conn = connect("postgres", SUPER_USER, SUPER_PW)
|
||||||
|
cur = conn.cursor()
|
||||||
|
cur.execute("select 1 from pg_database where datname = %s", (DB,))
|
||||||
|
exists = cur.fetchone() is not None
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
have_tables = False
|
||||||
|
if exists:
|
||||||
|
dconn = connect(DB, SUPER_USER, SUPER_PW)
|
||||||
|
dcur = dconn.cursor()
|
||||||
|
have_tables = bool(tables(dcur))
|
||||||
|
dconn.close()
|
||||||
|
|
||||||
|
if not have_tables:
|
||||||
|
print(f"== initialising {DB}: base,web (no demo data) ==", flush=True)
|
||||||
|
run(["odoo", "-c", CONF, "-d", DB, "-i", "base,web",
|
||||||
|
"--without-demo=all", "--stop-after-init", "--no-http"])
|
||||||
|
else:
|
||||||
|
print(f"== {DB} already initialised: skipping -i base ==", flush=True)
|
||||||
|
|
||||||
|
# unaccent as the database owner (trusted extension in PG16). Odoo uses it
|
||||||
|
# for accent-insensitive search in the web client.
|
||||||
|
oconn = connect(DB, "odoo", os.environ["ODOO_DB_PASSWORD"])
|
||||||
|
ocur = oconn.cursor()
|
||||||
|
ocur.execute("CREATE EXTENSION IF NOT EXISTS unaccent")
|
||||||
|
ocur.execute("select extname, extowner::regrole::text from pg_extension where extname = 'unaccent'")
|
||||||
|
print("unaccent:", ocur.fetchone(), flush=True)
|
||||||
|
oconn.close()
|
||||||
|
|
||||||
|
# Read-only BI grants + credential-table revokes.
|
||||||
|
gconn = connect(DB, SUPER_USER, SUPER_PW)
|
||||||
|
gcur = gconn.cursor()
|
||||||
|
# PostgreSQL 16 leaves CREATE on schema public granted to PUBLIC in a
|
||||||
|
# database created by a NON-SUPERUSER (Odoo creates its own database as
|
||||||
|
# `odoo`), so `default_transaction_read_only` is the only thing stopping
|
||||||
|
# metabase_ro from creating tables — and a role may lift its own default
|
||||||
|
# with `SET default_transaction_read_only = off`. Privileges are the real
|
||||||
|
# guard: PUBLIC loses CREATE, metabase_ro gets USAGE only.
|
||||||
|
gcur.execute("REVOKE CREATE ON SCHEMA public FROM PUBLIC")
|
||||||
|
gcur.execute("REVOKE ALL ON SCHEMA public FROM metabase_ro")
|
||||||
|
gcur.execute("GRANT USAGE ON SCHEMA public TO metabase_ro")
|
||||||
|
gcur.execute("GRANT SELECT ON ALL TABLES IN SCHEMA public TO metabase_ro")
|
||||||
|
gcur.execute(
|
||||||
|
"ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public "
|
||||||
|
"GRANT SELECT ON TABLES TO metabase_ro"
|
||||||
|
)
|
||||||
|
present = tables(gcur)
|
||||||
|
revoked = sorted({t for t in CREDENTIAL_TABLES if t in present})
|
||||||
|
# Inspect rather than assume the static list is complete: anything whose
|
||||||
|
# columns look like credentials is added to the revoke set (logged below).
|
||||||
|
gcur.execute(
|
||||||
|
"select distinct table_name from information_schema.columns "
|
||||||
|
"where table_schema = 'public' and ("
|
||||||
|
" column_name ~ '(^|_)(password|secret|token)($|_)' or "
|
||||||
|
" column_name ~ '(api_key|access_key|private_key)'"
|
||||||
|
") and table_name not in ('res_users', 'res_partner')"
|
||||||
|
)
|
||||||
|
for (t,) in gcur.fetchall():
|
||||||
|
if t in present and t not in revoked:
|
||||||
|
revoked.append(t)
|
||||||
|
revoked = sorted(revoked)
|
||||||
|
for t in revoked:
|
||||||
|
gcur.execute("REVOKE SELECT ON public.%s FROM metabase_ro" % t)
|
||||||
|
gcur.execute(
|
||||||
|
"select table_name from information_schema.table_privileges "
|
||||||
|
"where grantee = 'metabase_ro' and privilege_type = 'SELECT' "
|
||||||
|
"and table_schema = 'public' order by 1"
|
||||||
|
)
|
||||||
|
readable = len(gcur.fetchall())
|
||||||
|
gconn.close()
|
||||||
|
print(f"metabase_ro: SELECT granted on {readable} tables; "
|
||||||
|
f"revoked on {revoked}", flush=True)
|
||||||
|
|
||||||
|
# Admin login/password from Secret customer1/odoo-admin. `odoo shell` is
|
||||||
|
# the supported way to set a res.users password without hand-rolling a
|
||||||
|
# pbkdf2 hash. Re-writing the same value on every start is harmless.
|
||||||
|
payload = (
|
||||||
|
"u = env.ref('base.user_admin')\n"
|
||||||
|
f"u.write({{'login': {ADMIN_LOGIN!r}, 'password': {ADMIN_PASSWORD!r}}})\n"
|
||||||
|
"env.cr.commit()\n"
|
||||||
|
"print('admin uid', u.id, 'login', u.login)\n"
|
||||||
|
)
|
||||||
|
run(["odoo", "shell", "-c", CONF, "-d", DB, "--no-http",
|
||||||
|
"--shell-interface=python"], input=payload, text=True)
|
||||||
|
|
||||||
|
print("== provisioning complete ==", flush=True)
|
||||||
261
apps/base/customer1/odoo.yaml
Normal file
261
apps/base/customer1/odoo.yaml
Normal file
|
|
@ -0,0 +1,261 @@
|
||||||
|
# Odoo 18 — the application half of the Customer 1 lab replica.
|
||||||
|
#
|
||||||
|
# Image is pinned to the DATED build, never `18.0`/`latest`: Odoo auto-migrates
|
||||||
|
# its database schema on start, so a floating tag turns a pod restart into an
|
||||||
|
# unplanned upgrade of a database you may be auditing.
|
||||||
|
#
|
||||||
|
# This image already ships wkhtmltopdf 0.12.6.1 (patched Qt) at
|
||||||
|
# /usr/local/bin/wkhtmltopdf, so PDF reports/ invoices render without a derived
|
||||||
|
# image. Verified 2026-11-22 — see README.
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: odoo-data
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
storageClassName: local-path
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
---
|
||||||
|
# Empty by default. This is where the client's custom modules are copied in
|
||||||
|
# (`kubectl cp ./module customer1/<odoo-pod>:/mnt/extra-addons/...`), which is
|
||||||
|
# why it is a PVC and not an emptyDir: a module installed from here must survive
|
||||||
|
# a pod restart, or the modules table and the addons path disagree and Odoo
|
||||||
|
# refuses to start the affected modules.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: odoo-extra-addons
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
storageClassName: local-path
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 5Gi
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: odoo
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
# Parked 2026-11-22: siriussec's 15 W adapter cannot carry this replica
|
||||||
|
# stack (Odoo + two JVM/Postgres processes) alongside the public gateway
|
||||||
|
# workloads. Set back to 1 to bring the client replica up; PVCs are kept.
|
||||||
|
replicas: 0
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: odoo
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: odoo
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
spec:
|
||||||
|
# Envoy has to reach the backend on the same node it serves from, and the
|
||||||
|
# filestore PVC is local-path (siriussec-only anyway).
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: siriussec
|
||||||
|
tolerations:
|
||||||
|
- key: dedicated
|
||||||
|
operator: Exists
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
initContainers:
|
||||||
|
# Odoo has no env-var support for db_password, so the config file is
|
||||||
|
# rendered from the ConfigMap template + the Secret on every pod start
|
||||||
|
# into an emptyDir. Runs as root only to fix PVC ownership (the image
|
||||||
|
# user is uid 100 / gid 101 and local-path hands out root-owned dirs).
|
||||||
|
- name: render-config
|
||||||
|
image: odoo:18.0-20261112
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 0
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
mkdir -p /mnt/extra-addons /var/lib/odoo /etc/odoo-runtime
|
||||||
|
chown -R 100:101 /var/lib/odoo /mnt/extra-addons
|
||||||
|
chmod 0755 /mnt/extra-addons
|
||||||
|
umask 077
|
||||||
|
cat > /etc/odoo-runtime/odoo.conf <<EOF
|
||||||
|
[options]
|
||||||
|
admin_passwd = ${ODOO_ADMIN_PASSWD}
|
||||||
|
addons_path = /mnt/extra-addons,/mnt/enterprise-addons,/usr/lib/python3/dist-packages/odoo/addons
|
||||||
|
data_dir = /var/lib/odoo
|
||||||
|
db_host = ${DB_HOST}
|
||||||
|
db_port = ${DB_PORT}
|
||||||
|
db_name = odoo
|
||||||
|
db_user = odoo
|
||||||
|
db_password = ${ODOO_DB_PASSWORD}
|
||||||
|
dbfilter = ^odoo\$
|
||||||
|
list_db = False
|
||||||
|
proxy_mode = True
|
||||||
|
workers = 0
|
||||||
|
limit_memory_hard = 1610612736
|
||||||
|
limit_memory_soft = 1342177280
|
||||||
|
max_cron_threads = 1
|
||||||
|
log_level = info
|
||||||
|
log_handler = :INFO
|
||||||
|
xmlrpc_port = 8069
|
||||||
|
EOF
|
||||||
|
chown 100:101 /etc/odoo-runtime/odoo.conf
|
||||||
|
env:
|
||||||
|
- name: DB_HOST
|
||||||
|
value: pg
|
||||||
|
- name: DB_PORT
|
||||||
|
value: "5432"
|
||||||
|
- name: ODOO_DB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-users
|
||||||
|
key: odoo_password
|
||||||
|
- name: ODOO_ADMIN_PASSWD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: odoo-config
|
||||||
|
key: admin_passwd
|
||||||
|
volumeMounts:
|
||||||
|
- name: runtime-config
|
||||||
|
mountPath: /etc/odoo-runtime
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/odoo
|
||||||
|
- name: extra-addons
|
||||||
|
mountPath: /mnt/extra-addons
|
||||||
|
# "Init once". Idempotent: reinstalls nothing when the database already
|
||||||
|
# has tables, but always re-applies the BI grants/revokes and the admin
|
||||||
|
# credentials. Script lives in ConfigMap odoo-init.
|
||||||
|
- name: init-db
|
||||||
|
image: odoo:18.0-20261112
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command: ["python3", "/opt/init/init_db.py"]
|
||||||
|
env:
|
||||||
|
- name: DB_HOST
|
||||||
|
value: pg
|
||||||
|
- name: DB_PORT
|
||||||
|
value: "5432"
|
||||||
|
- name: ODOO_DB_NAME
|
||||||
|
value: odoo
|
||||||
|
- name: PG_SUPERUSER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: username
|
||||||
|
- name: PG_SUPERPASS
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: password
|
||||||
|
- name: ODOO_DB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-users
|
||||||
|
key: odoo_password
|
||||||
|
- name: ODOO_ADMIN_LOGIN
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: odoo-admin
|
||||||
|
key: email
|
||||||
|
- name: ODOO_ADMIN_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: odoo-admin
|
||||||
|
key: password
|
||||||
|
- name: TZ
|
||||||
|
value: America/Los_Angeles
|
||||||
|
volumeMounts:
|
||||||
|
- name: runtime-config
|
||||||
|
mountPath: /etc/odoo-runtime
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/odoo
|
||||||
|
- name: extra-addons
|
||||||
|
mountPath: /mnt/extra-addons
|
||||||
|
- name: enterprise-addons
|
||||||
|
mountPath: /mnt/enterprise-addons
|
||||||
|
- name: init-script
|
||||||
|
mountPath: /opt/init
|
||||||
|
containers:
|
||||||
|
- name: odoo
|
||||||
|
image: odoo:18.0-20261112
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command: ["odoo"]
|
||||||
|
args: ["-c", "/etc/odoo-runtime/odoo.conf"]
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 8069
|
||||||
|
env:
|
||||||
|
- name: TZ
|
||||||
|
value: America/Los_Angeles
|
||||||
|
- name: HOST
|
||||||
|
value: 0.0.0.0
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /web/login
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 20
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
livenessProbe:
|
||||||
|
tcpSocket:
|
||||||
|
port: http
|
||||||
|
initialDelaySeconds: 90
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 4
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 200m
|
||||||
|
memory: 512Mi
|
||||||
|
# workers=0 is a single process; the config's limit_memory_hard is
|
||||||
|
# 1.5 GiB, below this container limit, so Odoo throttles itself
|
||||||
|
# before the kernel OOM-kills the pod.
|
||||||
|
limits:
|
||||||
|
memory: 2Gi
|
||||||
|
volumeMounts:
|
||||||
|
- name: runtime-config
|
||||||
|
mountPath: /etc/odoo-runtime
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/odoo
|
||||||
|
- name: extra-addons
|
||||||
|
mountPath: /mnt/extra-addons
|
||||||
|
- name: enterprise-addons
|
||||||
|
mountPath: /mnt/enterprise-addons
|
||||||
|
volumes:
|
||||||
|
- name: runtime-config
|
||||||
|
emptyDir: {}
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: odoo-data
|
||||||
|
- name: extra-addons
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: odoo-extra-addons
|
||||||
|
# Empty, unused until the Enterprise licence question is answered. It
|
||||||
|
# exists so /mnt/enterprise-addons is already on addons_path the day an
|
||||||
|
# EE addons tree is dropped in, without a manifest change.
|
||||||
|
- name: enterprise-addons
|
||||||
|
emptyDir: {}
|
||||||
|
- name: init-script
|
||||||
|
configMap:
|
||||||
|
name: odoo-init
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: odoo
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: odoo
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 8069
|
||||||
|
targetPort: http
|
||||||
|
protocol: TCP
|
||||||
72
apps/base/customer1/postgres-init.yaml
Normal file
72
apps/base/customer1/postgres-init.yaml
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
# First-run provisioning for the lab Postgres: two databases (odoo, metabase)
|
||||||
|
# and three roles. Runs once, from postgres:16's /docker-entrypoint-initdb.d,
|
||||||
|
# only while PGDATA is empty.
|
||||||
|
#
|
||||||
|
# Why an init script instead of POSTGRES_DB/POSTGRES_USER: the stock image only
|
||||||
|
# knows one database and one role, and this namespace needs
|
||||||
|
# - `odoo` : owner of db `odoo`, CREATEDB (Odoo creates its own database
|
||||||
|
# on first `-i base` and needs the privilege to do it)
|
||||||
|
# - `metabase` : owner of db `metabase` (Metabase's own application DB)
|
||||||
|
# - `metabase_ro` : the read-only BI identity used in §4 of the card, with
|
||||||
|
# default_transaction_read_only + a statement timeout. Its
|
||||||
|
# SELECT grants over Odoo's tables are applied AFTER Odoo has
|
||||||
|
# installed them (the odoo Deployment's initContainer), because
|
||||||
|
# at this point the `odoo` database has no tables at all.
|
||||||
|
#
|
||||||
|
# Passwords arrive as env vars from Secret `customer1/pg-users` (out of band);
|
||||||
|
# nothing here is a credential literal.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: pg-init
|
||||||
|
namespace: customer1
|
||||||
|
data:
|
||||||
|
01-init-dbs.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
: "${ODOO_DB_PASSWORD:?}"
|
||||||
|
: "${METABASE_DB_PASSWORD:?}"
|
||||||
|
: "${METABASE_RO_PASSWORD:?}"
|
||||||
|
|
||||||
|
# Roles + databases. psql autocommits each statement, which CREATE DATABASE
|
||||||
|
# requires (it cannot run inside a transaction block).
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres \
|
||||||
|
-v odoo_pw="$ODOO_DB_PASSWORD" \
|
||||||
|
-v metabase_pw="$METABASE_DB_PASSWORD" \
|
||||||
|
-v ro_pw="$METABASE_RO_PASSWORD" <<'EOSQL'
|
||||||
|
CREATE ROLE odoo LOGIN CREATEDB PASSWORD :'odoo_pw';
|
||||||
|
CREATE ROLE metabase LOGIN PASSWORD :'metabase_pw';
|
||||||
|
CREATE ROLE metabase_ro LOGIN PASSWORD :'ro_pw' CONNECTION LIMIT 10;
|
||||||
|
|
||||||
|
-- Read-only BI identity: these are role-level defaults, so they hold for
|
||||||
|
-- every session Metabase opens, including ones it recycles.
|
||||||
|
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';
|
||||||
|
|
||||||
|
CREATE DATABASE odoo OWNER odoo;
|
||||||
|
CREATE DATABASE metabase OWNER metabase;
|
||||||
|
|
||||||
|
-- No cross-tenant CONNECT: the BI role reaches `odoo` only, the Metabase
|
||||||
|
-- application role never reaches `odoo`. (PUBLIC carries CONNECT on every
|
||||||
|
-- new database, which is the usual way a "read-only" role ends up able to
|
||||||
|
-- reach databases it was never granted.)
|
||||||
|
REVOKE CONNECT ON DATABASE odoo FROM PUBLIC;
|
||||||
|
GRANT CONNECT ON DATABASE odoo TO odoo, metabase_ro;
|
||||||
|
REVOKE CONNECT ON DATABASE metabase FROM PUBLIC;
|
||||||
|
GRANT CONNECT ON DATABASE metabase TO metabase;
|
||||||
|
EOSQL
|
||||||
|
|
||||||
|
# Schema-level setup in the (still empty) odoo database. Table grants and
|
||||||
|
# the credential-table revokes are (re)applied by the odoo initContainer.
|
||||||
|
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname odoo <<'EOSQL'
|
||||||
|
-- Odoo creates the `odoo` role's tables later; PUBLIC must not keep CREATE
|
||||||
|
-- on the public schema (PG16 keeps it when the database was made by a
|
||||||
|
-- non-superuser), or the "read-only" BI role can create tables after
|
||||||
|
-- lifting its own default_transaction_read_only.
|
||||||
|
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
|
||||||
|
GRANT USAGE ON SCHEMA public TO metabase_ro;
|
||||||
|
ALTER DEFAULT PRIVILEGES FOR ROLE odoo IN SCHEMA public
|
||||||
|
GRANT SELECT ON TABLES TO metabase_ro;
|
||||||
|
EOSQL
|
||||||
143
apps/base/customer1/postgres.yaml
Normal file
143
apps/base/customer1/postgres.yaml
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
# Plain PostgreSQL 16 — deliberately NOT CloudNativePG.
|
||||||
|
#
|
||||||
|
# The client runs Odoo against a plain Postgres on a Proxmox VM. This namespace
|
||||||
|
# is a *lab replica of that shape*, so the database is a bare container with a
|
||||||
|
# single local-path volume, no operator, no replicas, no WAL archive. Do not
|
||||||
|
# "improve" this into a CNPG Cluster: the point is to develop and audit against
|
||||||
|
# the client's actual architecture, not ours.
|
||||||
|
#
|
||||||
|
# Backups: none at the database level — no WAL archive, no replica, no PITR.
|
||||||
|
# The client's practice (a cron-driven `pg_dump` of the DB only) is mirrored by
|
||||||
|
# `backup.yaml` in this directory: nightly logical dumps, 14-day retention, on a
|
||||||
|
# node-local PVC, with the filestore deliberately NOT covered. See README.
|
||||||
|
# Do not "improve" this into a CNPG Cluster: the point is to develop and audit
|
||||||
|
# against the client's actual architecture, not ours.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: pg-data
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
accessModes: [ReadWriteOnce]
|
||||||
|
storageClassName: local-path
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 10Gi
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: pg
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
# Parked 2026-11-22 (power budget) — see apps/base/customer1/odoo.yaml.
|
||||||
|
# Recreate: the data directory must be released before anything restarts.
|
||||||
|
replicas: 0
|
||||||
|
strategy:
|
||||||
|
type: Recreate
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: pg
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: pg
|
||||||
|
app.kubernetes.io/part-of: customer1
|
||||||
|
spec:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: siriussec
|
||||||
|
tolerations:
|
||||||
|
- key: dedicated
|
||||||
|
operator: Exists
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
containers:
|
||||||
|
- name: postgres
|
||||||
|
image: postgres:16
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
args: ["-c", "max_connections=60"]
|
||||||
|
ports:
|
||||||
|
- name: postgres
|
||||||
|
containerPort: 5432
|
||||||
|
env:
|
||||||
|
- name: POSTGRES_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: username
|
||||||
|
- name: POSTGRES_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: password
|
||||||
|
# The bootstrap superuser's own database. `odoo` and `metabase` are
|
||||||
|
# created by the init script below.
|
||||||
|
- name: POSTGRES_DB
|
||||||
|
value: postgres
|
||||||
|
- name: PGDATA
|
||||||
|
value: /var/lib/postgresql/data/pgdata
|
||||||
|
# Consumed only by 01-init-dbs.sh on first start.
|
||||||
|
- name: ODOO_DB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-users
|
||||||
|
key: odoo_password
|
||||||
|
- name: METABASE_DB_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-users
|
||||||
|
key: metabase_password
|
||||||
|
- name: METABASE_RO_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-users
|
||||||
|
key: metabase_ro_password
|
||||||
|
- name: TZ
|
||||||
|
value: America/Los_Angeles
|
||||||
|
readinessProbe:
|
||||||
|
exec:
|
||||||
|
command: ["pg_isready", "-U", "postgres", "-d", "postgres"]
|
||||||
|
initialDelaySeconds: 5
|
||||||
|
periodSeconds: 5
|
||||||
|
timeoutSeconds: 3
|
||||||
|
livenessProbe:
|
||||||
|
exec:
|
||||||
|
command: ["pg_isready", "-U", "postgres", "-d", "postgres"]
|
||||||
|
initialDelaySeconds: 60
|
||||||
|
periodSeconds: 20
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 4
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
limits:
|
||||||
|
memory: 1Gi
|
||||||
|
volumeMounts:
|
||||||
|
- name: data
|
||||||
|
mountPath: /var/lib/postgresql/data
|
||||||
|
- name: initdb
|
||||||
|
mountPath: /docker-entrypoint-initdb.d
|
||||||
|
readOnly: true
|
||||||
|
volumes:
|
||||||
|
- name: data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: pg-data
|
||||||
|
- name: initdb
|
||||||
|
configMap:
|
||||||
|
name: pg-init
|
||||||
|
defaultMode: 0555
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: pg
|
||||||
|
namespace: customer1
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: pg
|
||||||
|
ports:
|
||||||
|
- name: postgres
|
||||||
|
port: 5432
|
||||||
|
targetPort: postgres
|
||||||
|
protocol: TCP
|
||||||
32
apps/base/forgejo/custom-public.yaml
Normal file
32
apps/base/forgejo/custom-public.yaml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Custom "public" assets served at the site root by Forgejo.
|
||||||
|
#
|
||||||
|
# GITEA_CUSTOM in the image is /data/gitea, so Forgejo serves
|
||||||
|
# /data/gitea/public/* at the root path. Mounting this ConfigMap there makes
|
||||||
|
# /robots.txt declarative instead of a hand-written file on the PVC
|
||||||
|
# (docs: forgejo.org/docs/latest/admin/advanced/search-engines-indexation).
|
||||||
|
#
|
||||||
|
# Why: self-registration was open until 2026-11-20 and spam profiles
|
||||||
|
# (/leonabrewton8, /charlinebrando, .../-/packages) were indexed by Google.
|
||||||
|
# The accounts are gone, but Forgejo's built-in robots.txt only disallows
|
||||||
|
# /explore/*?* (query strings) and /user/, leaving /explore/repos and
|
||||||
|
# /search crawlable. This keeps the owner's portfolio repos (/sirius/*)
|
||||||
|
# indexable and everything else out.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: forgejo-custom-public
|
||||||
|
namespace: forgejo
|
||||||
|
data:
|
||||||
|
robots.txt: |
|
||||||
|
# forgejo.siriusdevops.com
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /explore/*
|
||||||
|
Disallow: /user/*
|
||||||
|
Disallow: /search*
|
||||||
|
Disallow: /api/*
|
||||||
|
Disallow: /*/-/packages
|
||||||
|
Disallow: /repo/create
|
||||||
|
Disallow: /repo/migrate
|
||||||
|
Disallow: /org/create
|
||||||
|
|
||||||
|
Allow: /sirius/*
|
||||||
|
|
@ -55,9 +55,17 @@ spec:
|
||||||
value: "true"
|
value: "true"
|
||||||
- name: FORGEJO__packages__ENABLED
|
- name: FORGEJO__packages__ENABLED
|
||||||
value: "true"
|
value: "true"
|
||||||
|
# Bot signup lockdown: admin-only account creation (web + API).
|
||||||
|
- name: FORGEJO__service__DISABLE_REGISTRATION
|
||||||
|
value: "true"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: data
|
- name: data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
|
# Custom site-root assets (robots.txt). GITEA_CUSTOM=/data/gitea,
|
||||||
|
# so Forgejo serves /data/gitea/public/robots.txt at /robots.txt.
|
||||||
|
- name: custom-public
|
||||||
|
mountPath: /data/gitea/public
|
||||||
|
readOnly: true
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /
|
path: /
|
||||||
|
|
@ -74,3 +82,6 @@ spec:
|
||||||
- name: data
|
- name: data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: forgejo-data
|
claimName: forgejo-data
|
||||||
|
- name: custom-public
|
||||||
|
configMap:
|
||||||
|
name: forgejo-custom-public
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ resources:
|
||||||
- cluster.yaml
|
- cluster.yaml
|
||||||
- podmonitor.yaml
|
- podmonitor.yaml
|
||||||
- pg-actions-queries.yaml
|
- pg-actions-queries.yaml
|
||||||
|
# Site-root custom assets (robots.txt) mounted into the forgejo pod.
|
||||||
|
- custom-public.yaml
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
- service.yaml
|
- service.yaml
|
||||||
- runner-configmap.yaml
|
- runner-configmap.yaml
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,11 @@ spec:
|
||||||
cpu: 200m
|
cpu: 200m
|
||||||
memory: 512Mi
|
memory: 512Mi
|
||||||
limits:
|
limits:
|
||||||
|
# Hard ceiling on CI burst draw: siriussec is a laptop on a 15 W
|
||||||
|
# USB-C supply, and dind previously had no CPU limit, so one
|
||||||
|
# Android/x86_64 build could pin all 8 threads (~25 W package)
|
||||||
|
# and drain the battery faster than the adapter refills it.
|
||||||
|
cpu: 3
|
||||||
memory: 4Gi
|
memory: 4Gi
|
||||||
- name: runner
|
- name: runner
|
||||||
image: code.forgejo.org/forgejo/runner:5.0.1
|
image: code.forgejo.org/forgejo/runner:5.0.1
|
||||||
|
|
|
||||||
38
apps/base/metabase/cluster.yaml
Normal file
38
apps/base/metabase/cluster.yaml
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Metabase's application database (its own metadata only: users, dashboards,
|
||||||
|
# questions, saved queries — never the data it queries).
|
||||||
|
#
|
||||||
|
# Same shape as every other CNPG cluster in this repo: one instance, local-path
|
||||||
|
# on siriussec, no superuser access. `bootstrap.initdb.secret` names the
|
||||||
|
# out-of-band Secret `metabase/pg-app` (kubernetes.io/basic-auth, username
|
||||||
|
# `metabase` — CNPG requires the secret's username to equal `owner`). The
|
||||||
|
# operator materialises `pg-app` with the same credentials for the Deployment.
|
||||||
|
#
|
||||||
|
# No barman ObjectStore yet: the other clusters get WAL archiving to Garage via
|
||||||
|
# the CNPG-I Barman Cloud plugin; this evaluation instance is deliberately left
|
||||||
|
# with no archive until Lance keeps it (follow-up card, not a silent gap).
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: pg
|
||||||
|
namespace: metabase
|
||||||
|
spec:
|
||||||
|
instances: 1
|
||||||
|
imageName: ghcr.io/cloudnative-pg/postgresql:16
|
||||||
|
storage:
|
||||||
|
size: 5Gi
|
||||||
|
storageClass: local-path
|
||||||
|
affinity:
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: siriussec
|
||||||
|
bootstrap:
|
||||||
|
initdb:
|
||||||
|
database: metabase
|
||||||
|
owner: metabase
|
||||||
|
secret:
|
||||||
|
name: pg-app
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 256Mi
|
||||||
|
limits:
|
||||||
|
memory: 1Gi
|
||||||
87
apps/base/metabase/deployment.yaml
Normal file
87
apps/base/metabase/deployment.yaml
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: metabase
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: metabase
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: metabase
|
||||||
|
spec:
|
||||||
|
# Siriussec is the only gateway node (upstream Envoy has to reach the
|
||||||
|
# backend pod on the same node), and the CNPG primary is pinned here too.
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: siriussec
|
||||||
|
tolerations:
|
||||||
|
- key: dedicated
|
||||||
|
operator: Exists
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
containers:
|
||||||
|
- name: metabase
|
||||||
|
# Pinned release tag (2026-11-20, multi-arch). Never latest/nightly:
|
||||||
|
# Metabase auto-migrates its app DB on start, so an unpinned tag turns
|
||||||
|
# a pod restart into a schema upgrade.
|
||||||
|
image: metabase/metabase:v0.65.6.3
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
containerPort: 3000
|
||||||
|
env:
|
||||||
|
# One JVM, 1.5 GiB heap, container limit 2 GiB. The laptop is on a
|
||||||
|
# marginal USB-C supply; a 2 GiB heap here is what starved it in the
|
||||||
|
# past (see references/laptop-node-power.md).
|
||||||
|
- name: JAVA_OPTS
|
||||||
|
value: "-Xmx1536m"
|
||||||
|
# All state lives in Postgres (no H2 file, no PVC), so the pod is
|
||||||
|
# disposable and `strategy: Recreate` is unnecessary.
|
||||||
|
- name: MB_DB_TYPE
|
||||||
|
value: postgres
|
||||||
|
- name: MB_DB_HOST
|
||||||
|
value: pg-rw.metabase.svc.cluster.local
|
||||||
|
- name: MB_DB_PORT
|
||||||
|
value: "5432"
|
||||||
|
- name: MB_DB_DBNAME
|
||||||
|
value: metabase
|
||||||
|
- name: MB_DB_USER
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: username
|
||||||
|
- name: MB_DB_PASS
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: pg-app
|
||||||
|
key: password
|
||||||
|
readinessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: 3000
|
||||||
|
# The JVM takes ~30-60 s to migrate/bootstrap its app DB.
|
||||||
|
initialDelaySeconds: 20
|
||||||
|
periodSeconds: 10
|
||||||
|
timeoutSeconds: 5
|
||||||
|
failureThreshold: 6
|
||||||
|
livenessProbe:
|
||||||
|
httpGet:
|
||||||
|
path: /api/health
|
||||||
|
port: 3000
|
||||||
|
initialDelaySeconds: 120
|
||||||
|
periodSeconds: 30
|
||||||
|
timeoutSeconds: 10
|
||||||
|
failureThreshold: 3
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 1Gi
|
||||||
|
limits:
|
||||||
|
# 2 → 1: two Metabase JVMs on the gateway node could together
|
||||||
|
# burst to 4 threads on a 15 W adapter. 1 core each keeps the
|
||||||
|
# node inside its power budget; UI latency is unaffected at this
|
||||||
|
# query volume.
|
||||||
|
cpu: "1"
|
||||||
|
memory: 2Gi
|
||||||
25
apps/base/metabase/httproute.yaml
Normal file
25
apps/base/metabase/httproute.yaml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Internal only, and deliberately HOSTNAME-LESS: it answers on the bare WireGuard
|
||||||
|
# address http://10.10.0.2:8085/ for every Host header. Phones cannot edit
|
||||||
|
# /etc/hosts, so a hostname would make the evaluation unusable on mobile.
|
||||||
|
#
|
||||||
|
# parentRefs is the dedicated `metabase` Gateway (infrastructure/networking/
|
||||||
|
# internal/gateway-metabase.yaml), NOT the shared `internal` one: Cilium merges
|
||||||
|
# every hostname-less route of a Gateway into one weighted route, so sharing a
|
||||||
|
# Gateway with Grafana would serve both services on both ports at random.
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: HTTPRoute
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: metabase
|
||||||
|
spec:
|
||||||
|
parentRefs:
|
||||||
|
- name: metabase
|
||||||
|
namespace: internal
|
||||||
|
rules:
|
||||||
|
- matches:
|
||||||
|
- path:
|
||||||
|
type: PathPrefix
|
||||||
|
value: /
|
||||||
|
backendRefs:
|
||||||
|
- name: metabase
|
||||||
|
port: 3000
|
||||||
10
apps/base/metabase/kustomization.yaml
Normal file
10
apps/base/metabase/kustomization.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
# Secret metabase/pg-app (kubernetes.io/basic-auth) is created out of band
|
||||||
|
# before this Cluster applies — CNPG's initdb reads it.
|
||||||
|
- cluster.yaml
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
- httproute.yaml
|
||||||
6
apps/base/metabase/namespace.yaml
Normal file
6
apps/base/metabase/namespace.yaml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
labels:
|
||||||
|
app.kubernetes.io/part-of: metabase
|
||||||
14
apps/base/metabase/service.yaml
Normal file
14
apps/base/metabase/service.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: metabase
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: metabase
|
||||||
|
ports:
|
||||||
|
- name: http
|
||||||
|
port: 3000
|
||||||
|
targetPort: 3000
|
||||||
|
protocol: TCP
|
||||||
|
|
@ -8,32 +8,44 @@ instead of a host Docker container on the Pi.
|
||||||
|
|
||||||
| Deployment | Image | Purpose |
|
| Deployment | Image | Purpose |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2` | TimescaleDB 2 + PostGIS 3 on Postgres 16, `local-path` PVC `osint-pgdata` 15 Gi |
|
| `osint-db` | `forgejo…/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3` | TimescaleDB 2.32.1 + PostGIS 3 on Postgres 16.16, `local-path-linode` PVC `osint-pgdata-linode` 15 Gi |
|
||||||
| `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) |
|
| `osint-nats` | `forgejo…/sirius/nats:2.10` | JetStream event bus (`-js -m 8222`) |
|
||||||
| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-58f71f5b4520` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations |
|
| `osint-app` | `forgejo…/sirius/osint-dashboard:amd64-915f6cbe25be` | FastAPI + static HUD; runs `alembic upgrade heads` on start; single-admin auth (`app/auth.py`) — public read-only site, admin-only keys/settings/mutations |
|
||||||
| `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres |
|
| `osint-ingester` | same app image | RSS/GDELT/USGS/FIRMS/vessel ingest → NATS → Postgres |
|
||||||
| `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) |
|
| `osint-camera-service` | same app image | public-camera discovery + snapshots (PVC `osint-camera-snapshots` 3 Gi, shared with the app) |
|
||||||
| `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` |
|
| `osint-titiler` | `forgejo…/sirius/titiler:0.26.0` | SAR COG tile proxy, exposed same-origin at `/titiler` |
|
||||||
| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop |
|
| `osint-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop |
|
||||||
| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-d04ddc9afacb` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap |
|
| `osint-news-summarizer` | `forgejo…/sirius/osint-news-summarizer:amd64-fe2b5df369d0` | "analyst" — Nous Portal briefs every 15 min + 23:00 recap |
|
||||||
|
|
||||||
Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy
|
Every workload is pinned to `kubernetes.io/hostname: siriussec` (Gateway/Envoy
|
||||||
co-location + local-path PVs).
|
co-location + local-path PVs).
|
||||||
|
|
||||||
## Images
|
## Images
|
||||||
|
|
||||||
The upstream CI (`.forgejo/workflows/build.yml` in `sirius/osint-dashboard`)
|
**CI builds the cluster images.** Since PR #63 in `sirius/osint-dashboard`,
|
||||||
builds **arm64** for the Pi via `runs-on: docker`. The cluster is amd64, so the
|
`.forgejo/workflows/build.yml` runs on the `amd64` runner (`runs-on: amd64`),
|
||||||
cluster images were built on an amd64 host and pushed to the Forgejo registry
|
tags `amd64-<sha12>`, and pushes straight into the in-cluster registry
|
||||||
over a `kubectl -n forgejo port-forward svc/forgejo 3000:3000` (Cloudflare
|
(`forgejo.forgejo.svc.cluster.local:3000`, plain HTTP, whitelisted by
|
||||||
rejects layer uploads ≳100 MB on the public hostname). **Build from a detached
|
`--insecure-registry` on the runner's dind). Deploying is then just a pin
|
||||||
worktree at the merge sha, never from the main checkout** — Legion's
|
change here in `apps/base/osint/` — check the run's `## Pin in homek8s` summary
|
||||||
`~/osint-dashboard` sits on a feature branch, and a `docker build` there once
|
for the exact tags. Builds are **path-filtered**, so one image can be several
|
||||||
produced a `:amd64-<sha>` image that carried the right tag and none of the
|
commits older than another: the app tag is normally master tip, the summarizer
|
||||||
commit's code (that tag was deleted from the registry; `-r1` is the real build).
|
tag is whichever commit last touched `news/summerizer/`.
|
||||||
|
|
||||||
|
Do not build these by hand and push over a `:amd64-<sha>` tag: that replaces
|
||||||
|
CI's manifest, and Forgejo's registry garbage-collects the displaced digest, so
|
||||||
|
the CI artifact cannot be pulled back. If you need a tag rebuilt, dispatch CI
|
||||||
|
instead: `POST /api/v1/repos/sirius/osint-dashboard/actions/workflows/build.yml/dispatches`
|
||||||
|
with `{"ref":"master","inputs":{"rebuild_all":"true"}}`.
|
||||||
|
|
||||||
|
Manual builds exist only as a historical fallback (pre-#63 images, or a CI
|
||||||
|
outage) — and then **build from a detached worktree at the merge sha, never
|
||||||
|
from the main checkout**: Legion's `~/osint-dashboard` sits on a feature
|
||||||
|
branch, and a `docker build` there once produced a `:amd64-<sha>` image that
|
||||||
|
carried the right tag and none of the commit's code.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# from the manifests repo root; build the merge sha, not whatever the checkout has
|
# fallback only — the normal path is: let CI build, then pin the tag here
|
||||||
git -C ~/osint-dashboard fetch origin
|
git -C ~/osint-dashboard fetch origin
|
||||||
git -C ~/osint-dashboard worktree add --detach /tmp/osint-build origin/master
|
git -C ~/osint-dashboard worktree add --detach /tmp/osint-build origin/master
|
||||||
cd /tmp/osint-build && SHA=$(git rev-parse --short=12 HEAD) && TAG="amd64-$SHA"
|
cd /tmp/osint-build && SHA=$(git rev-parse --short=12 HEAD) && TAG="amd64-$SHA"
|
||||||
|
|
@ -44,13 +56,23 @@ docker build -f pg-image/Dockerfile -t 127.0.0.1:3000/sirius/osint-das
|
||||||
```
|
```
|
||||||
|
|
||||||
`pg-image/Dockerfile` is the cluster copy of `Dockerfile.pg`. **It pins
|
`pg-image/Dockerfile` is the cluster copy of `Dockerfile.pg`. **It pins
|
||||||
`postgres:16-bookworm`**: the upstream file's bare `postgres:16` now resolves to
|
`postgres:16.16-bookworm`**: the upstream file's bare `postgres:16` now resolves
|
||||||
Debian trixie, whose `postgresql-16-postgis-3` (3.7.0+pgdg13) fails to load
|
to Debian trixie, whose `postgresql-16-postgis-3` (3.7.0+pgdg13) fails to load
|
||||||
against PG 16.15 with `undefined symbol: heap_datum_check` — `CREATE EXTENSION
|
against PG 16.15 with `undefined symbol: heap_datum_check` — `CREATE EXTENSION
|
||||||
postgis` crashes the server. On bookworm (`+pgdg12`) PostGIS 3.7 loads and
|
postgis` crashes the server. On bookworm (`+pgdg12`) PostGIS 3.7 loads and
|
||||||
`create_hypertable()` works. Port the one-line base-image pin upstream when the
|
`create_hypertable()` works. Port the one-line base-image pin upstream when the
|
||||||
Pi stack is next rebuilt.
|
Pi stack is next rebuilt.
|
||||||
|
|
||||||
|
It also pins the TimescaleDB packages to `2.32.1~debian12-1616` (the `-1616`
|
||||||
|
suffix = built against PG 16.16) and the base image to the 16.16 minor. PG
|
||||||
|
16.16 added the `PortalDrop()` "cannot drop portal while it is being set up"
|
||||||
|
check that TimescaleDB <=2.32.0 trips in its background-worker path, so every
|
||||||
|
policy job failed with SQLSTATE 24000 while `CALL run_job()` worked
|
||||||
|
(timescale/timescaledb#11038, fixed in 2.31.2/2.32.1). Never unpin either half:
|
||||||
|
a pg minor bump without a matching TimescaleDB build reintroduces the failure.
|
||||||
|
`-r3` is that build. After a pod recreate the extension itself still has to be
|
||||||
|
moved: `ALTER EXTENSION timescaledb UPDATE TO '2.32.1'`.
|
||||||
|
|
||||||
## Secrets (never in git)
|
## Secrets (never in git)
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ spec:
|
||||||
initContainers:
|
initContainers:
|
||||||
# Wait for Postgres before alembic runs (the entrypoint migrates).
|
# Wait for Postgres before alembic runs (the entrypoint migrates).
|
||||||
- name: wait-for-db
|
- name: wait-for-db
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520
|
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-54897b49bc57
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command:
|
command:
|
||||||
- python
|
- python
|
||||||
|
|
@ -42,7 +42,7 @@ spec:
|
||||||
sys.exit("postgres did not become reachable in 300s")
|
sys.exit("postgres did not become reachable in 300s")
|
||||||
containers:
|
containers:
|
||||||
- name: app
|
- name: app
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520
|
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-54897b49bc57
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8000
|
- containerPort: 8000
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: camera-service
|
- name: camera-service
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520
|
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["python", "app/run_camera_service.py"]
|
command: ["python", "app/run_camera_service.py"]
|
||||||
envFrom:
|
envFrom:
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,15 @@ data:
|
||||||
VESSELAPI_IN_APP: "0"
|
VESSELAPI_IN_APP: "0"
|
||||||
VESSELAPI_IN_INGEST: "1"
|
VESSELAPI_IN_INGEST: "1"
|
||||||
|
|
||||||
|
# ── ADS-B refresh (osint-app `_adsb_refresh_loop`) ──────────────────────
|
||||||
|
# The loop polls ADSB.lol for each connected browser viewport. With no tab
|
||||||
|
# open it used to persist nothing, and aircraft_positions stalled for a day
|
||||||
|
# (max(ts) frozen 2026-11-20 04:58 -> 2026-11-21) while USGS/news kept
|
||||||
|
# ingesting. While idle it now sweeps the chokepoint presets instead.
|
||||||
|
ADSB_REFRESH_INTERVAL: "8"
|
||||||
|
ADSB_WATCH_ENABLED: "1"
|
||||||
|
ADSB_WATCH_INTERVAL: "30"
|
||||||
|
|
||||||
# ── camera discovery service ────────────────────────────────────────────
|
# ── camera discovery service ────────────────────────────────────────────
|
||||||
CAMERA_SOURCE_URLS: ""
|
CAMERA_SOURCE_URLS: ""
|
||||||
CAMERA_SCRAPE_INTERVAL: "3600"
|
CAMERA_SCRAPE_INTERVAL: "3600"
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,25 @@ spec:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Exists
|
operator: Exists
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
# Prefer the amd64 worker (linode) for these stateless CPU loops so
|
||||||
|
# they stop drawing on the 15 W-powered ThinkPad. Preferred, not
|
||||||
|
# required: if linode is absent they still schedule on siriussec.
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- linode
|
||||||
|
# keeps these off the arm64 rpi (some of these images are amd64-only)
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/arch: amd64
|
||||||
containers:
|
containers:
|
||||||
- name: ingester
|
- name: ingester
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-58f71f5b4520
|
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-76035535bcb2
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["python", "app/run_ingester.py"]
|
command: ["python", "app/run_ingester.py"]
|
||||||
envFrom:
|
envFrom:
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ resources:
|
||||||
- namespace.yaml
|
- namespace.yaml
|
||||||
- configmap.yaml
|
- configmap.yaml
|
||||||
- postgres-pvc.yaml
|
- postgres-pvc.yaml
|
||||||
|
- postgres-pvc-linode.yaml
|
||||||
- postgres-deployment.yaml
|
- postgres-deployment.yaml
|
||||||
- postgres-service.yaml
|
- postgres-service.yaml
|
||||||
- nats-deployment.yaml
|
- nats-deployment.yaml
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,22 @@ spec:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Exists
|
operator: Exists
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
# Prefer the amd64 worker (linode) for these stateless CPU loops so
|
||||||
|
# they stop drawing on the 15 W-powered ThinkPad. Preferred, not
|
||||||
|
# required: if linode is absent they still schedule on siriussec.
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- linode
|
||||||
|
# keeps these off the arm64 rpi (some of these images are amd64-only)
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/arch: amd64
|
||||||
containers:
|
containers:
|
||||||
- name: nats
|
- name: nats
|
||||||
image: forgejo.siriusdevops.com/sirius/nats:2.10
|
image: forgejo.siriusdevops.com/sirius/nats:2.10
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,22 @@ spec:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Exists
|
operator: Exists
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
# Prefer the amd64 worker (linode) for these stateless CPU loops so
|
||||||
|
# they stop drawing on the 15 W-powered ThinkPad. Preferred, not
|
||||||
|
# required: if linode is absent they still schedule on siriussec.
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- linode
|
||||||
|
# keeps these off the arm64 rpi (some of these images are amd64-only)
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/arch: amd64
|
||||||
containers:
|
containers:
|
||||||
- name: news-scraper
|
- name: news-scraper
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-58f71f5b4520
|
image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-58f71f5b4520
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,25 @@ spec:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Exists
|
operator: Exists
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
# Prefer the amd64 worker (linode) for these stateless CPU loops so
|
||||||
|
# they stop drawing on the 15 W-powered ThinkPad. Preferred, not
|
||||||
|
# required: if linode is absent they still schedule on siriussec.
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- weight: 100
|
||||||
|
preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- linode
|
||||||
|
# keeps these off the arm64 rpi (some of these images are amd64-only)
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/arch: amd64
|
||||||
containers:
|
containers:
|
||||||
- name: news-summarizer
|
- name: news-summarizer
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-d04ddc9afacb
|
image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
# Loop: batch the last window, call Nous Portal, write summaries.
|
# Loop: batch the last window, call Nous Portal, write summaries.
|
||||||
command: ["python", "run_news_summarizer.py"]
|
command: ["python", "run_news_summarizer.py"]
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,32 @@
|
||||||
# Cluster build of the OSINT Postgres image (amd64).
|
# Cluster build of the OSINT Postgres image (amd64).
|
||||||
#
|
#
|
||||||
# Identical to `Dockerfile.pg` in sirius/osint-dashboard EXCEPT the base image
|
# Identical to `Dockerfile.pg` in sirius/osint-dashboard EXCEPT the base image
|
||||||
# is pinned to bookworm. The upstream `FROM postgres:16` now resolves to Debian
|
# is pinned to Debian bookworm AND to the 16.16 minor. The upstream file's bare
|
||||||
# trixie, where postgresql-16-postgis-3 (3.7.0+pgdg13) fails to load against
|
# `FROM postgres:16` now resolves to Debian trixie, where
|
||||||
# PostgreSQL 16.15:
|
# postgresql-16-postgis-3 (3.7.0+pgdg13) fails to load against PostgreSQL 16.15:
|
||||||
# could not load library "/usr/lib/postgresql/16/lib/postgis-3.so":
|
# could not load library "/usr/lib/postgresql/16/lib/postgis-3.so":
|
||||||
# undefined symbol: heap_datum_check
|
# undefined symbol: heap_datum_check
|
||||||
# On bookworm (+pgdg12) both extensions load and create_hypertable() works.
|
# On bookworm (+pgdg12) both extensions load and create_hypertable() works.
|
||||||
FROM postgres:16-bookworm
|
#
|
||||||
|
# PostgreSQL minor and the TimescaleDB package build MUST match. TimescaleDB
|
||||||
|
# publishes one .so per PG minor (the packagecloud suffix `-1616` means built
|
||||||
|
# against 16.16). PostgreSQL 16.16/17.12/18.7 added the PortalDrop() "while it
|
||||||
|
# is being set up" check, which the <=2.32.0 background scheduler trips on, so
|
||||||
|
# every policy job fails with `cannot drop portal ""` (timescale#11038, fixed
|
||||||
|
# in 2.32.1). Both halves are pinned here so a rebuild cannot silently drift
|
||||||
|
# back onto a mismatched pair.
|
||||||
|
#
|
||||||
|
# Resulting versions: PostgreSQL 16.16, postgis 3.7.0, timescaledb 2.32.1.
|
||||||
|
# After a pod recreate run `ALTER EXTENSION timescaledb UPDATE TO '2.32.1'`.
|
||||||
|
FROM postgres:16.16-bookworm
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
ca-certificates curl gnupg lsb-release && \
|
ca-certificates curl gnupg lsb-release && \
|
||||||
curl -fsSL https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash && \
|
curl -fsSL https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash && \
|
||||||
apt-get update && apt-get install -y --no-install-recommends \
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
postgresql-16-postgis-3 timescaledb-2-postgresql-16 && \
|
postgresql-16-postgis-3 \
|
||||||
|
timescaledb-2-postgresql-16=2.32.1~debian12-1616 \
|
||||||
|
timescaledb-2-loader-postgresql-16=2.32.1~debian12-1616 && \
|
||||||
mkdir -p /etc/postgresql/16/main/conf.d && \
|
mkdir -p /etc/postgresql/16/main/conf.d && \
|
||||||
echo "shared_preload_libraries = 'timescaledb'" > /etc/postgresql/16/main/conf.d/timescaledb.conf && \
|
echo "shared_preload_libraries = 'timescaledb'" > /etc/postgresql/16/main/conf.d/timescaledb.conf && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,23 @@ spec:
|
||||||
- key: dedicated
|
- key: dedicated
|
||||||
operator: Exists
|
operator: Exists
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
|
# Local-path volume: the claim (osint-pgdata-linode) is pinned to linode by
|
||||||
|
# its PV, so the pod must be too. arch selector documents why: the image is
|
||||||
|
# amd64-only, as on every other node this can land on.
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/arch: amd64
|
||||||
|
affinity:
|
||||||
|
nodeAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: kubernetes.io/hostname
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- linode
|
||||||
containers:
|
containers:
|
||||||
- name: postgres
|
- name: postgres
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r2
|
image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
args:
|
args:
|
||||||
- -c
|
- -c
|
||||||
|
|
@ -48,6 +60,12 @@ spec:
|
||||||
value: osint
|
value: osint
|
||||||
- name: POSTGRES_DB
|
- name: POSTGRES_DB
|
||||||
value: osint_data
|
value: osint_data
|
||||||
|
# Bare `psql`/`pg_dump -U osint` inside this pod would otherwise
|
||||||
|
# default the database to the USER name and log
|
||||||
|
# `FATAL: database "osint" does not exist` (seen 2026-11-21 22:15
|
||||||
|
# on deploy/osint-db). PGDATABASE makes the correct db the default.
|
||||||
|
- name: PGDATABASE
|
||||||
|
value: osint_data
|
||||||
- name: PGDATA
|
- name: PGDATA
|
||||||
value: /var/lib/postgresql/data/pgdata
|
value: /var/lib/postgresql/data/pgdata
|
||||||
- name: POSTGRES_PASSWORD
|
- name: POSTGRES_PASSWORD
|
||||||
|
|
@ -79,4 +97,4 @@ spec:
|
||||||
volumes:
|
volumes:
|
||||||
- name: pgdata
|
- name: pgdata
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: osint-pgdata
|
claimName: osint-pgdata-linode
|
||||||
|
|
|
||||||
16
apps/base/osint/postgres-pvc-linode.yaml
Normal file
16
apps/base/osint/postgres-pvc-linode.yaml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Post-migration home for osint-db: a linode-local volume.
|
||||||
|
# Kept separate from postgres-pvc.yaml (osint-pgdata, on siriussec) so a
|
||||||
|
# rollback is one revert of the Deployment's claimName; the old claim and its
|
||||||
|
# PV stay untouched and Bound.
|
||||||
|
apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: osint-pgdata-linode
|
||||||
|
namespace: osint
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
storageClassName: local-path-linode
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: 15Gi
|
||||||
|
|
@ -24,6 +24,38 @@ spec:
|
||||||
memory: 256Mi
|
memory: 256Mi
|
||||||
limits:
|
limits:
|
||||||
memory: 1Gi
|
memory: 1Gi
|
||||||
|
# ---------------------------------------------------------------------------
|
||||||
|
# Point-in-time recovery: continuous WAL archiving + daily base backups into
|
||||||
|
# Garage on the Linode hub (10.10.0.5), i.e. a different power and internet
|
||||||
|
# domain from this primary. Companion objects: ObjectStore portal-wal (the
|
||||||
|
# store + 14d retention) and ScheduledBackup portal-daily.
|
||||||
|
#
|
||||||
|
# This is the CNPG-I Barman Cloud **plugin** (Deployment cnpg-system/barman-cloud,
|
||||||
|
# vendored in infrastructure/databases/base), not the operator's in-tree
|
||||||
|
# barman-cloud support: 1.30 deprecates the in-tree path and 1.31 removes it
|
||||||
|
# (`Warning: Native support for Barman Cloud backups and recovery is
|
||||||
|
# deprecated ...`). See objectstore-portal-wal.yaml for the store definition.
|
||||||
|
#
|
||||||
|
# `serverName: portal` is the barman prefix and must stay exactly the cluster
|
||||||
|
# name: the plugin writes to s3://pg-wal-archive/portal/{base,wals}/... — the
|
||||||
|
# same objects the in-tree archiver left behind, so the existing 14-day window
|
||||||
|
# stays restorable. Changing it starts a new prefix and abandons that window.
|
||||||
|
#
|
||||||
|
# Credentials live in Secret sirius-growth/portal-wal-s3 (created out of band
|
||||||
|
# from the Garage key `cnpg-portal-wal`, id GK7f2b4bb1fc9abaec50fde37b, scope
|
||||||
|
# read+write on bucket `pg-wal-archive` only). Never commit the key values.
|
||||||
|
#
|
||||||
|
# `pg_dump` in forgejo/cluster-backup still runs nightly for this database as
|
||||||
|
# a second, logical copy: a dump survives a barman-format regression or a
|
||||||
|
# store that has been emptied, and it is the only copy that is readable
|
||||||
|
# without barman. Belt and braces, not redundancy theatre — the RPO comes
|
||||||
|
# from the WAL archive, not from the dump.
|
||||||
|
plugins:
|
||||||
|
- name: barman-cloud.cloudnative-pg.io
|
||||||
|
isWALArchiver: true
|
||||||
|
parameters:
|
||||||
|
barmanObjectName: portal-wal
|
||||||
|
serverName: portal
|
||||||
# Scraped via podmonitor.yaml in this directory (hand-written; see the comment
|
# Scraped via podmonitor.yaml in this directory (hand-written; see the comment
|
||||||
# in apps/base/forgejo/podmonitor.yaml for why enablePodMonitor is false).
|
# in apps/base/forgejo/podmonitor.yaml for why enablePodMonitor is false).
|
||||||
# Only the operator's default query set here — this database needs no custom
|
# Only the operator's default query set here — this database needs no custom
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,10 @@ resources:
|
||||||
- service-blog.yaml
|
- service-blog.yaml
|
||||||
- service-portal-gate.yaml
|
- service-portal-gate.yaml
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
|
# The WAL archive store must exist before the Cluster references it.
|
||||||
|
- objectstore-portal-wal.yaml
|
||||||
- cluster.yaml
|
- cluster.yaml
|
||||||
|
- scheduled-backup.yaml
|
||||||
- podmonitor.yaml
|
- podmonitor.yaml
|
||||||
- pvc-leadgen.yaml
|
- pvc-leadgen.yaml
|
||||||
- cronjob-leadgen.yaml
|
- cronjob-leadgen.yaml
|
||||||
|
|
|
||||||
51
apps/base/sirius-growth/objectstore-portal-wal.yaml
Normal file
51
apps/base/sirius-growth/objectstore-portal-wal.yaml
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
# The WAL archive for Cluster sirius-growth/portal, in the CNPG-I Barman Cloud
|
||||||
|
# plugin's own CR instead of Cluster.spec.backup.barmanObjectStore.
|
||||||
|
#
|
||||||
|
# Same store, same layout: destinationPath is the *bucket root* and the plugin
|
||||||
|
# appends the server name (Cluster.spec.plugins[].parameters.serverName, set to
|
||||||
|
# `portal`), so the existing objects stay exactly where the in-tree archiver put
|
||||||
|
# them — s3://pg-wal-archive/portal/{base,wals}/... . Anything that changes the
|
||||||
|
# prefix silently abandons the 14-day window that is already in the bucket.
|
||||||
|
#
|
||||||
|
# `spec.configuration` is the literal translation of the retired
|
||||||
|
# `spec.backup.barmanObjectStore` block (same schema, same Secret), and
|
||||||
|
# `retentionPolicy` moved here from Cluster.spec.backup.retentionPolicy — in the
|
||||||
|
# plugin architecture retention is a property of the store, not the cluster.
|
||||||
|
#
|
||||||
|
# Credentials: Secret sirius-growth/portal-wal-s3 (Garage key `cnpg-portal-wal`,
|
||||||
|
# id GK7f2b4bb1fc9abaec50fde37b, RW on bucket `pg-wal-archive` only), created
|
||||||
|
# out of band. The key values are deliberately not in git.
|
||||||
|
apiVersion: barmancloud.cnpg.io/v1
|
||||||
|
kind: ObjectStore
|
||||||
|
metadata:
|
||||||
|
name: portal-wal
|
||||||
|
namespace: sirius-growth
|
||||||
|
spec:
|
||||||
|
configuration:
|
||||||
|
destinationPath: s3://pg-wal-archive
|
||||||
|
endpointURL: http://10.10.0.5:3900
|
||||||
|
s3Credentials:
|
||||||
|
accessKeyId:
|
||||||
|
name: portal-wal-s3
|
||||||
|
key: ACCESS_KEY_ID
|
||||||
|
secretAccessKey:
|
||||||
|
name: portal-wal-s3
|
||||||
|
key: ACCESS_SECRET_KEY
|
||||||
|
region:
|
||||||
|
name: portal-wal-s3
|
||||||
|
key: REGION
|
||||||
|
# gzip on both directions: this is a WAL stream over the WireGuard mesh into
|
||||||
|
# a 20 GB store on the Linode, so bytes on the wire and in the bucket are
|
||||||
|
# the cost. Must match what the in-tree archiver wrote (gzip) — the
|
||||||
|
# archive is read by segment, but a mismatch in base-backup compression
|
||||||
|
# would make the existing base backups unrestorable.
|
||||||
|
wal:
|
||||||
|
compression: gzip
|
||||||
|
maxParallel: 2
|
||||||
|
data:
|
||||||
|
compression: gzip
|
||||||
|
jobs: 2
|
||||||
|
# Enforced by the plugin instance sidecar every 30 min (default
|
||||||
|
# retentionPolicyIntervalSeconds) with barman-cloud's retention logic, i.e.
|
||||||
|
# the same 14-day window the in-tree archiver maintained.
|
||||||
|
retentionPolicy: "14d"
|
||||||
24
apps/base/sirius-growth/scheduled-backup.yaml
Normal file
24
apps/base/sirius-growth/scheduled-backup.yaml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: ScheduledBackup
|
||||||
|
metadata:
|
||||||
|
name: portal-daily
|
||||||
|
namespace: sirius-growth
|
||||||
|
spec:
|
||||||
|
# Six-field cron (seconds first — CNPG, not standard cron). 03:20 UTC, clear
|
||||||
|
# of the 02:37 forgejo/cluster-backup CronJob so the two do not fight for the
|
||||||
|
# primary's I/O on a laptop disk.
|
||||||
|
schedule: "0 20 3 * * *"
|
||||||
|
cluster:
|
||||||
|
name: portal
|
||||||
|
# `self`: the Backup objects are owned by this ScheduledBackup, so deleting the
|
||||||
|
# schedule (or the namespace) does not leave orphaned Backups pointing at the
|
||||||
|
# cluster. Retention/cleanup of the archive itself is the ObjectStore's
|
||||||
|
# spec.retentionPolicy (14d), enforced by the plugin's sidecar.
|
||||||
|
backupOwnerReference: self
|
||||||
|
# Plugin method, not `barmanObjectStore`: the in-tree method is removed in
|
||||||
|
# CNPG 1.31. `pluginConfiguration` names the CNPG-I plugin, whose
|
||||||
|
# ObjectStore is referenced by the Cluster's spec.plugins.
|
||||||
|
method: plugin
|
||||||
|
pluginConfiguration:
|
||||||
|
name: barman-cloud.cloudnative-pg.io
|
||||||
|
immediate: false
|
||||||
|
|
@ -21,7 +21,7 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: contact-api
|
- name: contact-api
|
||||||
image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13
|
image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:8642f1a14b1dd9f217e32856b7a9ea0a0c37e3aa
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"]
|
command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"]
|
||||||
ports:
|
ports:
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ spec:
|
||||||
memory: 128Mi
|
memory: 128Mi
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:4d03fc814d39faaf5d8cc64b794aa4bc19f72995
|
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:399c421f51a2fd74a87e810641226d58e4e22690
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,5 @@ resources:
|
||||||
- ../base/piedmont
|
- ../base/piedmont
|
||||||
- ../base/sirius-growth
|
- ../base/sirius-growth
|
||||||
- ../base/osint
|
- ../base/osint
|
||||||
|
- ../base/metabase
|
||||||
|
- ../base/customer1
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,7 @@ spec:
|
||||||
prune: true
|
prune: true
|
||||||
dependsOn:
|
dependsOn:
|
||||||
- name: infrastructure
|
- name: infrastructure
|
||||||
|
# `sirius-growth` now carries an `ObjectStore` (barmancloud.cnpg.io) whose
|
||||||
|
# CRD ships with the plugin in the `databases` Kustomization, and the
|
||||||
|
# portal Cluster references it. Apply apps only after that CRD exists.
|
||||||
|
- name: databases
|
||||||
|
|
|
||||||
18
clusters/homek8s/cert-manager.yaml
Normal file
18
clusters/homek8s/cert-manager.yaml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
|
namespace: flux-system
|
||||||
|
spec:
|
||||||
|
interval: 10m0s
|
||||||
|
retryInterval: 1m
|
||||||
|
timeout: 5m
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: flux-system
|
||||||
|
path: ./infrastructure/controllers/cert-manager
|
||||||
|
# The HelmRelease owns the chart; pruning the Kustomization deletes the
|
||||||
|
# release object, and the chart's CRDs carry `helm.sh/resource-policy: keep`
|
||||||
|
# so they survive. Nothing here is a bare CRD in git, hence prune: true.
|
||||||
|
prune: true
|
||||||
|
wait: true
|
||||||
|
|
@ -11,9 +11,15 @@ spec:
|
||||||
kind: GitRepository
|
kind: GitRepository
|
||||||
name: flux-system
|
name: flux-system
|
||||||
path: ./infrastructure/databases/base
|
path: ./infrastructure/databases/base
|
||||||
# The CloudNativePG operator bundle contains its 11 CRDs. Those must never be
|
# The CloudNativePG operator bundle contains its 11 CRDs, and the vendored
|
||||||
# pruned automatically: dropping them would delete every Cluster/Database
|
# Barman Cloud plugin adds the `ObjectStore` CRD. Those must never be pruned
|
||||||
|
# automatically: dropping them would delete every Cluster/Database/Backup
|
||||||
# object (and the Forgejo and portal Postgres clusters with them). Same
|
# object (and the Forgejo and portal Postgres clusters with them). Same
|
||||||
# reasoning as gateway-api-crds. Reverting the operator Deployment args is a
|
# reasoning as gateway-api-crds. Reverting the operator Deployment args is a
|
||||||
# git change, not a prune.
|
# git change, not a prune.
|
||||||
prune: false
|
prune: false
|
||||||
|
# The plugin's operator<->plugin mTLS pair is issued by cert-manager
|
||||||
|
# (Issuer/Certificate in the vendored plugin manifest). Applying those before
|
||||||
|
# the cert-manager CRDs and webhook exist just churns; wait for it.
|
||||||
|
dependsOn:
|
||||||
|
- name: cert-manager
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,34 @@ Neither hostname is in the cloudflared ingress list, and `*.lab.internal` resolv
|
||||||
|
|
||||||
**What breaks:** anything that assumes `127.0.0.1:3902` (the removed static web endpoint) is reachable from inside the pod network. It never was — a pod's `127.0.0.1` is its own netns — and the listener is now gone. Kubernetes workloads must use the `10.10.0.1:3900` S3 endpoint, or the in-image `/photos/` alias baked into the site images as a fallback. That alias is a deliberate fallback, **not** evidence the bucket is gone.
|
**What breaks:** anything that assumes `127.0.0.1:3902` (the removed static web endpoint) is reachable from inside the pod network. It never was — a pod's `127.0.0.1` is its own netns — and the listener is now gone. Kubernetes workloads must use the `10.10.0.1:3900` S3 endpoint, or the in-image `/photos/` alias baked into the site images as a fallback. That alias is a deliberate fallback, **not** evidence the bucket is gone.
|
||||||
|
|
||||||
|
### 5.1 A *second*, unrelated Garage node: the WAL archive on the Linode
|
||||||
|
|
||||||
|
`infrastructure/garage-linode/` (not Flux-applied, like the Pi's) runs a
|
||||||
|
single-node Garage on the **Linode hub** and holds exactly one bucket,
|
||||||
|
`pg-wal-archive`, for CloudNativePG point-in-time recovery (§8.1, §8.3).
|
||||||
|
|
||||||
|
| Property | Value |
|
||||||
|
|---|---|
|
||||||
|
| Where | Linode VPS (`linode` node), **podman** + quadlet `/etc/containers/systemd/garage.container` — there is no Docker on a kubelet node |
|
||||||
|
| Node | `994fd2f42ae72da6`, zone `dc1`, capacity **20 GB**, `replication_factor = 1` — a separate store with its own `node_key`, **not** a peer of the Pi's node |
|
||||||
|
| Endpoint | `http://10.10.0.5:3900` (S3) — the dummy-k8s WireGuard address, reachable from every pod over the mesh. `:3903` metrics, mesh-only, not scraped yet |
|
||||||
|
| Config | `garage.toml` binds those two addresses explicitly (no `0.0.0.0`), RPC secret from `/etc/garage/garage.env` (0600, not in git) |
|
||||||
|
| Firewall | nft `inet wal_archive_guard`, PREROUTING priority -140: accept `lo`/`wg0` (+ pod CIDR), drop everything else. ufw on this host is unrelated and stays as it is |
|
||||||
|
| State | `/var/lib/garage/{meta,data}`, covered by the nightly cluster-backup tree on the same host |
|
||||||
|
| Bucket | `pg-wal-archive` — private (`Website access: false`, anonymous GET → 403) |
|
||||||
|
| Keys | `cnpg-portal-wal` (`GK7f2b4bb1fc9abaec50fde37b`, RW on that bucket only) → Secret `sirius-growth/portal-wal-s3` |
|
||||||
|
|
||||||
|
This node exists **because of where it is**, not because the estate needed a
|
||||||
|
second S3 service: a WAL archive on the Pi would sit in the same building, power
|
||||||
|
domain and uplink as the CNPG primary on siriussec. Off-site or it is not a
|
||||||
|
backup.
|
||||||
|
|
||||||
|
Producer: the **CNPG-I Barman Cloud plugin** (`cnpg-system/barman-cloud`,
|
||||||
|
`ObjectStore sirius-growth/portal-wal`) — not the operator's deprecated in-tree
|
||||||
|
`barmanObjectStore`. The bucket, key and layout are unchanged (`portal/base/…`,
|
||||||
|
`portal/wals/…`), because the plugin appends the same barman server name
|
||||||
|
(`portal`) to the same `s3://pg-wal-archive` root. See §8.4.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 6. Workloads
|
## 6. Workloads
|
||||||
|
|
@ -366,9 +394,10 @@ Nothing runs on `linode` except its Cilium agent. `rpi` runs only the two runner
|
||||||
| `kube-system` | 45 d | control plane, Cilium, Envoy, CoreDNS, hubble-relay + hubble-ui |
|
| `kube-system` | 45 d | control plane, Cilium, Envoy, CoreDNS, hubble-relay + hubble-ui |
|
||||||
| `kube-public`, `kube-node-lease`, `default` | 45 d | kubeadm defaults |
|
| `kube-public`, `kube-node-lease`, `default` | 45 d | kubeadm defaults |
|
||||||
| `forgejo` | 45 d | Forgejo, its CNPG cluster, 3 runners, prune CronJob |
|
| `forgejo` | 45 d | Forgejo, its CNPG cluster, 3 runners, prune CronJob |
|
||||||
| `cnpg-system` | 45 d | CloudNativePG operator |
|
| `cnpg-system` | 45 d | CloudNativePG operator **+ the CNPG-I Barman Cloud plugin** (`barman-cloud`, §8.4) |
|
||||||
|
| `cert-manager` | 1 m | cert-manager v1.21.3 (controller + webhook + cainjector) — installed for the Barman Cloud plugin's mTLS pair, §8.4 |
|
||||||
| `monitoring` | 1 d | kube-prometheus-stack: Prometheus (7d/8GB), Grafana, kube-state-metrics, node-exporter |
|
| `monitoring` | 1 d | kube-prometheus-stack: Prometheus (7d/8GB), Grafana, kube-state-metrics, node-exporter |
|
||||||
| `flux-system` | 41 d | 4 Flux controllers, GitRepository, 4 Kustomizations |
|
| `flux-system` | 41 d | 4 Flux controllers, GitRepository, 7 Kustomizations (`flux-system`, `gateway-api-crds`, `cert-manager`, `databases`, `infrastructure`, `monitoring`, `apps`) |
|
||||||
| `gateway-system` | 45 d | Gateway `public` |
|
| `gateway-system` | 45 d | Gateway `public` |
|
||||||
| `internal` | 41 d | Gateways `internal` (8081) and `hubble-ui` (8084) |
|
| `internal` | 41 d | Gateways `internal` (8081) and `hubble-ui` (8084) |
|
||||||
| `local-path-storage` | 45 d | provisioner |
|
| `local-path-storage` | 45 d | provisioner |
|
||||||
|
|
@ -492,11 +521,11 @@ StorageClass `local-path` (default, `WaitForFirstConsumer`, no expansion), provi
|
||||||
|
|
||||||
**Dind growth hazard.** The amd64 runner's PVC is nominally 20 Gi and currently sits at **~22 G**: it has previously grown to ~50 GB from heavy Android/Rust builds and pushed the node into `DiskPressure`, which evicted the runner and left Forgejo and `pg-1` Pending. Docker image GC does not reclaim the data-root. Rule: when it approaches the cap, scale the runner to 0 **first**, then wipe `.../docker/*` (keeping `runner.ini` beside it), then scale back and re-pull the job image — wiping it under a live or restarting pod leaves `dockerd` half-initialised and every pull fails. Note the data-root also hosts the named volumes CI depends on (`cargo-target`, Android SDK, Gradle cache), so a wipe makes the next run fully cold.
|
**Dind growth hazard.** The amd64 runner's PVC is nominally 20 Gi and currently sits at **~22 G**: it has previously grown to ~50 GB from heavy Android/Rust builds and pushed the node into `DiskPressure`, which evicted the runner and left Forgejo and `pg-1` Pending. Docker image GC does not reclaim the data-root. Rule: when it approaches the cap, scale the runner to 0 **first**, then wipe `.../docker/*` (keeping `runner.ini` beside it), then scale back and re-pull the job image — wiping it under a live or restarting pod leaves `dockerd` half-initialised and every pull fails. Note the data-root also hosts the named volumes CI depends on (`cargo-target`, Android SDK, Gradle cache), so a wipe makes the next run fully cold.
|
||||||
|
|
||||||
Host disks *(live)*: siriussec `/` 214 G, 167 G used (**83 %**, 37 G free); rpi `/` 917 G, 506 G used (58 %, 374 G free); linode `/` 79 G, 11 G used (**14 %**, 64 G free — this is the backup target).
|
Host disks *(live)*: siriussec `/` 214 G, 167 G used (**83 %**, 37 G free); rpi `/` 917 G, 506 G used (58 %, 374 G free); linode `/` 79 G, 29 G used (**39 %**, 46 G free — this is the backup target, and since 2026-11-19 it also hosts the `pg-wal-archive` Garage node).
|
||||||
|
|
||||||
### 8.1 Backup coverage
|
### 8.1 Backup coverage
|
||||||
|
|
||||||
Three independent scheduled paths, all **off** the T480 and **off** the Pi:
|
Five independent scheduled paths, all **off** the T480 and **off** the Pi:
|
||||||
|
|
||||||
1. **Cluster state → Linode VPS**, CronJob `forgejo/cluster-backup`
|
1. **Cluster state → Linode VPS**, CronJob `forgejo/cluster-backup`
|
||||||
(`apps/base/forgejo/cluster-backup.yaml`; exec-only RBAC in
|
(`apps/base/forgejo/cluster-backup.yaml`; exec-only RBAC in
|
||||||
|
|
@ -515,15 +544,28 @@ Three independent scheduled paths, all **off** the T480 and **off** the Pi:
|
||||||
3. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/`
|
3. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/`
|
||||||
`garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) →
|
`garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) →
|
||||||
`[email protected]:/root/garage-backup`.
|
`[email protected]:/root/garage-backup`.
|
||||||
|
4. **Point-in-time recovery for `sirius-growth/portal`**, continuous WAL archiving
|
||||||
|
+ a daily base backup straight from the **CNPG-I Barman Cloud plugin** into a
|
||||||
|
**second Garage node running on the Linode** (`infrastructure/garage-linode/`,
|
||||||
|
bucket `pg-wal-archive`, bucket-private, `10.10.0.5:3900` WireGuard-only). This
|
||||||
|
is the only path with a **sub-24 h RPO**: recovery to any second inside the last
|
||||||
|
14 days, not just "the state at 02:37". Config:
|
||||||
|
`apps/base/sirius-growth/objectstore-portal-wal.yaml` (`ObjectStore portal-wal`,
|
||||||
|
store + `retentionPolicy: 14d`), the Cluster's `spec.plugins`
|
||||||
|
(`barman-cloud.cloudnative-pg.io`, `isWALArchiver: true`, `serverName: portal`)
|
||||||
|
and `apps/base/sirius-growth/scheduled-backup.yaml` (`ScheduledBackup
|
||||||
|
portal-daily`, `20 3 * * *` UTC in **six**-field cron, seconds first,
|
||||||
|
`method: plugin`). The plugin Deployment itself is vendored in
|
||||||
|
`infrastructure/databases/base/` (§8.4).
|
||||||
|
|
||||||
A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/`
|
A fifth path covers the Pi's own hub state: `infrastructure/wireguard/backup/`
|
||||||
`wireguard-backup.timer` (nightly 04:13) → `[email protected]:/root/pihost-backup`.
|
`wireguard-backup.timer` (nightly 04:13) → `[email protected]:/root/pihost-backup`.
|
||||||
|
|
||||||
| Artifact | Method | On the Linode | Retention |
|
| Artifact | Method | On the Linode | Retention |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| `forgejo-data` PVC (`/data`) | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `forgejo-data/<stamp>/` + `latest` symlink | 7 snapshots (hardlinked: 1 full copy + nightly deltas) |
|
| `forgejo-data` PVC (`/data`) | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `forgejo-data/<stamp>/` + `latest` symlink | 7 snapshots (hardlinked: 1 full copy + nightly deltas) |
|
||||||
| `forgejo/pg` | `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket — no DB password exists in git or in the Job | `db/forgejo-pg-<stamp>.dump` | 14 |
|
| `forgejo/pg` | `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket — no DB password exists in git or in the Job | `db/forgejo-pg-<stamp>.dump` | 14 |
|
||||||
| `sirius-growth/portal` | same, through exec RBAC in `sirius-growth` | `db/sirius-growth-portal-<stamp>.dump` | 14 |
|
| `sirius-growth/portal` | two independent copies, on purpose. **(a)** `pg_dump -Fc -Z6` **inside the CNPG primary** over the local socket, through exec RBAC in `sirius-growth` — logical, human-readable with any `pg_restore`. **(b)** barman-cloud **continuous WAL archive + daily base backup** through the CNPG-I plugin (path 4) | (a) `db/sirius-growth-portal-<stamp>.dump`; (b) `pg-wal-archive` bucket on the Linode: `portal/base/<stamp>/` + `portal/wals/…` | (a) 14 dumps; (b) 14 days of WAL (`ObjectStore.spec.retentionPolicy: 14d`) |
|
||||||
| `osint/osint-db` (plain Postgres Deployment, has TimescaleDB + PostGIS) | `pg_dump -Fc -Z6` **inside the pod** over the local socket, using its own `POSTGRES_USER`/`POSTGRES_DB` via exec RBAC in `osint` | `db/osint-osint-db-<stamp>.dump` | 14 |
|
| `osint/osint-db` (plain Postgres Deployment, has TimescaleDB + PostGIS) | `pg_dump -Fc -Z6` **inside the pod** over the local socket, using its own `POSTGRES_USER`/`POSTGRES_DB` via exec RBAC in `osint` | `db/osint-osint-db-<stamp>.dump` | 14 |
|
||||||
| `grafana.db` (sqlite) | **sqlite backup API** in a `python:3.12-alpine` pod that mounts the PVC — a `cp` of a live db can capture a torn page; the image is `-distroless`, so there is no shell to exec into | `grafana/grafana-<stamp>.db` | 14 |
|
| `grafana.db` (sqlite) | **sqlite backup API** in a `python:3.12-alpine` pod that mounts the PVC — a `cp` of a live db can capture a torn page; the image is `-distroless`, so there is no shell to exec into | `grafana/grafana-<stamp>.db` | 14 |
|
||||||
| `sgs-leadgen-data` PVC | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `leadgen-data/<stamp>/` + `latest` | 7 |
|
| `sgs-leadgen-data` PVC | `rsync -a --delete --link-dest` snapshot mirror, PVC mounted read-only | `leadgen-data/<stamp>/` + `latest` | 7 |
|
||||||
|
|
@ -546,6 +588,51 @@ A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/`
|
||||||
- The Job lives in namespace `forgejo` (not a `backup` namespace) because a PVC
|
- The Job lives in namespace `forgejo` (not a `backup` namespace) because a PVC
|
||||||
cannot be mounted cross-namespace and `forgejo-data` is the largest artifact.
|
cannot be mounted cross-namespace and `forgejo-data` is the largest artifact.
|
||||||
|
|
||||||
|
- **The WAL archive lives in a second Garage node on the Linode, and only there.**
|
||||||
|
Pointing barman at the Pi's Garage would put the archive in the same building,
|
||||||
|
power domain and uplink as the CNPG primary — a second copy of the same
|
||||||
|
failure. `infrastructure/garage-linode/` is a *separate* single-node store
|
||||||
|
(node `994fd2f42ae72da6`, capacity 20 GB, no relation to the Pi's
|
||||||
|
`d053db4dfc97bf78`): podman + a quadlet unit (this host has no Docker — it is a
|
||||||
|
kubelet node), `garage.toml` binding `10.10.0.5:3900`/`:3903` only, and an nft
|
||||||
|
table `inet wal_archive_guard` (PREROUTING -140) that drops 3900/3903 from
|
||||||
|
anything but `lo`/`wg0`. Measured off-mesh (from this laptop, straight to the
|
||||||
|
Linode's public IP, no VPN in the path): 3900 and 3903 **filtered**, and the
|
||||||
|
drop counter increments. Anonymous S3 GET on the bucket → **403 AccessDenied**.
|
||||||
|
- **Disk sizing for the WAL archive** *(measured 2026-11-19)*: Linode `/` is 79 G
|
||||||
|
with **46 G free**; Garage is capped at 20 GB. Actual usage after the first
|
||||||
|
base backup + 7 WAL segments: **4.9 MB** in 8 bucket objects (`data/` 9.3 MB
|
||||||
|
with Garage's block-store overhead, `meta/` 4.6 MB). `archive_timeout` is 5 min
|
||||||
|
and `wal_segment_size` 16 MB, so the archive takes at most 288 segments/day;
|
||||||
|
gzip turns a segment into 16–25 KB when the database is quiet (measured) →
|
||||||
|
~6 MB WAL/day + a 4.5 MB base backup/day ≈ **150 MB for the whole 14-day
|
||||||
|
window**. Worst case on a busy database (every segment full at a typical 3–5×
|
||||||
|
gzip ratio) is ~1.5 GB/day → 21 GB for 14 days, i.e. it would hit the 20 GB
|
||||||
|
cap. The cap is deliberate: Garage answers `507 InsufficientStorage` and
|
||||||
|
barman-cloud fails loudly (a red `Backup`/`ScheduledBackup`) rather
|
||||||
|
than filling the Linode disk. If that ever fires, the lever is
|
||||||
|
`ObjectStore portal-wal` → `spec.retentionPolicy` (7d) — not deleting WALs by
|
||||||
|
hand.
|
||||||
|
- **The barman credentials are a namespaced Secret, not git**:
|
||||||
|
`sirius-growth/portal-wal-s3` (`ACCESS_KEY_ID` / `ACCESS_SECRET_KEY` /
|
||||||
|
`REGION`), created out of band from Garage key `cnpg-portal-wal`
|
||||||
|
(`GK7f2b4bb1fc9abaec50fde37b`, scope **read+write on `pg-wal-archive` only**,
|
||||||
|
no bucket-create). Recording key IDs is fine; the values are not in git, in the
|
||||||
|
docs, or in any comment.
|
||||||
|
- **The 1.31 gate is closed — WAL archiving runs on the CNPG-I plugin, not the
|
||||||
|
in-tree path.** CNPG 1.30 deprecated `spec.backup.barmanObjectStore` and warns
|
||||||
|
on every apply that 1.31 removes it. `sirius-growth/portal` was migrated on
|
||||||
|
**2026-11-19** (kanban `t_5df331de`) to the Barman Cloud plugin
|
||||||
|
(`infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml`,
|
||||||
|
Deployment `cnpg-system/barman-cloud`, `ObjectStore sirius-growth/portal-wal`,
|
||||||
|
`Cluster.spec.plugins`, `ScheduledBackup.method: plugin`), so bumping the
|
||||||
|
operator pin from 1.30.0 to 1.31 no longer breaks archiving or PITR. The bucket
|
||||||
|
layout did not move: `portal/base` + `portal/wals` are the same objects the
|
||||||
|
in-tree archiver wrote, and the restore rehearsal in §8.3 ran against that
|
||||||
|
mixed archive. The plugin needs cert-manager (its mTLS pair is an
|
||||||
|
`Issuer` + two `Certificate`s), installed as `cert-manager` HelmRelease v1.21.3
|
||||||
|
— see §8.4.
|
||||||
|
|
||||||
**Accepted gaps (with the reason, not just a TODO):**
|
**Accepted gaps (with the reason, not just a TODO):**
|
||||||
|
|
||||||
- **Prometheus TSDB** (2.4 GiB) — deliberately excluded: regenerated metrics
|
- **Prometheus TSDB** (2.4 GiB) — deliberately excluded: regenerated metrics
|
||||||
|
|
@ -561,10 +648,25 @@ A fourth path covers the Pi's own hub state: `infrastructure/wireguard/backup/`
|
||||||
- **Pi `/etc/wireguard` is only as fresh as the last nightly run** — a peer
|
- **Pi `/etc/wireguard` is only as fresh as the last nightly run** — a peer
|
||||||
added today is in the db and on the Pi, and reaches the Linode at 04:13.
|
added today is in the db and on the Pi, and reaches the Linode at 04:13.
|
||||||
|
|
||||||
A new CloudNativePG cluster is **not** picked up automatically: add
|
**Closed 2026-11-19 — point-in-time recovery.** There is no longer a "restore to
|
||||||
`<ns>/<cluster>` to `CNPG_TARGETS` in the CronJob env *and* an equivalent
|
02:37 or lose the day" gap: `sirius-growth/portal` can be recovered to any second
|
||||||
exec-only Role/RoleBinding for the `forgejo/cluster-backup` ServiceAccount in
|
inside the 14-day window, and that restore has been rehearsed end to end (§8.3).
|
||||||
that namespace.
|
`forgejo/pg` is deliberately **not** on barman yet — a day of git history is
|
||||||
|
annoying, not costly, and one cluster proves the pattern; `osint/osint-db` is a
|
||||||
|
plain Deployment and cannot use CNPG backup at all.
|
||||||
|
|
||||||
|
A new CloudNativePG cluster is **not** picked up automatically by either
|
||||||
|
mechanism. For dumps: add `<ns>/<cluster>` to `CNPG_TARGETS` in the CronJob env
|
||||||
|
*and* an equivalent exec-only Role/RoleBinding for the `forgejo/cluster-backup`
|
||||||
|
ServiceAccount in that namespace. For WAL archiving: create an `ObjectStore` in
|
||||||
|
that namespace whose `spec.configuration.destinationPath` is
|
||||||
|
`s3://pg-wal-archive` (the bucket root — the plugin appends the barman server
|
||||||
|
name, which defaults to the cluster name, so clusters share one bucket without
|
||||||
|
colliding), point its `s3Credentials` at a `sirius-growth/portal-wal-s3`-shaped
|
||||||
|
Secret in that namespace, give it its own `retentionPolicy`, add
|
||||||
|
`spec.plugins: [{name: barman-cloud.cloudnative-pg.io, isWALArchiver: true,
|
||||||
|
parameters: {barmanObjectName: <store>}}]` to the Cluster and a
|
||||||
|
`ScheduledBackup` with `method: plugin`.
|
||||||
|
|
||||||
### 8.2 Restoring
|
### 8.2 Restoring
|
||||||
|
|
||||||
|
|
@ -631,6 +733,141 @@ sudo systemctl start wg-quick@wg0 && sudo wg show
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### 8.3 Point-in-time recovery (`sirius-growth/portal`)
|
||||||
|
|
||||||
|
Rehearsed end to end twice: **2026-11-19** with the in-tree barman-cloud archiver
|
||||||
|
(task `t_ce7d6772`) and again the same day **on the CNPG-I Barman Cloud plugin**
|
||||||
|
(task `t_5df331de`, §8.4) — marker row → forced WAL switch → unwanted row →
|
||||||
|
forced WAL switch → throwaway cluster restored with `targetTime` between the
|
||||||
|
two. Both times the marker came back and the later row did not.
|
||||||
|
|
||||||
|
**Step 1 — establish the target time.** Take it from the data, never from
|
||||||
|
memory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n sirius-growth exec portal-1 -c postgres -- \
|
||||||
|
psql -U postgres -d portal -tAc "select max(updated_at) from leads" # or pg_last_xact_replay_timestamp-style reasoning
|
||||||
|
date -u +%FT%TZ
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 2 — restore into a throwaway cluster.** Never into `portal` itself while
|
||||||
|
it is serving: CNPG recovery bootstraps a *new* data dir from the archive.
|
||||||
|
`externalClusters[].plugin` replaces `barmanObjectStore`; `serverName` is the
|
||||||
|
barman prefix and must stay the **source** cluster name.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: portal-pitr-test
|
||||||
|
namespace: sirius-growth
|
||||||
|
spec:
|
||||||
|
instances: 1
|
||||||
|
imageName: ghcr.io/cloudnative-pg/postgresql:16
|
||||||
|
storage: {size: 5Gi, storageClass: local-path}
|
||||||
|
affinity: {nodeSelector: {kubernetes.io/hostname: siriussec}}
|
||||||
|
bootstrap:
|
||||||
|
recovery:
|
||||||
|
source: portal-wal
|
||||||
|
recoveryTarget:
|
||||||
|
targetTime: "2026-11-19T23:05:00Z" # UTC, RFC3339
|
||||||
|
externalClusters:
|
||||||
|
- name: portal-wal
|
||||||
|
plugin:
|
||||||
|
name: barman-cloud.cloudnative-pg.io
|
||||||
|
parameters:
|
||||||
|
barmanObjectName: portal-wal # the ObjectStore in this namespace
|
||||||
|
serverName: portal # MUST be the *source* cluster name
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl apply -f portal-pitr-test.yaml
|
||||||
|
kubectl -n sirius-growth get cluster portal-pitr-test -w # Ready=True, "Cluster in healthy state"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Step 3 — verify the cut, and then promote the result.**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# the restore must stop before the unwanted transaction
|
||||||
|
kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \
|
||||||
|
psql -U postgres -d portal -c "select id, note, at from <the table> order by id"
|
||||||
|
kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \
|
||||||
|
psql -U postgres -tAc "select pg_is_in_recovery(), pg_last_xact_replay_timestamp()"
|
||||||
|
```
|
||||||
|
|
||||||
|
Rehearsal transcript on the plugin path (2026-11-19 23:04–23:06 UTC), target
|
||||||
|
`2026-11-19T23:05:00Z`, marker written 23:04:53.07, unwanted row 23:05:15.80:
|
||||||
|
|
||||||
|
```
|
||||||
|
# live primary, the mistake
|
||||||
|
1 | MARKER-plugin-before-target | 2026-11-19 23:04:53.072104+00
|
||||||
|
2 | POISON-plugin-after-target | 2026-11-19 23:05:15.798408+00
|
||||||
|
# pg_stat_archiver after forcing both segments out: ...062 (23:04:54), ...063 (23:05:16), failed_count 6 (historical, static)
|
||||||
|
|
||||||
|
# restored cluster portal-pitr-test (targetTime 23:05:00Z)
|
||||||
|
id | note | at
|
||||||
|
----+-----------------------------+-------------------------------
|
||||||
|
1 | MARKER-plugin-before-target | 2026-11-19 23:04:53.072104+00
|
||||||
|
(1 row)
|
||||||
|
select count(*) from pitr_probe where note like 'POISON%' -> 0
|
||||||
|
select pg_is_in_recovery(), pg_last_xact_replay_timestamp() -> f|
|
||||||
|
clients=4 calendar_tokens=3 applications=1 # identical to the primary
|
||||||
|
```
|
||||||
|
|
||||||
|
`pg_is_in_recovery() = f` on a single-instance recovery cluster means replay
|
||||||
|
finished and it has already been promoted. **A recovery cluster is writable the
|
||||||
|
moment it is Ready** — do not leave `portal-pitr-test` running, and do not point
|
||||||
|
application traffic at it.
|
||||||
|
|
||||||
|
**Step 4 — make it the real one.** Two supported shapes: cut the app over to the
|
||||||
|
restored cluster (preferred — reversible), or re-point the PVC:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# cut over: patch the API/portal Deployments' POSTGRES_HOST to portal-pitr-test-rw,
|
||||||
|
# then, once verified, keep it and delete the old cluster.
|
||||||
|
# in-place: let the recovery cluster finish, stop portal, and restore the portal-1
|
||||||
|
# PVC from the test cluster's data dir — only after the app is confirmed correct.
|
||||||
|
```
|
||||||
|
|
||||||
|
**What recovery does not do:** it does not replay anything after the target, so
|
||||||
|
a "restore to now" is only as good as the last archived WAL. If
|
||||||
|
`pg_stat_archiver.failed_count` is non-zero, fix archiving *before* relying on a
|
||||||
|
timestamp near the present.
|
||||||
|
|
||||||
|
**If the archive is lost or corrupt:** fall back to the nightly `pg_dump`
|
||||||
|
(§8.2 step 2) — 24 h RPO, logical, and readable without barman. That is exactly
|
||||||
|
why `sirius-growth/portal` stayed in `CNPG_TARGETS`.
|
||||||
|
|
||||||
|
### 8.4 The CNPG-I Barman Cloud plugin (how it is wired)
|
||||||
|
|
||||||
|
Active since **2026-11-19**. Three moving parts, all in git:
|
||||||
|
|
||||||
|
| Piece | Where | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| Plugin Deployment | `infrastructure/databases/base/upstream/plugin-barman-cloud-0.16.0.yaml` (vendored verbatim, sha256 `aee61468…7155`), patched only for `--log-level=info` + resources | `cnpg-system/barman-cloud`, port 9090, `replicas: 1`; **registered through Service annotations** `cnpg.io/pluginName: barman-cloud.cloudnative-pg.io` + `cnpg.io/pluginPort`/`pluginClientSecret`/`pluginServerSecret` — there is no `Plugin` CR in CNPG 1.30; delete the Service and the operator deregisters it |
|
||||||
|
| mTLS | `infrastructure/controllers/cert-manager/` (HelmRelease `cert-manager` v1.21.3, `crds.enabled: true`) issuing `barman-cloud-server-tls` / `barman-cloud-client-tls` from the vendored `Issuer` + `Certificate`s | cert-manager is a hard dependency of the plugin manifest, not a nice-to-have |
|
||||||
|
| Store + wiring | `ObjectStore sirius-growth/portal-wal`, `Cluster portal` `spec.plugins`, `ScheduledBackup portal-daily` `method: plugin` | `ObjectStore` must live in the Cluster's namespace, and its `serverName` field must stay **empty** (the CRD enforces this); the prefix comes from `spec.plugins[].parameters.serverName` |
|
||||||
|
|
||||||
|
Instance side: the operator injects an init-container sidecar
|
||||||
|
(`plugin-barman-cloud`, restartable sidecar) into `portal-1` and mounts a
|
||||||
|
`plugins` volume, which is why the Cluster restarted its primary once at
|
||||||
|
migration time. That sidecar runs `barman-cloud-wal-archive` /
|
||||||
|
`barman-cloud-backup` and enforces `retentionPolicy` every 30 min; the archive
|
||||||
|
URL it uses is `s3://pg-wal-archive portal <segment>` — same prefix as before.
|
||||||
|
|
||||||
|
Metrics change family with the archiver: `barman_cloud_cloudnative_pg_io_*`
|
||||||
|
(`…_last_available_backup_timestamp`, `…_first_recoverability_point`,
|
||||||
|
`…_last_failed_backup_timestamp`) replace `cnpg_collector_*` for this cluster.
|
||||||
|
The CNPG Grafana board accepts both. The deprecated
|
||||||
|
`cnpg_collector_last_available_backup_timestamp` is still *scraped* for portal
|
||||||
|
and holds the pre-migration value (22:34 UTC), so a panel that selects it alone
|
||||||
|
freezes at the last in-tree backup — that is why §8.4's dashboard change puts
|
||||||
|
the plugin metric first in the `or`.
|
||||||
|
|
||||||
|
Dependency order in Flux: `cert-manager` → `databases` (plugin + `ObjectStore`
|
||||||
|
CRD) → `apps` (the `ObjectStore` CR and the Cluster that references it).
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 9. Known hazards and runbook pointers
|
## 9. Known hazards and runbook pointers
|
||||||
|
|
@ -726,3 +963,16 @@ All times 2026-10-26 UTC. `kubeconfig` on the Legion admin laptop → `https://1
|
||||||
| 36 | siriussec: `curl :2381/metrics` (etcd) | `wal_fsync` 158 >8.192 s / 2,518 >2.048 s of 14,813,192; `backend_commit` 187 >8.192 s of 6,652,027; 99.6 %/99.7 % ≤32 ms — matches the stated stall profile, so this is spiky contention, not a failing disk |
|
| 36 | siriussec: `curl :2381/metrics` (etcd) | `wal_fsync` 158 >8.192 s / 2,518 >2.048 s of 14,813,192; `backend_commit` 187 >8.192 s of 6,652,027; 99.6 %/99.7 % ≤32 ms — matches the stated stall profile, so this is spiky contention, not a failing disk |
|
||||||
|
|
||||||
**Not verified, deliberately:** Cloudflare DNS records, Forgejo's `app.ini`, any secret material, and the SG-VPS/phone spoke routing beyond what the Linode's `wg show` reports.
|
**Not verified, deliberately:** Cloudflare DNS records, Forgejo's `app.ini`, any secret material, and the SG-VPS/phone spoke routing beyond what the Linode's `wg show` reports.
|
||||||
|
|
||||||
|
**CNPG-I Barman Cloud plugin migration, verified 2026-11-19 22:57–23:07 UTC (commits `f3a8233`, `c452552`; kanban `t_5df331de`):**
|
||||||
|
|
||||||
|
| # | Command | Key result |
|
||||||
|
|---|---|---|
|
||||||
|
| 37 | `kubectl -n cert-manager get pods`; `kubectl -n flux-system get kustomization` | controller/webhook/cainjector `1/1 Running`; all 7 Kustomizations `Ready=True` at the same revision, `databases` `dependsOn cert-manager`, `apps` `dependsOn databases` |
|
||||||
|
| 38 | `kubectl -n cnpg-system get pods,certificate` | `barman-cloud-7b779d49d8-2pnbk 1/1 Running`; `barman-cloud-client` + `barman-cloud-server` certificates `READY=True` — the operator logged `Registered plugin` for `barman-cloud.cloudnative-pg.io` |
|
||||||
|
| 39 | `kubectl -n sirius-growth get cluster portal -o jsonpath='{.status.pluginStatus}'` | `[{name: barman-cloud.cloudnative-pg.io, version: 0.16.0, capabilities: [TYPE_RECONCILER_HOOKS, TYPE_LIFECYCLE_SERVICE, TYPE_INSTANCE_SIDECAR_INJECTION]}]`; pod `portal-1` now carries the `plugin-barman-cloud` init-sidecar and `plugins` volume; Cluster `Ready=True` |
|
||||||
|
| 40 | `kubectl -n sirius-growth logs portal-1 -c plugin-barman-cloud` | `Executing barman-cloud-wal-archive … ["--gzip","--endpoint-url","http://10.10.0.5:3900","--cloud-provider","aws-s3","s3://pg-wal-archive","portal", …05D]` → `Archived WAL file … elapsedWalTime 0.586`; retention runnable applied `14d` |
|
||||||
|
| 41 | `kubectl -n sirius-growth get backup portal-plugin-proof-1 -o wide` | `METHOD plugin`, `PHASE completed` (on-demand base backup through the plugin) |
|
||||||
|
| 42 | `aws --endpoint-url http://10.10.0.5:3900 s3 ls --recursive s3://pg-wal-archive/` (from a pod, Secret `portal-wal-s3`) | `portal/base/20261119T223452/…` (in-tree) **and** `portal/base/20261119T230300/…` (plugin) side by side, `portal/wals/…` continuous — the prefix did not move; 4 objects under `base/`, 10 under `wals/` |
|
||||||
|
| 43 | PITR rehearsal: marker `23:04:53.07`, poison `23:05:15.80`, `targetTime 2026-11-19T23:05:00Z` | restored `portal-pitr-test` → marker row present, `count(POISON%)=0`, `pg_is_in_recovery()=f`, `clients 4 / calendar_tokens 3 / applications 1` identical to the primary; test cluster + PVC deleted, probe table dropped afterwards |
|
||||||
|
| 44 | Prometheus (`/api/v1/query`) | `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` = 1795129385 (23:03:05, the plugin backup), `…_first_recoverability_point` = 1795127697; the legacy `cnpg_collector_last_available_backup_timestamp` for `portal` still returns the **pre-migration** 1795127697 — hence the dashboard's `or` lists the plugin metric first |
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: cert-manager
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- repository.yaml
|
||||||
|
- release.yaml
|
||||||
4
infrastructure/controllers/cert-manager/namespace.yaml
Normal file
4
infrastructure/controllers/cert-manager/namespace.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
64
infrastructure/controllers/cert-manager/release.yaml
Normal file
64
infrastructure/controllers/cert-manager/release.yaml
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
# cert-manager — installed for one reason: the Barman Cloud CNPG-I plugin
|
||||||
|
# expects its operator/plugin mTLS pair as cert-manager `Certificate` objects
|
||||||
|
# (the upstream v0.16.0 manifest ships an Issuer + two Certificates and assumes
|
||||||
|
# cert-manager is present). CNPG-I *can* run on hand-made cert bundles, but that
|
||||||
|
# would put a CA private key in a hand-maintained Secret with no renewal; the
|
||||||
|
# chart is the supported path and is ~3 small pods.
|
||||||
|
#
|
||||||
|
# CRDs: `crds.enabled: true` is required — `Certificate`/`Issuer` do not exist
|
||||||
|
# otherwise. The chart annotates its CRDs with `helm.sh/resource-policy: keep`,
|
||||||
|
# so uninstalling the release does not delete issued certs' CRDs out from under
|
||||||
|
# the running plugin. Do not add `crds.keep: false`.
|
||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: cert-manager
|
||||||
|
namespace: cert-manager
|
||||||
|
spec:
|
||||||
|
releaseName: cert-manager
|
||||||
|
interval: 15m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
chart: cert-manager
|
||||||
|
version: "v1.21.3"
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: jetstack
|
||||||
|
namespace: cert-manager
|
||||||
|
install:
|
||||||
|
crds: CreateReplace
|
||||||
|
remediation:
|
||||||
|
retries: 3
|
||||||
|
upgrade:
|
||||||
|
crds: CreateReplace
|
||||||
|
remediation:
|
||||||
|
retries: 3
|
||||||
|
values:
|
||||||
|
crds:
|
||||||
|
enabled: true
|
||||||
|
# Homelab sizing: upstream requests are already small, but the webhook and
|
||||||
|
# cainjector each get a memory ceiling so a runaway cannot evict the CNPG
|
||||||
|
# primary that shares this node.
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
memory: 192Mi
|
||||||
|
webhook:
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 32Mi
|
||||||
|
limits:
|
||||||
|
memory: 128Mi
|
||||||
|
cainjector:
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 10m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
memory: 192Mi
|
||||||
|
# No Prometheus Operator CRs here (ServiceMonitor is not installed).
|
||||||
|
prometheus:
|
||||||
|
enabled: false
|
||||||
8
infrastructure/controllers/cert-manager/repository.yaml
Normal file
8
infrastructure/controllers/cert-manager/repository.yaml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
apiVersion: source.toolkit.fluxcd.io/v1
|
||||||
|
kind: HelmRepository
|
||||||
|
metadata:
|
||||||
|
name: jetstack
|
||||||
|
namespace: cert-manager
|
||||||
|
spec:
|
||||||
|
interval: 24h
|
||||||
|
url: https://charts.jetstack.io/
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# CloudNativePG operator, pinned at 1.30.0.
|
# CloudNativePG operator, pinned at 1.30.0, plus the CNPG-I Barman Cloud plugin.
|
||||||
#
|
#
|
||||||
# The operator was installed by hand at some point and Flux did not own it, so
|
# The operator was installed by hand at some point and Flux did not own it, so
|
||||||
# a kubectl patch was lost on every reinstall. The upstream release manifest is
|
# a kubectl patch was lost on every reinstall. The upstream release manifest is
|
||||||
|
|
@ -7,9 +7,21 @@
|
||||||
# and patched only for the deltas that already existed live plus the widened
|
# and patched only for the deltas that already existed live plus the widened
|
||||||
# leader-election window. Do not upgrade the version in this directory without
|
# leader-election window. Do not upgrade the version in this directory without
|
||||||
# a separate, tested change: the CRDs are in this bundle.
|
# a separate, tested change: the CRDs are in this bundle.
|
||||||
|
#
|
||||||
|
# The Barman Cloud plugin is the replacement for the in-tree barman-cloud
|
||||||
|
# integration that 1.30 still ships but deprecates (removed in 1.31). Also
|
||||||
|
# vendored verbatim (sha256
|
||||||
|
# aee614683892dd4b44ff9f7afaca55254f1c28de17abbaa0552bf2e1228f7155,
|
||||||
|
# https://github.com/cloudnative-pg/plugin-barman-cloud/releases/download/v0.16.0/manifest.yaml):
|
||||||
|
# a separate Deployment in cnpg-system, registered with the operator through
|
||||||
|
# Service annotations, carrying the `ObjectStore` CRD (barmancloud.cnpg.io). Its
|
||||||
|
# operator<->plugin mTLS pair is issued by cert-manager (Flux Kustomization
|
||||||
|
# `cert-manager`). v0.16.0 requires CloudNativePG >= 1.30 — satisfied above.
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- upstream/cnpg-1.30.0.yaml
|
- upstream/cnpg-1.30.0.yaml
|
||||||
|
- upstream/plugin-barman-cloud-0.16.0.yaml
|
||||||
patches:
|
patches:
|
||||||
- path: patch-controller-manager.yaml
|
- path: patch-controller-manager.yaml
|
||||||
|
- path: patch-barman-cloud.yaml
|
||||||
|
|
|
||||||
36
infrastructure/databases/base/patch-barman-cloud.yaml
Normal file
36
infrastructure/databases/base/patch-barman-cloud.yaml
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
# Delta on the vendored Barman Cloud plugin manifest (0.16.0).
|
||||||
|
#
|
||||||
|
# Upstream ships the plugin operator with `--log-level=debug`. On this cluster
|
||||||
|
# nothing scrapes the plugin's logs and siriussec's root filesystem is the
|
||||||
|
# tightest disk in the estate, so the arg is lowered to `info`. Everything else
|
||||||
|
# in the release manifest is used verbatim — including the Service annotations
|
||||||
|
# (`cnpg.io/pluginName`, `cnpg.io/pluginPort`, `cnpg.io/pluginClientSecret`,
|
||||||
|
# `cnpg.io/pluginServerSecret`) that are the actual CNPG-I registration.
|
||||||
|
#
|
||||||
|
# The whole `args` list is restated because strategic merge replaces a container
|
||||||
|
# `args` list rather than merging it.
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: barman-cloud
|
||||||
|
namespace: cnpg-system
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: barman-cloud
|
||||||
|
args:
|
||||||
|
- operator
|
||||||
|
- --server-cert=/server/tls.crt
|
||||||
|
- --server-key=/server/tls.key
|
||||||
|
- --client-cert=/client/tls.crt
|
||||||
|
- --server-address=:9090
|
||||||
|
- --leader-elect
|
||||||
|
- --log-level=info
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 50m
|
||||||
|
memory: 64Mi
|
||||||
|
limits:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 256Mi
|
||||||
File diff suppressed because it is too large
Load diff
157
infrastructure/garage-linode/README.md
Normal file
157
infrastructure/garage-linode/README.md
Normal file
|
|
@ -0,0 +1,157 @@
|
||||||
|
# Garage on the Linode — the CloudNativePG WAL archive
|
||||||
|
|
||||||
|
A **second, independent** single-node Garage on the Linode VPS. It holds one
|
||||||
|
bucket, `pg-wal-archive`, and its only consumer is the **CNPG-I Barman Cloud
|
||||||
|
plugin** archiving for `sirius-growth/portal` (continuous WAL archiving + daily
|
||||||
|
base backups → point-in-time recovery).
|
||||||
|
|
||||||
|
It is **not** the Pi's Garage (`infrastructure/garage/`, node
|
||||||
|
`d053db4dfc97bf78`). Different host, different `node_key`, different metadata
|
||||||
|
dir, no RPC peering, nothing shared. That is the whole point:
|
||||||
|
|
||||||
|
> The CNPG primary runs on `siriussec` in the same building, on the same power
|
||||||
|
> domain and the same uplink as the Pi. A WAL archive on the Pi would be a second
|
||||||
|
> copy of the same failure. The archive has to be off-site; the Linode is the
|
||||||
|
> only off-site box in this estate.
|
||||||
|
|
||||||
|
## What runs
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Host | Linode VPS, Kubernetes node `linode`, WireGuard `10.10.0.5` (`dummy-k8s`), hub `10.20.0.1` on `wg0` |
|
||||||
|
| Runtime | **podman 5.4** + a quadlet unit. This host is a kubelet node: installing `dockerd` next to the kubelet's containerd would add a second container runtime for no benefit, so the Pi's compose file cannot be reused verbatim |
|
||||||
|
| Unit | `/etc/containers/systemd/garage.container` → generated `garage.service` (`Restart=always`) |
|
||||||
|
| Image | `dxflrs/garage:v1.1.0` (same pinned tag as the Pi) |
|
||||||
|
| Config | `/etc/garage/garage.toml` (installed from this directory) |
|
||||||
|
| RPC secret | `/etc/garage/garage.env` → `GARAGE_RPC_SECRET`, `0600 root:root`, **not in git** |
|
||||||
|
| State | `/var/lib/garage/meta` (metadata, `node_key`) and `/var/lib/garage/data` (objects) |
|
||||||
|
| Node | `994fd2f42ae72da6`, zone `dc1`, capacity **20 GB**, `replication_factor = 1` |
|
||||||
|
| Bucket | `pg-wal-archive` — private, `Website access: false` |
|
||||||
|
|
||||||
|
## Exposure — WireGuard only, twice
|
||||||
|
|
||||||
|
1. `garage.toml` binds `10.10.0.5:3900` (S3) and `10.10.0.5:3903` (admin/metrics)
|
||||||
|
explicitly. There is no `0.0.0.0` listener and `eth0` (the public IP) is never
|
||||||
|
bound, so `ss -ltn` is proof by itself.
|
||||||
|
2. `host/wal-archive-firewall.nft` is an nftables table in **PREROUTING priority
|
||||||
|
-140** that accepts 3900/3903 only from `lo`/`wg0` (plus source
|
||||||
|
`10.244.0.0/16` for pods on this node) and **drops** everything else, with
|
||||||
|
counters on every rule. podman with `Network=host` does not need DNAT, but
|
||||||
|
the table keeps a future port mapping from reopening the path — and ufw alone
|
||||||
|
would not cover a container publish, exactly as on the Pi.
|
||||||
|
|
||||||
|
Measured (2026-11-19), from the laptop **straight to the Linode's public IP with
|
||||||
|
no VPN in the path**: 3900 and 3903 both `filtered`, and
|
||||||
|
`nft list table inet wal_archive_guard` shows the drop counter incrementing.
|
||||||
|
Anonymous `GET http://10.10.0.5:3900/pg-wal-archive/` → **403 AccessDenied**.
|
||||||
|
|
||||||
|
## Install / re-install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# on the Linode, from a checkout of sirius/homek8s
|
||||||
|
cd infrastructure/garage-linode
|
||||||
|
sudo ./install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
`install.sh` is idempotent: it installs podman if missing, writes
|
||||||
|
`/etc/garage/{garage.toml,garage.env}` (generating the RPC secret once), installs
|
||||||
|
the quadlet unit and the nft guard **before** starting the container, then
|
||||||
|
assigns the layout capacity on first run (`layout assign -z dc1 -c 20G`) and
|
||||||
|
prints `garage status` + the listener set.
|
||||||
|
|
||||||
|
Verify (all four must hold):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
systemctl status garage.service --no-pager | head -3
|
||||||
|
ss -ltnH 'sport = :3900 or sport = :3903' # only 10.10.0.5, never 0.0.0.0
|
||||||
|
podman exec garage /garage -c /etc/garage.toml status # node 994fd2f42ae72da6, HEALTHY
|
||||||
|
nft list table inet wal_archive_guard # counters on accept and drop
|
||||||
|
```
|
||||||
|
|
||||||
|
## Bucket and key
|
||||||
|
|
||||||
|
```bash
|
||||||
|
G() { podman exec garage /garage -c /etc/garage.toml "$@"; }
|
||||||
|
G bucket create pg-wal-archive
|
||||||
|
G key create cnpg-portal-wal # prints the secret once — capture it
|
||||||
|
G bucket allow --read --write pg-wal-archive --key cnpg-portal-wal
|
||||||
|
G bucket info pg-wal-archive # Website access: false
|
||||||
|
```
|
||||||
|
|
||||||
|
Key ID `GK7f2b4bb1fc9abaec50fde37b` (`cnpg-portal-wal`), scope **read+write on
|
||||||
|
`pg-wal-archive` only** — no bucket-create, no other bucket, not an admin key.
|
||||||
|
The secret lives in the cluster as Secret `sirius-growth/portal-wal-s3`
|
||||||
|
(`ACCESS_KEY_ID`, `ACCESS_SECRET_KEY`, `REGION=garage`), created out of band and
|
||||||
|
**never committed**. Garage v1.1 has no `--yes` on `key create`; the secret is
|
||||||
|
printed exactly once, so redirect it to a `0600` root file and read it from there.
|
||||||
|
|
||||||
|
## Disk sizing and retention
|
||||||
|
|
||||||
|
Measured 2026-11-19:
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| Linode `/` | 79 GB, 29 GB used, **46 GB free** |
|
||||||
|
| Garage capacity | **20 GB** (layout), i.e. the store stops accepting before the disk does |
|
||||||
|
| First base backup + 7 WAL segments | **4.9 MB** in 8 bucket objects (`/var/lib/garage/data` 9.3 MB including Garage's block-store overhead, `meta` 4.6 MB) |
|
||||||
|
| `archive_timeout` / `wal_segment_size` on the primary | 5 min / 16 MB → at most 288 segments/day |
|
||||||
|
| Observed compressed segment | 16–25 KB when the portal is quiet |
|
||||||
|
| Steady state (quiet) | ~6 MB WAL/day + 4.5 MB base backup/day ≈ **150 MB per 14-day window** |
|
||||||
|
| Worst case (every segment full, 3–5× gzip) | ~1.5 GB/day ≈ 21 GB per 14 days — would hit the cap |
|
||||||
|
|
||||||
|
Retention is `spec.retentionPolicy: "14d"` on the `ObjectStore` (`portal-wal` in
|
||||||
|
`sirius-growth`), enforced by the plugin's instance sidecar (every 30 min), not
|
||||||
|
by the Cluster. The 20 GB cap is deliberate: when it is
|
||||||
|
reached Garage returns `507 InsufficientStorage` and the `Backup` /
|
||||||
|
`ScheduledBackup` goes red — a visible failure instead of a full Linode disk.
|
||||||
|
The response to that is to lower the retention policy to `7d`, or to grow the
|
||||||
|
Linode disk; never to delete WALs by hand (that breaks the archive's
|
||||||
|
continuity and every PITR target that depends on the deleted segment).
|
||||||
|
|
||||||
|
## How the archive is laid out
|
||||||
|
|
||||||
|
`destinationPath: s3://pg-wal-archive` (bucket root) with the barman server name
|
||||||
|
explicitly set to the cluster name (`Cluster.spec.plugins[].parameters.serverName:
|
||||||
|
portal`), so:
|
||||||
|
|
||||||
|
```
|
||||||
|
pg-wal-archive/portal/base/20261119T223452/{backup.info,data.tar.gz}
|
||||||
|
pg-wal-archive/portal/wals/0000000100000000/00000001000000000000005A.gz
|
||||||
|
```
|
||||||
|
|
||||||
|
That is one prefix per cluster, which is what lets `forgejo/pg` share this bucket
|
||||||
|
later without colliding. Listing it (the postgres container has no credentials in
|
||||||
|
its own environment; the Secret does):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n sirius-growth run wal-list --rm -it --restart=Never \
|
||||||
|
--image=public.ecr.aws/aws-cli/aws-cli:2.15.30 \
|
||||||
|
--overrides='{"spec":{"containers":[{"name":"aws","image":"public.ecr.aws/aws-cli/aws-cli:2.15.30",
|
||||||
|
"envFrom":[{"secretRef":{"name":"portal-wal-s3"}}],
|
||||||
|
"command":["sh","-c","export AWS_ACCESS_KEY_ID=$ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=$ACCESS_SECRET_KEY AWS_DEFAULT_REGION=$REGION; aws --endpoint-url http://10.10.0.5:3900 s3 ls --recursive --human-readable s3://pg-wal-archive/"]}]}}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Restore
|
||||||
|
|
||||||
|
Point-in-time recovery is a **cluster restore**, not a file copy. The full
|
||||||
|
rehearsed recipe (marker → restore to `targetTime` → verify) is §8.3 of
|
||||||
|
`docs/cluster-overview.md`; `pitr-restore.md` in this directory is the
|
||||||
|
self-contained version with the commands and the acceptance output.
|
||||||
|
|
||||||
|
Short form: a throwaway `Cluster` with `bootstrap.recovery.source` pointing at an
|
||||||
|
`externalClusters` entry (`serverName: portal`, the same bucket and Secret) and
|
||||||
|
`recoveryTarget.targetTime`, then promote/cut over. Recovery needs the **base
|
||||||
|
backup** plus every WAL segment up to the target — one missing segment is a
|
||||||
|
failed restore, which is why the archive is never pruned by hand.
|
||||||
|
|
||||||
|
## What this store is *not*
|
||||||
|
|
||||||
|
- **Not a cluster peer of the Pi's Garage.** No `[rpc]` peering, no shared
|
||||||
|
`rpc_secret`, no replicated data. Two independent single-node stores.
|
||||||
|
- **Not Flux-managed.** Flux watches `./clusters/homek8s`; nothing there
|
||||||
|
references this directory. A push changes nothing on the Linode until
|
||||||
|
`install.sh` runs.
|
||||||
|
- **Not a general-purpose bucket host.** One bucket, one key, one consumer. Put
|
||||||
|
application media on the Pi's store; this one exists to be off-site.
|
||||||
|
- **Not exposed to the LAN or the internet**, and no Cloudflare tunnel, DNS
|
||||||
|
record or public bucket will be added to it.
|
||||||
38
infrastructure/garage-linode/garage.container
Normal file
38
infrastructure/garage-linode/garage.container
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Quadlet unit — Garage WAL archive on the Linode hub (10.10.0.5).
|
||||||
|
#
|
||||||
|
# Installed to /etc/containers/systemd/garage.container by install.sh; the
|
||||||
|
# podman systemd generator turns it into `garage.service` on the next
|
||||||
|
# `systemctl daemon-reload`. There is no docker on this host (it is a kubelet
|
||||||
|
# node — installing dockerd here would add a second container runtime next to
|
||||||
|
# the kubelet's containerd for no reason), so the Pi's compose file cannot be
|
||||||
|
# reused verbatim. Quadlet is the podman-native equivalent: one declarative
|
||||||
|
# file, systemd owns the lifecycle, no daemon of its own.
|
||||||
|
#
|
||||||
|
# Network=host on purpose: the container binds 10.10.0.5:3900 from garage.toml
|
||||||
|
# directly, so the published addresses are visible in `ss -lnt` on the host and
|
||||||
|
# no podman port-forwarding rules are injected into the node's netfilter state.
|
||||||
|
|
||||||
|
[Unit]
|
||||||
|
Description=Garage S3 — CloudNativePG WAL archive (WireGuard-only)
|
||||||
|
Documentation=file:///etc/garage/README.md
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Container]
|
||||||
|
ContainerName=garage
|
||||||
|
Image=docker.io/dxflrs/garage:v1.1.0
|
||||||
|
Network=host
|
||||||
|
EnvironmentFile=/etc/garage/garage.env
|
||||||
|
Volume=/etc/garage/garage.toml:/etc/garage.toml:ro
|
||||||
|
Volume=/var/lib/garage/meta:/data/meta
|
||||||
|
Volume=/var/lib/garage/data:/data/data
|
||||||
|
Exec=/garage -c /etc/garage.toml server
|
||||||
|
LogDriver=journald
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Restart=always
|
||||||
|
TimeoutStartSec=120
|
||||||
|
TimeoutStopSec=60
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
47
infrastructure/garage-linode/garage.toml
Normal file
47
infrastructure/garage-linode/garage.toml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Garage v1.1.0 — WAL archive for CloudNativePG, on the Linode hub.
|
||||||
|
#
|
||||||
|
# Installed to /etc/garage/garage.toml (root:root 0644) by install.sh.
|
||||||
|
#
|
||||||
|
# This is a SECOND, independent Garage node — not a cluster peer of the Pi's
|
||||||
|
# node `d053db4dfc97bf78`. It exists because a WAL archive must live off-site:
|
||||||
|
# the Pi and the CNPG primary (siriussec) share a building, power domain and
|
||||||
|
# internet uplink, so archiving WALs there is a second copy of the same
|
||||||
|
# failure. Different node_key, different metadata dir, `replication_factor = 1`,
|
||||||
|
# nothing shared with the Pi's store.
|
||||||
|
#
|
||||||
|
# Listeners are bound to explicit addresses here AND the ports are guarded by
|
||||||
|
# host/wal-archive-firewall.nft before Docker-style DNAT could ever matter.
|
||||||
|
# `10.10.0.5` is the Linode worker's WireGuard-mesh InternalIP (dummy-k8s) —
|
||||||
|
# the only address any cluster pod can reach this on. eth0 (50.116.38.217) is
|
||||||
|
# not bound at all, so an off-mesh scan sees a filtered port, not a listener.
|
||||||
|
#
|
||||||
|
# rpc_secret is NOT in this file: GARAGE_RPC_SECRET comes from
|
||||||
|
# /etc/garage/garage.env (0600, out of git), same as the Pi's node.
|
||||||
|
|
||||||
|
metadata_dir = "/data/meta"
|
||||||
|
data_dir = "/data/data"
|
||||||
|
db_engine = "sqlite"
|
||||||
|
replication_factor = 1
|
||||||
|
|
||||||
|
# Single node: nothing outside the container speaks RPC. Garage still needs the
|
||||||
|
# listener for its own CLI-over-loopback calls (`garage status`, `garage key`).
|
||||||
|
rpc_bind_addr = "127.0.0.1:3901"
|
||||||
|
rpc_public_addr = "127.0.0.1:3901"
|
||||||
|
|
||||||
|
[s3_api]
|
||||||
|
s3_region = "garage"
|
||||||
|
# WireGuard address only. An empty/i.e. 0.0.0.0 bind here would put barman's
|
||||||
|
# archive on the Linode's public interface.
|
||||||
|
api_bind_addr = "10.10.0.5:3900"
|
||||||
|
|
||||||
|
# Admin API + Prometheus metrics, mesh-only. No metrics_token: the port does not
|
||||||
|
# leave the WireGuard mesh. Add one here (and a bearer token in the scrape
|
||||||
|
# config) if 3903 is ever exposed beyond it. Not scraped today — the archive's
|
||||||
|
# growth is asserted from the filesystem in the backup README instead.
|
||||||
|
[admin]
|
||||||
|
api_bind_addr = "10.10.0.5:3903"
|
||||||
|
|
||||||
|
# node_key is generated on first start and lives in metadata_dir (/data/meta).
|
||||||
|
# It is part of /root/garage-backup for the Pi's node; this node's meta/ is
|
||||||
|
# covered by the cluster-backup mirror on the same host. Restore meta/ before
|
||||||
|
# data/ or the layout no longer names this node and every bucket is orphaned.
|
||||||
20
infrastructure/garage-linode/host/install-wal-archive-firewall.sh
Executable file
20
infrastructure/garage-linode/host/install-wal-archive-firewall.sh
Executable file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Install the WAL-archive inbound guard on the Linode hub. Idempotent.
|
||||||
|
#
|
||||||
|
# sudo ./install-wal-archive-firewall.sh
|
||||||
|
#
|
||||||
|
# Verifies the table afterwards instead of trusting `systemctl start`'s exit 0.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
|
||||||
|
install -D -m 0644 "$here/wal-archive-firewall.nft" /etc/nftables.d/wal_archive_guard.nft
|
||||||
|
install -D -m 0644 "$here/wal-archive-firewall.service" /etc/systemd/system/wal-archive-firewall.service
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable --now wal-archive-firewall.service
|
||||||
|
|
||||||
|
nft list table inet wal_archive_guard >/dev/null
|
||||||
|
nft list table inet wal_archive_guard | grep -q 'dport { 3900, 3903 }'
|
||||||
|
echo "OK: wal_archive_guard loaded"
|
||||||
|
nft list table inet wal_archive_guard
|
||||||
41
infrastructure/garage-linode/host/wal-archive-firewall.nft
Normal file
41
infrastructure/garage-linode/host/wal-archive-firewall.nft
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#!/usr/sbin/nft -f
|
||||||
|
# WAL-archive inbound guard — defence in depth for Garage on the Linode hub.
|
||||||
|
#
|
||||||
|
# WHY THIS EXISTS AND WHY UFW ALONE IS NOT ENOUGH:
|
||||||
|
# On the Pi the risk is docker's DNAT bypassing ufw's INPUT chain. Here the
|
||||||
|
# store runs under podman with Network=host, so there is no DNAT to bypass —
|
||||||
|
# but the same rule shape is kept anyway, because the next person who adds a
|
||||||
|
# port mapping (or a second container that proxies this one) must not be able
|
||||||
|
# to reach 3900 from eth0 by accident. This table is evaluated in PREROUTING
|
||||||
|
# at priority -140, before any DNAT, so it binds the exposure to the transport
|
||||||
|
# rather than to how the listener was published.
|
||||||
|
#
|
||||||
|
# Effective policy for 3900 (S3 API) and 3903 (metrics/admin):
|
||||||
|
# accept from WireGuard (wg0) and loopback — incl. pod traffic arriving from
|
||||||
|
# the mesh with a 10.244.x source — drop everything else (eth0, LAN, public).
|
||||||
|
# DROP not REJECT: an off-mesh scan sees `filtered` and learns nothing.
|
||||||
|
#
|
||||||
|
# Note this is *in addition to* ufw, which on this host allows 22 from
|
||||||
|
# 10.20.0.0/24 and any from 10.10.0.0/24 / 10.244.0.0/16. ufw's own default is
|
||||||
|
# deny incoming, so the LAN path is already closed; this table keeps it closed
|
||||||
|
# even if someone later opens ufw wider for a different service.
|
||||||
|
#
|
||||||
|
# `destroy` (not `delete`) so re-running the unit replaces the table instead of
|
||||||
|
# appending a duplicate, and does not fail on first install.
|
||||||
|
|
||||||
|
destroy table inet wal_archive_guard
|
||||||
|
table inet wal_archive_guard {
|
||||||
|
chain prerouting {
|
||||||
|
type filter hook prerouting priority -140; policy accept;
|
||||||
|
|
||||||
|
# WireGuard mesh + hub link, and loopback (the garage CLI talks to
|
||||||
|
# 127.0.0.1:3901 inside this host namespace).
|
||||||
|
iifname { "lo", "wg0" } tcp dport { 3900, 3903 } counter accept
|
||||||
|
|
||||||
|
# Pods on this node reach the dummy-k8s address from the pod network.
|
||||||
|
ip saddr 10.244.0.0/16 tcp dport { 3900, 3903 } counter accept
|
||||||
|
|
||||||
|
# Everything else — eth0/public, any future interface nobody added above.
|
||||||
|
tcp dport { 3900, 3903 } counter drop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
# /etc/systemd/system/wal-archive-firewall.service (linode)
|
||||||
|
#
|
||||||
|
# Host unit, installed by hand (not Flux-managed) — the file lives in git at
|
||||||
|
# infrastructure/garage-linode/host/. Same shape as garage-firewall.service on
|
||||||
|
# the Pi and k8s-api-firewall.service on siriussec.
|
||||||
|
#
|
||||||
|
# No Requires= on wg-quick@wg0: the tunnel is enabled at boot on this host but a
|
||||||
|
# hard dependency would turn a transient tunnel failure into "store unguarded
|
||||||
|
# and unit failed". The table only filters; it can load before the interface
|
||||||
|
# exists.
|
||||||
|
[Unit]
|
||||||
|
Description=Drop off-WireGuard inbound to the Garage WAL archive (3900/3903)
|
||||||
|
After=network-online.target
|
||||||
|
Wants=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/sbin/nft -f /etc/nftables.d/wal_archive_guard.nft
|
||||||
|
RemainAfterExit=yes
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
60
infrastructure/garage-linode/install.sh
Executable file
60
infrastructure/garage-linode/install.sh
Executable file
|
|
@ -0,0 +1,60 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
# Install the Garage WAL archive on the Linode hub (10.10.0.5). Idempotent.
|
||||||
|
#
|
||||||
|
# sudo ./install.sh
|
||||||
|
#
|
||||||
|
# Installs: podman (if missing), /etc/garage/{garage.toml,garage.env},
|
||||||
|
# /etc/containers/systemd/garage.container, the nft guard, and the state dirs.
|
||||||
|
# Then starts the unit and assigns the node's layout capacity on first run.
|
||||||
|
#
|
||||||
|
# The RPC secret is generated once and never printed. Rewriting it on an
|
||||||
|
# existing install is harmless for a single-node store, but the copy in
|
||||||
|
# /root/garage-backup is what a rebuild should reuse.
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
here=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
|
||||||
|
command -v podman >/dev/null || {
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update -qq
|
||||||
|
apt-get install -y podman
|
||||||
|
}
|
||||||
|
|
||||||
|
install -d -m 0755 /etc/garage /etc/containers/systemd /etc/nftables.d
|
||||||
|
install -d -m 0700 /var/lib/garage/meta /var/lib/garage/data
|
||||||
|
|
||||||
|
install -m 0644 "$here/garage.toml" /etc/garage/garage.toml
|
||||||
|
install -m 0644 "$here/garage.container" /etc/containers/systemd/garage.container
|
||||||
|
|
||||||
|
if [ ! -s /etc/garage/garage.env ]; then
|
||||||
|
umask 077
|
||||||
|
printf 'GARAGE_RPC_SECRET=%s\n' "$(openssl rand -hex 32)" > /etc/garage/garage.env
|
||||||
|
fi
|
||||||
|
chmod 0600 /etc/garage/garage.env
|
||||||
|
|
||||||
|
# Guard first: the listener must never exist unguarded, not even for the
|
||||||
|
# seconds between `compose/quadlet up` and a firewall install.
|
||||||
|
"$here/host/install-wal-archive-firewall.sh" >/dev/null
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl start garage.service
|
||||||
|
|
||||||
|
# First run only: this Garage node needs a layout entry before it accepts
|
||||||
|
# writes. Capacity 20 GB against a 79 GB disk holding 29 GB of other data —
|
||||||
|
# see README "Disk sizing".
|
||||||
|
for _ in $(seq 1 30); do
|
||||||
|
garage_status=$(podman exec garage /garage -c /etc/garage.toml status 2>&1 || true)
|
||||||
|
grep -q 'NO ROLE' <<<"$garage_status" && break
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
if grep -q 'NO ROLE' <<<"$garage_status"; then
|
||||||
|
node_id=$(awk '/NO ROLE/{print $1}' <<<"$garage_status" | head -1)
|
||||||
|
podman exec garage /garage -c /etc/garage.toml layout assign -z dc1 -c 20G "$node_id"
|
||||||
|
podman exec garage /garage -c /etc/garage.toml layout apply --version 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Verify rather than assume.
|
||||||
|
podman exec garage /garage -c /etc/garage.toml status
|
||||||
|
ss -ltnH 'sport = :3900 or sport = :3903'
|
||||||
|
nft list table inet wal_archive_guard >/dev/null && echo "OK: wal_archive_guard loaded"
|
||||||
210
infrastructure/garage-linode/pitr-restore.md
Normal file
210
infrastructure/garage-linode/pitr-restore.md
Normal file
|
|
@ -0,0 +1,210 @@
|
||||||
|
# Restore notes — point-in-time recovery for `sirius-growth/portal`
|
||||||
|
|
||||||
|
Rehearsed end to end on **2026-11-19** against the live archive, twice: once with
|
||||||
|
the in-tree barman-cloud archiver (kanban `t_ce7d6772`) and once **after the
|
||||||
|
migration to the CNPG-I Barman Cloud plugin** (kanban `t_5df331de`). This file
|
||||||
|
records the commands and the actual output of the plugin rehearsal, so the next
|
||||||
|
person restores from a transcript instead of a hope.
|
||||||
|
|
||||||
|
The archive: Garage on the Linode, bucket `pg-wal-archive`, `http://10.10.0.5:3900`
|
||||||
|
over the WireGuard mesh, credentials in Secret `sirius-growth/portal-wal-s3`.
|
||||||
|
Producer: the **Barman Cloud plugin** — `ObjectStore sirius-growth/portal-wal`
|
||||||
|
(store + `retentionPolicy: 14d`), `Cluster portal` `spec.plugins`
|
||||||
|
(`isWALArchiver: true`, `serverName: portal`) and `ScheduledBackup portal-daily`
|
||||||
|
at 03:20 UTC with `method: plugin`. WAL archiving is continuous; base backups are
|
||||||
|
daily plus on demand.
|
||||||
|
|
||||||
|
## 0. Is the archive actually healthy?
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n sirius-growth exec portal-1 -c postgres -- \
|
||||||
|
psql -U postgres -tAc "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver"
|
||||||
|
# 000000010000000000000063|2026-11-19 23:05:16.834323+00|6
|
||||||
|
```
|
||||||
|
|
||||||
|
`last_archived_time` must be minutes old and the WAL name must advance when you
|
||||||
|
force a segment (`select pg_switch_wal()`). A `targetTime` after the last
|
||||||
|
archived WAL cannot be reached — recovery stops at the last segment it can fetch.
|
||||||
|
|
||||||
|
`failed_count` is **cumulative for the life of the instance**, not a "current
|
||||||
|
health" gauge: the 6 recorded here are from the pre-migration in-tree archiver
|
||||||
|
and the primary restart during the switch. What matters is that it does not
|
||||||
|
*increase* while you watch — check it before and after a forced segment.
|
||||||
|
|
||||||
|
What actually wrote the last segment is visible in the sidecar log, which names
|
||||||
|
barman's own arguments (server name `portal`, bucket root `s3://pg-wal-archive`):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n sirius-growth logs portal-1 -c plugin-barman-cloud --tail=20
|
||||||
|
# {"msg":"Executing barman-cloud-wal-archive", ... "options":["--gzip","--endpoint-url","http://10.10.0.5:3900",
|
||||||
|
# "--cloud-provider","aws-s3","s3://pg-wal-archive","portal","/var/lib/postgresql/data/pgdata/pg_wal/<seg>"]}
|
||||||
|
# {"msg":"Archived WAL file","walName":"...<seg>","elapsedWalTime":0.586...}
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n sirius-growth get backup -o wide # newest Backup: METHOD plugin, PHASE completed
|
||||||
|
kubectl -n sirius-growth get scheduledbackup # portal-daily, method plugin, LAST BACKUP set
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1. Prove the marker, then make the mistake
|
||||||
|
|
||||||
|
```bash
|
||||||
|
q() { kubectl -n sirius-growth exec portal-1 -c postgres -- psql -U postgres -d portal -tAc "$1"; }
|
||||||
|
q "create table if not exists pitr_probe(id bigserial primary key, note text, at timestamptz default now())"
|
||||||
|
q "insert into pitr_probe(note) values ('MARKER-plugin-before-target') returning id, at"
|
||||||
|
# 1|2026-11-19 23:04:53.072104+00
|
||||||
|
q "select pg_switch_wal()" ; sleep 12
|
||||||
|
q "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver"
|
||||||
|
# 000000010000000000000062|2026-11-19 23:04:54.052315+00|6
|
||||||
|
sleep 10
|
||||||
|
q "insert into pitr_probe(note) values ('POISON-plugin-after-target') returning id, at"
|
||||||
|
# 2|2026-11-19 23:05:15.798408+00
|
||||||
|
q "select pg_switch_wal()" ; sleep 12
|
||||||
|
q "select last_archived_wal, last_archived_time, failed_count from pg_stat_archiver"
|
||||||
|
# 000000010000000000000063|2026-11-19 23:05:16.834323+00|6
|
||||||
|
```
|
||||||
|
|
||||||
|
The target is therefore **`2026-11-19T23:05:00Z`** — 7 s after the marker, 15 s
|
||||||
|
before the row that must be lost. Note that WAL `…063` (which contains the poison
|
||||||
|
row) *is* in the archive: the restore has to choose to stop, it is not starved of
|
||||||
|
data.
|
||||||
|
|
||||||
|
## 2. Restore into a throwaway cluster
|
||||||
|
|
||||||
|
Never restore over the live `portal` cluster while it is serving.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: postgresql.cnpg.io/v1
|
||||||
|
kind: Cluster
|
||||||
|
metadata:
|
||||||
|
name: portal-pitr-test
|
||||||
|
namespace: sirius-growth
|
||||||
|
labels: {purpose: pitr-acceptance-test}
|
||||||
|
spec:
|
||||||
|
instances: 1
|
||||||
|
imageName: ghcr.io/cloudnative-pg/postgresql:16
|
||||||
|
storage: {size: 5Gi, storageClass: local-path}
|
||||||
|
affinity: {nodeSelector: {kubernetes.io/hostname: siriussec}}
|
||||||
|
resources:
|
||||||
|
requests: {cpu: 100m, memory: 256Mi}
|
||||||
|
limits: {memory: 1Gi}
|
||||||
|
bootstrap:
|
||||||
|
recovery:
|
||||||
|
source: portal-wal
|
||||||
|
recoveryTarget:
|
||||||
|
targetTime: "2026-11-19T23:05:00Z"
|
||||||
|
externalClusters:
|
||||||
|
- name: portal-wal
|
||||||
|
plugin: # was barmanObjectStore before the plugin migration
|
||||||
|
name: barman-cloud.cloudnative-pg.io
|
||||||
|
parameters:
|
||||||
|
barmanObjectName: portal-wal # ObjectStore in THIS namespace
|
||||||
|
serverName: portal # MUST be the *source* Cluster name
|
||||||
|
```
|
||||||
|
|
||||||
|
`serverName` is not optional: it is the barman prefix (`portal/base`,
|
||||||
|
`portal/wals`). Omit it and the plugin falls back to the *restoring* cluster's
|
||||||
|
name (`portal-pitr-test`) and finds an empty history. `targetTime` is UTC
|
||||||
|
RFC3339 — a wrong timezone silently restores the wrong hour. The ObjectStore's
|
||||||
|
own `spec.configuration.serverName` must stay empty (its CRD rejects anything
|
||||||
|
else); the prefix always comes from this plugin parameter.
|
||||||
|
|
||||||
|
The operator restores the base backup, replays WAL, stops at the target and
|
||||||
|
promotes:
|
||||||
|
|
||||||
|
```
|
||||||
|
ready=False phase=Setting up primary
|
||||||
|
ready=False phase=Waiting for the instances to become active
|
||||||
|
ready=True phase=Cluster in healthy state
|
||||||
|
portal-pitr-test 1 1 Cluster in healthy state portal-pitr-test-1
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. The acceptance evidence
|
||||||
|
|
||||||
|
```
|
||||||
|
$ kubectl -n sirius-growth exec portal-pitr-test-1 -c postgres -- \
|
||||||
|
psql -U postgres -d portal -c "select id, note, at from pitr_probe order by id"
|
||||||
|
id | note | at
|
||||||
|
----+-----------------------------+-------------------------------
|
||||||
|
1 | MARKER-plugin-before-target | 2026-11-19 23:04:53.072104+00
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
$ ... -tAc "select count(*) from pitr_probe where note like 'POISON%'"
|
||||||
|
0
|
||||||
|
```
|
||||||
|
|
||||||
|
Marker present, post-target row gone. The rest of the database came back with it
|
||||||
|
(physical restore, all databases, no `pg_restore` ordering games), e.g.
|
||||||
|
`clients 4 = 4`, `calendar_tokens 3 = 3`, `applications 1 = 1` against the
|
||||||
|
primary at that moment.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ ... -tAc "select pg_is_in_recovery()"
|
||||||
|
f # replay finished, instance promoted
|
||||||
|
```
|
||||||
|
|
||||||
|
`pg_is_in_recovery() = f` is expected here and is **not** a failure: a CNPG
|
||||||
|
recovery cluster with `instances: 1` promotes itself once it hits the target. It
|
||||||
|
is writable from that moment — which is why the test cluster must be deleted, and
|
||||||
|
why nothing may point application traffic at it before you decide to.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl -n sirius-growth delete cluster portal-pitr-test
|
||||||
|
kubectl -n sirius-growth delete pvc -l cnpg.io/cluster=portal-pitr-test
|
||||||
|
kubectl -n sirius-growth exec portal-1 -c postgres -- psql -U postgres -d portal -tAc "drop table if exists pitr_probe"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. Making the restored data the real data
|
||||||
|
|
||||||
|
Two shapes, both legitimate:
|
||||||
|
|
||||||
|
1. **Cut over (preferred, reversible).** Point the app at
|
||||||
|
`portal-pitr-test-rw` (`POSTGRES_HOST` in the API/portal Deployments — through
|
||||||
|
git, not `kubectl set env`), verify, then drop the old cluster only after the
|
||||||
|
app has been confirmed on the restored copy.
|
||||||
|
2. **In place.** Keep `portal`, stop its instances, and swap the PVC content from
|
||||||
|
the recovered data directory. Slower, destructive, and easy to get wrong —
|
||||||
|
only with the app scaled to zero.
|
||||||
|
|
||||||
|
Either way, take a fresh base backup once the decision is made (a `Backup` CR with
|
||||||
|
`method: plugin`, or `kubectl cnpg backup -n sirius-growth portal --method=plugin
|
||||||
|
--plugin-name=barman-cloud.cloudnative-pg.io`) so the archive has a post-recovery
|
||||||
|
base rather than one from before the incident.
|
||||||
|
|
||||||
|
## Gotchas that cost time
|
||||||
|
|
||||||
|
- **Flux owns `apps/base/sirius-growth/`.** A hand `kubectl apply` of the Cluster,
|
||||||
|
the ObjectStore or the ScheduledBackup is reverted by the `apps` Kustomization
|
||||||
|
within its 1 min interval. Config changes belong in the branch/PR. (`Cluster`
|
||||||
|
and `Backup` objects created by hand for a rehearsal are not in the
|
||||||
|
Kustomization inventory, so they are not pruned — but the objects Flux *does*
|
||||||
|
own are reverted.)
|
||||||
|
- **`ScheduledBackup.spec.schedule` is six-field cron, seconds first.** `0 20 3
|
||||||
|
* * *` = 03:20:00 UTC. Copying a five-field crontab string silently means
|
||||||
|
"every minute" in the first field.
|
||||||
|
- **Two different `serverName`s exist and only one may be set.** On the
|
||||||
|
`ObjectStore` it must be absent (CRD CEL rule); on the Cluster's
|
||||||
|
`spec.plugins[].parameters` / `externalClusters[].plugin.parameters` it is the
|
||||||
|
prefix. Set the wrong one and archiving writes to `portal-<something>/`, which
|
||||||
|
silently abandons the existing 14-day window.
|
||||||
|
- **The bucket prefix is `portal/portal/…` only if you get `destinationPath`
|
||||||
|
wrong.** Use `s3://pg-wal-archive` for the bucket root; the server name is
|
||||||
|
appended.
|
||||||
|
- **Plugin, not in-tree.** The operator's in-tree barman-cloud support is
|
||||||
|
deprecated in 1.30 and removed in 1.31; `spec.backup.barmanObjectStore` on a
|
||||||
|
1.31 operator would leave the cluster with no archiver at all. Restore config
|
||||||
|
is `externalClusters[].plugin` + `parameters.barmanObjectName`, and the store
|
||||||
|
itself is an `ObjectStore` CR in the cluster's namespace.
|
||||||
|
- **Retention moved.** `retentionPolicy` lives on the `ObjectStore` now, enforced
|
||||||
|
by the plugin sidecar every 30 min — not on the Cluster, and not "at backup
|
||||||
|
time".
|
||||||
|
- **Backup metrics changed family.** `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp`
|
||||||
|
replaces `cnpg_collector_last_available_backup_timestamp`. The old series for
|
||||||
|
`portal` still shows the pre-migration timestamp, so alert/dashboard queries
|
||||||
|
must prefer the new one (see `monitoring/controllers/home/dashboards/build.py`).
|
||||||
|
- **If archiving has failed** (`pg_stat_archiver.failed_count` increasing), fix it
|
||||||
|
and let a fresh base backup complete before trusting any recent `targetTime`.
|
||||||
|
- **Fallback when the archive is unusable:** the nightly `pg_dump` in
|
||||||
|
`forgejo/cluster-backup` (`db/sirius-growth-portal-<stamp>.dump`, 14 retained,
|
||||||
|
§8.2 step 2 of `docs/cluster-overview.md`). 24 h RPO, logical, independent of
|
||||||
|
barman and of the Linode Garage node.
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Own Gateway for the Customer 1 lab Metabase (:8087) — see
|
||||||
|
# gateway-customer1-odoo.yaml for why one bare-IP service per Gateway.
|
||||||
|
#
|
||||||
|
# This is NOT the evaluation instance in namespace `metabase` (:8085). Same
|
||||||
|
# reasoning applies to the port choice: one listener port carries exactly one
|
||||||
|
# internal service, so its route can never compete with another one.
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: Gateway
|
||||||
|
metadata:
|
||||||
|
name: customer1-metabase
|
||||||
|
namespace: internal
|
||||||
|
labels:
|
||||||
|
dedicated: network
|
||||||
|
annotations:
|
||||||
|
sirius.dev/purpose: bare-IP listener for the Customer 1 lab Metabase (WireGuard only)
|
||||||
|
spec:
|
||||||
|
gatewayClassName: cilium
|
||||||
|
listeners:
|
||||||
|
- name: http-internal
|
||||||
|
protocol: HTTP
|
||||||
|
# Verified free 2026-11-22: `ss -lntH "sport = :8087" | wc -l` = 0 on
|
||||||
|
# siriussec.
|
||||||
|
port: 8087
|
||||||
|
allowedRoutes:
|
||||||
|
namespaces:
|
||||||
|
from: All
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Own Gateway for Odoo because each bare-IP (hostname-less) service needs its own
|
||||||
|
# RouteConfiguration: Cilium renders one per Gateway and merges all hostname-less
|
||||||
|
# routes inside it into a single weighted route. Sharing a Gateway with Grafana
|
||||||
|
# (8081) / Hubble (8084) / Metabase (8085) or with the sibling :8087 listener
|
||||||
|
# here would make both ports answer for a random backend.
|
||||||
|
#
|
||||||
|
# Port 8086 must be free on EVERY node running cilium-envoy (siriussec 10.10.0.2
|
||||||
|
# is the only `gateway=true` node). Envoy binds 0.0.0.0:<port> hostNetwork, so
|
||||||
|
# the host firewall (infrastructure/networking/internal/host-firewall/) must be
|
||||||
|
# installed BEFORE this is pushed; otherwise the listener is open on the LAN the
|
||||||
|
# moment it is programmed.
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: Gateway
|
||||||
|
metadata:
|
||||||
|
name: customer1-odoo
|
||||||
|
namespace: internal
|
||||||
|
labels:
|
||||||
|
dedicated: network
|
||||||
|
annotations:
|
||||||
|
sirius.dev/purpose: bare-IP listener for the Customer 1 lab Odoo (WireGuard only)
|
||||||
|
spec:
|
||||||
|
gatewayClassName: cilium
|
||||||
|
listeners:
|
||||||
|
- name: http-internal
|
||||||
|
protocol: HTTP
|
||||||
|
# Verified free 2026-11-22: `ss -lntH "sport = :8086" | wc -l` = 0 on
|
||||||
|
# siriussec. Taken: 8080 public, 8081 Grafana, 8084 Hubble, 8085 Metabase.
|
||||||
|
port: 8086
|
||||||
|
allowedRoutes:
|
||||||
|
namespaces:
|
||||||
|
from: All
|
||||||
31
infrastructure/networking/internal/gateway-metabase.yaml
Normal file
31
infrastructure/networking/internal/gateway-metabase.yaml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
apiVersion: gateway.networking.k8s.io/v1
|
||||||
|
kind: Gateway
|
||||||
|
metadata:
|
||||||
|
name: metabase
|
||||||
|
namespace: internal
|
||||||
|
labels:
|
||||||
|
dedicated: network
|
||||||
|
annotations:
|
||||||
|
# Why a second Gateway instead of a second listener on `internal`:
|
||||||
|
# Cilium renders one RouteConfiguration per Gateway shared by all its
|
||||||
|
# listeners, so a hostname-less route on any listener of `internal` would
|
||||||
|
# merge with Grafana's into one 50/50 weighted route. Its own Gateway gives
|
||||||
|
# it its own RouteConfiguration.
|
||||||
|
sirius.dev/purpose: bare-IP listener for Metabase (WireGuard only)
|
||||||
|
spec:
|
||||||
|
gatewayClassName: cilium
|
||||||
|
listeners:
|
||||||
|
- name: http-internal
|
||||||
|
protocol: HTTP
|
||||||
|
# PORT MUST BE FREE ON *EVERY* NODE THAT RUNS cilium-envoy (siriussec
|
||||||
|
# 10.10.0.2 is the only `gateway=true` node today). Cilium binds
|
||||||
|
# 0.0.0.0:<port> hostNetwork, so a port held by anything else on a gateway
|
||||||
|
# node makes xDS reject the listener there ("cannot bind '0.0.0.0:<port>':
|
||||||
|
# Address already in use") and restart-loops that node's Envoy — which
|
||||||
|
# fronts the public ingress. Verified free 2026-11-22:
|
||||||
|
# `ss -lntH "sport = :8085" | wc -l` = 0 on siriussec.
|
||||||
|
# 8080 (public), 8081 (Grafana), 8084 (Hubble UI) are taken.
|
||||||
|
port: 8085
|
||||||
|
allowedRoutes:
|
||||||
|
namespaces:
|
||||||
|
from: All
|
||||||
|
|
@ -21,7 +21,8 @@ exactly one node.
|
||||||
| siriussec (10.10.0.2) — **load bearing** | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` |
|
| siriussec (10.10.0.2) — **load bearing** | nftables table `inet internal_gw`, loaded by a oneshot unit (same pattern as `k8s-api-firewall.service`) | `siriussec-internal-gw.nft`, `internal-gw-firewall.service` |
|
||||||
| rpi (10.10.0.1) — **inert guard** | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` |
|
| rpi (10.10.0.1) — **inert guard** | ufw rules inserted above the `allow from 192.168.1.0/24` catch-all | `rpi-ufw-internal-gw.sh` |
|
||||||
|
|
||||||
Effective policy for `:8081` (Grafana) and `:8084` (Hubble UI):
|
Effective policy for `:8081` (Grafana), `:8084` (Hubble UI) and `:8085`
|
||||||
|
(Metabase):
|
||||||
**accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything
|
**accept from 10.10.0.0/24 and 10.244.0.0/16, accept on lo, drop everything
|
||||||
else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a
|
else** (LAN, tailscale, public). Envoy binds every listener on `0.0.0.0`, so a
|
||||||
new internal listener port is a LAN exposure until it is added here. The
|
new internal listener port is a LAN exposure until it is added here. The
|
||||||
|
|
@ -56,7 +57,7 @@ Verify:
|
||||||
# the drop counter non-zero after a LAN request
|
# the drop counter non-zero after a LAN request
|
||||||
nft list table inet internal_gw
|
nft list table inet internal_gw
|
||||||
# rpi
|
# rpi
|
||||||
ufw status | grep -E '8081|8084'
|
ufw status | grep -E '8081|8084|8085'
|
||||||
```
|
```
|
||||||
|
|
||||||
Negative test from the LAN must be a timeout (DROP), never 200:
|
Negative test from the LAN must be a timeout (DROP), never 200:
|
||||||
|
|
@ -70,4 +71,4 @@ When a new internal listener port is added, add it to the `tcp dport { … }` se
|
||||||
in `siriussec-internal-gw.nft` and to `PORTS` in `rpi-ufw-internal-gw.sh` (which
|
in `siriussec-internal-gw.nft` and to `PORTS` in `rpi-ufw-internal-gw.sh` (which
|
||||||
inserts one deny for the port plus mesh and pod-CIDR allows above the LAN
|
inserts one deny for the port plus mesh and pod-CIDR allows above the LAN
|
||||||
catch-all), then reinstall both and re-run the two negative tests above with the
|
catch-all), then reinstall both and re-run the two negative tests above with the
|
||||||
new port.
|
new port.
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
# Flux-managed); the file lives in git at
|
# Flux-managed); the file lives in git at
|
||||||
# infrastructure/networking/internal/host-firewall/.
|
# infrastructure/networking/internal/host-firewall/.
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Restrict the internal Gateway listeners (8081, 8082) to WireGuard
|
Description=Restrict the internal Gateway listeners (8081, 8084, 8085) to WireGuard
|
||||||
After=network-online.target
|
After=network-online.target
|
||||||
Wants=network-online.target
|
Wants=network-online.target
|
||||||
|
|
||||||
|
|
@ -14,4 +14,4 @@ ExecStart=/usr/sbin/nft -f /etc/nftables.d/internal-gw.nft
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
@ -6,14 +6,17 @@
|
||||||
# Final order per port: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest.
|
# Final order per port: allow 10.10.0.0/24, allow 10.244.0.0/16, deny the rest.
|
||||||
#
|
#
|
||||||
# Ports: 8081 = Grafana (`internal` Gateway listener http-internal),
|
# Ports: 8081 = Grafana (`internal` Gateway listener http-internal),
|
||||||
# 8084 = Hubble UI (`internal` Gateway listener hubble-ui).
|
# 8084 = Hubble UI (`internal` Gateway listener hubble-ui),
|
||||||
|
# 8085 = Metabase (`metabase` Gateway listener http-internal),
|
||||||
|
# 8086 = Customer 1 lab Odoo (`customer1-odoo` Gateway),
|
||||||
|
# 8087 = Customer 1 lab Metabase (`customer1-metabase` Gateway).
|
||||||
# Add a new internal listener port to PORTS; the loop is idempotent, so
|
# Add a new internal listener port to PORTS; the loop is idempotent, so
|
||||||
# re-running after a port is already firewalled only adds what is missing.
|
# re-running after a port is already firewalled only adds what is missing.
|
||||||
#
|
#
|
||||||
# Run as root on rpi (192.168.1.125).
|
# Run as root on rpi (192.168.1.125).
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
PORTS="${PORTS:-8081 8084}"
|
PORTS="${PORTS:-8081 8084 8085 8086 8087}"
|
||||||
|
|
||||||
for port in $PORTS; do
|
for port in $PORTS; do
|
||||||
if ufw status | grep -q "${port}/tcp"; then
|
if ufw status | grep -q "${port}/tcp"; then
|
||||||
|
|
@ -28,4 +31,4 @@ for port in $PORTS; do
|
||||||
|
|
||||||
echo "$port rules installed:"
|
echo "$port rules installed:"
|
||||||
ufw status | grep "${port}/tcp" || true
|
ufw status | grep "${port}/tcp" || true
|
||||||
done
|
done
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/sbin/nft -f
|
#!/usr/sbin/nft -f
|
||||||
# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana) and 8084
|
# Internal (WireGuard-only) gateway listeners: TCP 8081 (Grafana), 8084
|
||||||
# (Hubble UI).
|
# (Hubble UI), 8085 (Metabase) and 8086/8087 (Customer 1 lab replica: Odoo,
|
||||||
|
# Metabase).
|
||||||
#
|
#
|
||||||
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the
|
# Cilium's hostNetwork Envoy binds every Gateway listener on 0.0.0.0, so the
|
||||||
# internal listeners are open on the LAN interface the moment the Gateway is
|
# internal listeners are open on the LAN interface the moment the Gateway is
|
||||||
|
|
@ -22,13 +23,13 @@ table inet internal_gw {
|
||||||
type filter hook input priority filter; policy accept;
|
type filter hook input priority filter; policy accept;
|
||||||
|
|
||||||
# local process / kubelet probes
|
# local process / kubelet probes
|
||||||
tcp dport { 8081, 8084 } iifname "lo" counter accept
|
tcp dport { 8081, 8084, 8085, 8086, 8087 } iifname "lo" counter accept
|
||||||
|
|
||||||
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes)
|
# WireGuard mesh (Legion = 10.10.0.3, nodes, remote hub spokes)
|
||||||
# and the pod network (in-cluster scrapers, probes)
|
# and the pod network (in-cluster scrapers, probes)
|
||||||
tcp dport { 8081, 8084 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept
|
tcp dport { 8081, 8084, 8085, 8086, 8087 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter accept
|
||||||
|
|
||||||
# everything else: LAN, tailscale, public
|
# everything else: LAN, tailscale, public
|
||||||
tcp dport { 8081, 8084 } counter drop
|
tcp dport { 8081, 8084, 8085, 8086, 8087 } counter drop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,3 +4,6 @@ resources:
|
||||||
- namespace.yaml
|
- namespace.yaml
|
||||||
- gateway.yaml
|
- gateway.yaml
|
||||||
- gateway-hubble-ui.yaml
|
- gateway-hubble-ui.yaml
|
||||||
|
- gateway-metabase.yaml
|
||||||
|
- gateway-customer1-odoo.yaml
|
||||||
|
- gateway-customer1-metabase.yaml
|
||||||
|
|
|
||||||
|
|
@ -2,3 +2,4 @@ apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
- local-path-storage.yaml
|
- local-path-storage.yaml
|
||||||
|
- local-path-linode.yaml
|
||||||
|
|
|
||||||
122
infrastructure/storage/local-path-linode.yaml
Normal file
122
infrastructure/storage/local-path-linode.yaml
Normal file
|
|
@ -0,0 +1,122 @@
|
||||||
|
# Second local-path provisioner, pinned to the `linode` worker.
|
||||||
|
#
|
||||||
|
# The original `local-path` StorageClass keeps its single-replica provisioner on
|
||||||
|
# siriussec (and its helper pod pinned there), so a PVC consumed by a pod on
|
||||||
|
# linode would have its directory created on the ThinkPad's disk. This file adds
|
||||||
|
# an independent provisioner + StorageClass whose volumes live on linode's own
|
||||||
|
# disk. `local-path` remains the cluster default; nothing here touches it.
|
||||||
|
#
|
||||||
|
# Volumes land under /opt/local-path-provisioner/pvc-<uuid>_<ns>_<pvc> on linode.
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: local-path-config-linode
|
||||||
|
namespace: local-path-storage
|
||||||
|
data:
|
||||||
|
config.json: |-
|
||||||
|
{
|
||||||
|
"nodePathMap":[
|
||||||
|
{
|
||||||
|
"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
|
||||||
|
"paths":["/opt/local-path-provisioner"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"node":"linode",
|
||||||
|
"paths":["/opt/local-path-provisioner"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
setup: |-
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
mkdir -m 0777 -p "$VOL_DIR"
|
||||||
|
teardown: |-
|
||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
rm -rf "$VOL_DIR"
|
||||||
|
helperPod.yaml: |-
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: helper-pod
|
||||||
|
spec:
|
||||||
|
priorityClassName: system-node-critical
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: linode
|
||||||
|
tolerations:
|
||||||
|
- key: node.kubernetes.io/disk-pressure
|
||||||
|
operator: Exists
|
||||||
|
effect: NoSchedule
|
||||||
|
- key: dedicated
|
||||||
|
operator: Equal
|
||||||
|
value: network
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
containers:
|
||||||
|
- name: helper-pod
|
||||||
|
image: busybox
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: local-path-provisioner-linode
|
||||||
|
namespace: local-path-storage
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: local-path-provisioner-linode
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: local-path-provisioner-linode
|
||||||
|
spec:
|
||||||
|
serviceAccountName: local-path-provisioner-service-account
|
||||||
|
nodeSelector:
|
||||||
|
kubernetes.io/hostname: linode
|
||||||
|
tolerations:
|
||||||
|
- key: dedicated
|
||||||
|
operator: Equal
|
||||||
|
value: network
|
||||||
|
effect: PreferNoSchedule
|
||||||
|
containers:
|
||||||
|
- name: local-path-provisioner
|
||||||
|
image: rancher/local-path-provisioner:v0.0.31
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- local-path-provisioner
|
||||||
|
- --debug
|
||||||
|
- start
|
||||||
|
- --config
|
||||||
|
- /etc/config/config.json
|
||||||
|
- --provisioner-name
|
||||||
|
- rancher.io/local-path-linode
|
||||||
|
- --configmap-name
|
||||||
|
- local-path-config-linode
|
||||||
|
volumeMounts:
|
||||||
|
- name: config-volume
|
||||||
|
mountPath: /etc/config/
|
||||||
|
env:
|
||||||
|
- name: POD_NAMESPACE
|
||||||
|
valueFrom:
|
||||||
|
fieldRef:
|
||||||
|
fieldPath: metadata.namespace
|
||||||
|
- name: CONFIG_MOUNT_PATH
|
||||||
|
value: /etc/config/
|
||||||
|
- name: KUBERNETES_SERVICE_HOST
|
||||||
|
value: "10.10.0.2"
|
||||||
|
- name: KUBERNETES_SERVICE_PORT
|
||||||
|
value: "6443"
|
||||||
|
volumes:
|
||||||
|
- name: config-volume
|
||||||
|
configMap:
|
||||||
|
name: local-path-config-linode
|
||||||
|
---
|
||||||
|
apiVersion: storage.k8s.io/v1
|
||||||
|
kind: StorageClass
|
||||||
|
metadata:
|
||||||
|
name: local-path-linode
|
||||||
|
provisioner: rancher.io/local-path-linode
|
||||||
|
volumeBindingMode: WaitForFirstConsumer
|
||||||
|
reclaimPolicy: Delete
|
||||||
|
|
@ -245,9 +245,9 @@ cnpg = [
|
||||||
{"h": 5, "w": 4, "x": 16, "y": 1},
|
{"h": 5, "w": 4, "x": 16, "y": 1},
|
||||||
desc="1 = the operator is asking for a manual switchover (e.g. after a fencing event).",
|
desc="1 = the operator is asking for a manual switchover (e.g. after a fencing event).",
|
||||||
thresholds=[{"color": "green", "value": None}, {"color": "red", "value": 1}]),
|
thresholds=[{"color": "green", "value": None}, {"color": "red", "value": 1}]),
|
||||||
stat("Last available backup", [target('max by (namespace) (cnpg_collector_last_available_backup_timestamp{%s})' % CLUSTER_NS)],
|
stat("Last available backup", [target('max by (namespace) (barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{%s} or cnpg_collector_last_available_backup_timestamp{%s})' % (CLUSTER_NS, CLUSTER_NS))],
|
||||||
{"h": 5, "w": 4, "x": 20, "y": 1}, unit="dateTimeAsIso",
|
{"h": 5, "w": 4, "x": 20, "y": 1}, unit="dateTimeAsIso",
|
||||||
desc="0 = never. There are NO Backup/Cluster backup resources in this cluster (verified: `kubectl get backups.postgresql.cnpg.io -A` is empty), so a 0 here is the honest answer, not a broken panel.",
|
desc="0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, whose metric is `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp`; the deprecated `cnpg_collector_*` name is the fallback for any cluster still on the in-tree path. Order matters: the legacy series is still scraped for portal and holds the PRE-migration timestamp, so it must not win the `or`.",
|
||||||
thresholds=[{"color": "red", "value": None}, {"color": "green", "value": 1}]),
|
thresholds=[{"color": "red", "value": None}, {"color": "green", "value": 1}]),
|
||||||
|
|
||||||
row("Throughput", 6),
|
row("Throughput", 6),
|
||||||
|
|
@ -280,10 +280,10 @@ cnpg = [
|
||||||
desc="pg_database_size. Both PVs are 10Gi (forgejo/pg) and 5Gi (sirius-growth/portal) — this is the trend that fills them."),
|
desc="pg_database_size. Both PVs are 10Gi (forgejo/pg) and 5Gi (sirius-growth/portal) — this is the trend that fills them."),
|
||||||
ts("WAL generation", [target('sum by (namespace) (rate(cnpg_collector_wal_bytes{%s}[5m]))' % CLUSTER_NS, "{{namespace}}")],
|
ts("WAL generation", [target('sum by (namespace) (rate(cnpg_collector_wal_bytes{%s}[5m]))' % CLUSTER_NS, "{{namespace}}")],
|
||||||
{"h": 8, "w": 8, "x": 8, "y": 25}, unit="Bps",
|
{"h": 8, "w": 8, "x": 8, "y": 25}, unit="Bps",
|
||||||
desc="Bytes of WAL written per second. On a cluster with no backups, WAL has nothing archiving it away."),
|
desc="Bytes of WAL written per second. sirius-growth/portal archives its WAL to the Linode Garage; forgejo/pg does not archive, so its WAL only ever fills the pg_wal directory."),
|
||||||
ts("WAL archiver failures", [target('max by (namespace) (cnpg_pg_stat_archiver_failed_count{%s})' % CLUSTER_NS, "{{namespace}}")],
|
ts("WAL archiver failures", [target('max by (namespace) (cnpg_pg_stat_archiver_failed_count{%s})' % CLUSTER_NS, "{{namespace}}")],
|
||||||
{"h": 8, "w": 8, "x": 16, "y": 25}, unit="short",
|
{"h": 8, "w": 8, "x": 16, "y": 25}, unit="short",
|
||||||
desc="pg_stat_archiver.failed_count. Archiving is not configured on either cluster (no ObjectStore/backup), so treat non-zero here as 'something was attempted and failed'."),
|
desc="pg_stat_archiver.failed_count. Archiving is configured only on sirius-growth/portal (Barman Cloud plugin -> Linode Garage); forgejo/pg has no archiver, so any non-zero value is the honest signal that WAL failed to reach the archive."),
|
||||||
|
|
||||||
row("Replication (single instance — panels are honest about it)", 33),
|
row("Replication (single instance — panels are honest about it)", 33),
|
||||||
ts("Replication lag", [target('max by (namespace) (cnpg_pg_replication_lag{%s})' % CLUSTER_NS, "{{namespace}}")],
|
ts("Replication lag", [target('max by (namespace) (cnpg_pg_replication_lag{%s})' % CLUSTER_NS, "{{namespace}}")],
|
||||||
|
|
@ -294,9 +294,11 @@ cnpg = [
|
||||||
{"h": 6, "w": 8, "x": 8, "y": 34}, unit="short",
|
{"h": 6, "w": 8, "x": 8, "y": 34}, unit="short",
|
||||||
desc="Both clusters run instances: 1, so 0 streaming replicas and in_recovery=0 is the correct reading. A future replica would light these up with no dashboard change."),
|
desc="Both clusters run instances: 1, so 0 streaming replicas and in_recovery=0 is the correct reading. A future replica would light these up with no dashboard change."),
|
||||||
note("Known unknowns on the CNPG board", """\
|
note("Known unknowns on the CNPG board", """\
|
||||||
- **No backups exist.** `kubectl get backups.postgresql.cnpg.io -A` returns nothing; neither Cluster
|
- **Backups exist on one cluster only.** `sirius-growth/portal` archives WAL + daily base backups
|
||||||
declares `spec.backup`. The "Last available backup" stat therefore reads 0 (never) — that is the
|
through the CNPG-I Barman Cloud plugin (`ObjectStore portal-wal`) into the Linode Garage;
|
||||||
real state, not a missing metric.
|
`forgejo/pg` has no archiver by design. The "Last available backup" stat reads 0 only if neither
|
||||||
|
the plugin's `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` nor the legacy
|
||||||
|
`cnpg_collector_last_available_backup_timestamp` series exists.
|
||||||
- **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas /
|
- **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas /
|
||||||
in recovery are structurally zero. The panels show the zero and say so instead of hiding them.
|
in recovery are structurally zero. The panels show the zero and say so instead of hiding them.
|
||||||
- **Query age vs transaction age.** CNPG's default query set exposes
|
- **Query age vs transaction age.** CNPG's default query set exposes
|
||||||
|
|
|
||||||
|
|
@ -423,7 +423,7 @@ data:
|
||||||
"id": 29,
|
"id": 29,
|
||||||
"type": "stat",
|
"type": "stat",
|
||||||
"title": "Last available backup",
|
"title": "Last available backup",
|
||||||
"description": "0 = never. There are NO Backup/Cluster backup resources in this cluster (verified: `kubectl get backups.postgresql.cnpg.io -A` is empty), so a 0 here is the honest answer, not a broken panel.",
|
"description": "0 = never. sirius-growth/portal archives through the CNPG-I Barman Cloud plugin, whose metric is `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp`; the deprecated `cnpg_collector_*` name is the fallback for any cluster still on the in-tree path. Order matters: the legacy series is still scraped for portal and holds the PRE-migration timestamp, so it must not win the `or`.",
|
||||||
"datasource": {
|
"datasource": {
|
||||||
"type": "prometheus",
|
"type": "prometheus",
|
||||||
"uid": "prometheus"
|
"uid": "prometheus"
|
||||||
|
|
@ -440,7 +440,7 @@ data:
|
||||||
"type": "prometheus",
|
"type": "prometheus",
|
||||||
"uid": "prometheus"
|
"uid": "prometheus"
|
||||||
},
|
},
|
||||||
"expr": "max by (namespace) (cnpg_collector_last_available_backup_timestamp{namespace=~\"$namespace\"})",
|
"expr": "max by (namespace) (barman_cloud_cloudnative_pg_io_last_available_backup_timestamp{namespace=~\"$namespace\"} or cnpg_collector_last_available_backup_timestamp{namespace=~\"$namespace\"})",
|
||||||
"refId": "A",
|
"refId": "A",
|
||||||
"editorMode": "code",
|
"editorMode": "code",
|
||||||
"range": true,
|
"range": true,
|
||||||
|
|
@ -937,7 +937,7 @@ data:
|
||||||
"id": 40,
|
"id": 40,
|
||||||
"type": "timeseries",
|
"type": "timeseries",
|
||||||
"title": "WAL generation",
|
"title": "WAL generation",
|
||||||
"description": "Bytes of WAL written per second. On a cluster with no backups, WAL has nothing archiving it away.",
|
"description": "Bytes of WAL written per second. sirius-growth/portal archives its WAL to the Linode Garage; forgejo/pg does not archive, so its WAL only ever fills the pg_wal directory.",
|
||||||
"datasource": {
|
"datasource": {
|
||||||
"type": "prometheus",
|
"type": "prometheus",
|
||||||
"uid": "prometheus"
|
"uid": "prometheus"
|
||||||
|
|
@ -994,7 +994,7 @@ data:
|
||||||
"id": 41,
|
"id": 41,
|
||||||
"type": "timeseries",
|
"type": "timeseries",
|
||||||
"title": "WAL archiver failures",
|
"title": "WAL archiver failures",
|
||||||
"description": "pg_stat_archiver.failed_count. Archiving is not configured on either cluster (no ObjectStore/backup), so treat non-zero here as 'something was attempted and failed'.",
|
"description": "pg_stat_archiver.failed_count. Archiving is configured only on sirius-growth/portal (Barman Cloud plugin -> Linode Garage); forgejo/pg has no archiver, so any non-zero value is the honest signal that WAL failed to reach the archive.",
|
||||||
"datasource": {
|
"datasource": {
|
||||||
"type": "prometheus",
|
"type": "prometheus",
|
||||||
"uid": "prometheus"
|
"uid": "prometheus"
|
||||||
|
|
@ -1203,7 +1203,7 @@ data:
|
||||||
"showLineNumbers": false,
|
"showLineNumbers": false,
|
||||||
"showMiniMap": false
|
"showMiniMap": false
|
||||||
},
|
},
|
||||||
"content": "- **No backups exist.** `kubectl get backups.postgresql.cnpg.io -A` returns nothing; neither Cluster\n declares `spec.backup`. The \"Last available backup\" stat therefore reads 0 (never) \u2014 that is the\n real state, not a missing metric.\n- **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas /\n in recovery are structurally zero. The panels show the zero and say so instead of hiding them.\n- **Query age vs transaction age.** CNPG's default query set exposes\n `cnpg_backends_max_tx_duration_seconds` (transaction age). Per-statement `query_start` age is not in\n the default set; adding it would need another custom query in the cluster's\n `customQueriesConfigMap`.\n- **Permissions.** Custom queries run as `cnpg_metrics_exporter`, not superuser. See\n docs/monitoring-dashboards.md for the GRANT the Forgejo Actions metrics need.\n"
|
"content": "- **Backups exist on one cluster only.** `sirius-growth/portal` archives WAL + daily base backups\n through the CNPG-I Barman Cloud plugin (`ObjectStore portal-wal`) into the Linode Garage;\n `forgejo/pg` has no archiver by design. The \"Last available backup\" stat reads 0 only if neither\n the plugin's `barman_cloud_cloudnative_pg_io_last_available_backup_timestamp` nor the legacy\n `cnpg_collector_last_available_backup_timestamp` series exists.\n- **Single instance.** Both clusters run `instances: 1`, so replication lag / streaming replicas /\n in recovery are structurally zero. The panels show the zero and say so instead of hiding them.\n- **Query age vs transaction age.** CNPG's default query set exposes\n `cnpg_backends_max_tx_duration_seconds` (transaction age). Per-statement `query_start` age is not in\n the default set; adding it would need another custom query in the cluster's\n `customQueriesConfigMap`.\n- **Permissions.** Custom queries run as `cnpg_metrics_exporter`, not superuser. See\n docs/monitoring-dashboards.md for the GRANT the Forgejo Actions metrics need.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue