Compare commits
167 changed files with 289 additions and 38152 deletions
185
README.md
185
README.md
|
|
@ -1,136 +1,73 @@
|
||||||
# HomeK8s
|
# HomeK8s
|
||||||
|
|
||||||
A three-node Kubernetes cluster: two machines on a home network and one cloud
|
Home Kubernetes cluster (kubeadm), same GitOps layout as `lab/`.
|
||||||
VPS, joined with kubeadm and reconciled from this repository by Flux CD. The
|
|
||||||
manifests here run the public sites listed below, plus the git server and CI
|
|
||||||
that build them.
|
|
||||||
|
|
||||||
## Architecture
|
Flux CD will take over once Forgejo is back. Until then apply with kustomize:
|
||||||
|
|
||||||
```mermaid
|
```bash
|
||||||
flowchart LR
|
kubectl apply -k infrastructure/home
|
||||||
net([Internet]) --> cf["Cloudflare TLS"]
|
|
||||||
cf --> t["cloudflared<br/>rpi, host service"]
|
|
||||||
t --> gw["Cilium Gateway<br/>gateway-system/public<br/>10.10.0.2:8080"]
|
|
||||||
gw --> rt["HTTPRoute"]
|
|
||||||
rt --> svc["Service"]
|
|
||||||
svc --> pod["Pods<br/>siriussec"]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Public requests terminate at Cloudflare and are carried by a cloudflared tunnel
|
## Cluster
|
||||||
on `rpi` to the Cilium Gateway on `siriussec` at `http://10.10.0.2:8080`, where a
|
|
||||||
Gateway API HTTPRoute selects the Service. The tunnel is the only public ingress.
|
|
||||||
|
|
||||||
Nodes and pods reach each other over a WireGuard mesh in `10.10.0.0/24`. Cilium
|
| Node | WG IP | Roles | Notes |
|
||||||
routes pod traffic natively across that tunnel — `10.244.0.0/16`, no VXLAN
|
|-------------|------------|--------------------------|--------------------------------------------|
|
||||||
overlay, and kube-proxy is replaced by Cilium's BPF data path.
|
| siriussec | 10.10.0.2 | control-plane, worker | default scheduling |
|
||||||
|
| rpi | 10.10.0.1 | traffic, worker | `dedicated=network:PreferNoSchedule` |
|
||||||
|
|
||||||
## Nodes
|
- CNI: Cilium 1.18.13, kube-proxy replacement, Gateway API hostNetwork on `dedicated=network`
|
||||||
|
- Overlay: WireGuard `10.10.0.0/24` (API only on WG)
|
||||||
|
- Ingress: Cloudflare tunnel → `127.0.0.1:8080` on rpi → Gateway `gateway-system/public`
|
||||||
|
- Storage: local-path on siriussec (`/opt/local-path-provisioner`)
|
||||||
|
|
||||||
| Node | Roles | WireGuard IP | Architecture | OS, kernel | Runtime |
|
Pin traffic / light workloads to the Pi:
|
||||||
|------|-------|--------------|--------------|------------|---------|
|
|
||||||
| `siriussec` | control-plane, gateway, worker | `10.10.0.2` | amd64 | Arch Linux, 6.18.50-2-lts | containerd 2.3.5 |
|
|
||||||
| `rpi` | traffic, worker | `10.10.0.1` | arm64 | Debian 13, 6.18.39+rpt-rpi-2712 | containerd 2.3.4 |
|
|
||||||
| `linode` | none | `10.10.0.5` | amd64 | Debian 13, 6.12.113+deb13-amd64 | containerd 2.3.5 |
|
|
||||||
|
|
||||||
`siriussec` is the only node carrying the `gateway` role: Cilium's host-network
|
```yaml
|
||||||
Envoy must run on the same node as the backends, so every public workload is
|
nodeSelector:
|
||||||
pinned there along with the default `local-path` volume. `rpi` is the WireGuard
|
dedicated: network
|
||||||
hub and runs the cloudflared tunnel host service; it is arm64 and carries
|
|
||||||
network-adjacent pods, marked with a `dedicated=network:PreferNoSchedule`
|
|
||||||
preference so the application nodes are used first.
|
|
||||||
|
|
||||||
`linode` is a cloud worker and is the least permanent node of the three —
|
|
||||||
confirm the current node list with `kubectl get nodes` rather than relying on
|
|
||||||
this table.
|
|
||||||
|
|
||||||
## Stack
|
|
||||||
|
|
||||||
| Layer | Component | Version |
|
|
||||||
|-------|-----------|---------|
|
|
||||||
| Cluster | Kubernetes (kubeadm) | v1.36.4 |
|
|
||||||
| CNI and data path | Cilium | chart 1.20.1 |
|
|
||||||
| GitOps | Flux CD | six Kustomizations, watching `master` |
|
|
||||||
| Ingress | Cloudflare Tunnel into Cilium Gateway API | — |
|
|
||||||
| Monitoring | kube-prometheus-stack | chart 92.14.0 |
|
|
||||||
| Databases | CloudNativePG | operator 1.30.0, `postgresql:16` |
|
|
||||||
| Container runtime | containerd | 2.3.5 (2.3.4 on `rpi`) |
|
|
||||||
|
|
||||||
Storage is the Rancher `local-path` provisioner, the default StorageClass, backed
|
|
||||||
by `/opt/local-path-provisioner` on `siriussec`. Host-path volumes that must stay
|
|
||||||
on the Pi use a second, static `local-static` StorageClass with `Retain`.
|
|
||||||
|
|
||||||
## Services
|
|
||||||
|
|
||||||
Public hostnames, all terminating on the Gateway above:
|
|
||||||
|
|
||||||
| Hostname | Route | What it serves |
|
|
||||||
|----------|-------|----------------|
|
|
||||||
| `forgejo.siriusdevops.com` | `forgejo/forgejo` | Forgejo git server and container registry |
|
|
||||||
| `siriusdevops.com`, `www.siriusdevops.com` | `siriusdevops/siriusdevops` | Static site and contact API |
|
|
||||||
| `siriusgrowthsolutions.com`, `www.siriusgrowthsolutions.com` | `sirius-growth/sirius-growth` | Static site, contact API, client portal |
|
|
||||||
| `piedmonthomesvc.com`, `www.piedmonthomesvc.com` | `piedmont/piedmont` | Static site and contact API |
|
|
||||||
|
|
||||||
The git server and the client portal each run a single-instance CloudNativePG
|
|
||||||
cluster (`forgejo/pg`, `sirius-growth/portal`). CI runs on the cluster itself:
|
|
||||||
three Forgejo Actions runners execute jobs inside their own Docker-in-Docker
|
|
||||||
sidecars, covering both arm64 and amd64.
|
|
||||||
|
|
||||||
Two services are deliberately not public. They answer on the bare WireGuard
|
|
||||||
address, with no hostname and no `Host` header, and are reachable only from
|
|
||||||
inside the tunnel:
|
|
||||||
|
|
||||||
| Service | Route | Address | Response |
|
|
||||||
|---------|-------|---------|----------|
|
|
||||||
| Grafana | `monitoring/grafana` → `internal` | `http://10.10.0.2:8081/` | 302 to `/login` |
|
|
||||||
| Hubble UI | `kube-system/hubble-ui` → `hubble-ui` | `http://10.10.0.2:8084/` | 200 |
|
|
||||||
|
|
||||||
Each needs its own Gateway object: Cilium renders one route table per Gateway,
|
|
||||||
so two hostname-less routes sharing a Gateway would answer for either backend.
|
|
||||||
The host firewall, not the Gateway, is the access boundary.
|
|
||||||
|
|
||||||
## Repository layout
|
|
||||||
|
|
||||||
Flux watches `master` and runs six Kustomizations from these paths:
|
|
||||||
|
|
||||||
| Path | Kustomization | Contents |
|
|
||||||
|------|---------------|----------|
|
|
||||||
| `clusters/homek8s` | `flux-system` | Bootstrap and the top-level Kustomization list |
|
|
||||||
| `infrastructure/home` | `infrastructure` | Storage, Cilium, internal gateways, node tuning |
|
|
||||||
| `infrastructure/networking/gateway-api` | `gateway-api-crds` | Gateway API CRDs |
|
|
||||||
| `infrastructure/databases/base` | `databases` | CloudNativePG operator, vendored and patched |
|
|
||||||
| `apps/home` | `apps` | The workloads this cluster runs |
|
|
||||||
| `monitoring/controllers/home` | `monitoring` | Prometheus, Grafana, dashboards, alert rules |
|
|
||||||
|
|
||||||
A new app is a directory under `apps/base/<app>/` holding its namespace, workload,
|
|
||||||
Service and HTTPRoute, plus one line in `apps/home/kustomization.yaml`. Push to
|
|
||||||
`master` and Flux applies it.
|
|
||||||
|
|
||||||
## Reference
|
|
||||||
|
|
||||||
[`docs/cluster-overview.md`](docs/cluster-overview.md) is the longer operator
|
|
||||||
write-up. It is a snapshot and will drift; where it disagrees with `kubectl`,
|
|
||||||
`kubectl` wins.
|
|
||||||
|
|
||||||
## Audit
|
|
||||||
|
|
||||||
Read live on 2026-10-29 01:21 America/New_York, at commit
|
|
||||||
`aa0f67fe33394bd565b1f07813ed4355fa926934` on `master`.
|
|
||||||
|
|
||||||
Commands behind the tables above:
|
|
||||||
|
|
||||||
```
|
|
||||||
kubectl get nodes -o wide
|
|
||||||
kubectl version -o json
|
|
||||||
kubectl -n flux-system get kustomizations
|
|
||||||
kubectl get hr -A
|
|
||||||
kubectl get httproute -A
|
|
||||||
kubectl get cluster -A
|
|
||||||
kubectl get deploy -A
|
|
||||||
kubectl get storageclass
|
|
||||||
curl -H 'Host: <hostname>' http://10.10.0.2:8080/ # 200 for all seven
|
|
||||||
curl http://10.10.0.2:8081/ # 302 → /login
|
|
||||||
curl http://10.10.0.2:8084/ # 200
|
|
||||||
```
|
```
|
||||||
|
|
||||||
If this file disagrees with `kubectl`, `kubectl` wins.
|
## Layout
|
||||||
|
|
||||||
|
```
|
||||||
|
homek8s/
|
||||||
|
├── apps/
|
||||||
|
│ ├── base/ # app definitions
|
||||||
|
│ └── home/ # overlay applied to this cluster
|
||||||
|
├── clusters/
|
||||||
|
│ └── home/ # Flux Kustomizations (bootstrap later)
|
||||||
|
│ ├── flux-system/ # flux bootstrap (after Forgejo)
|
||||||
|
│ ├── apps.yaml
|
||||||
|
│ ├── infrastructure.yaml
|
||||||
|
│ └── monitoring.yaml
|
||||||
|
├── infrastructure/
|
||||||
|
│ ├── home/ # kubectl apply -k target (no HelmRelease)
|
||||||
|
│ ├── networking/
|
||||||
|
│ │ ├── cilium/ # HelmRelease for Flux
|
||||||
|
│ │ └── gateway/ # Cilium Gateway API
|
||||||
|
│ ├── storage/ # local-path provisioner
|
||||||
|
│ ├── controllers/
|
||||||
|
│ └── databases/
|
||||||
|
└── monitoring/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Apply (now)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl apply -k infrastructure/home
|
||||||
|
```
|
||||||
|
|
||||||
|
That installs storage + the public Gateway. Cilium is already running; its HelmRelease is only for Flux.
|
||||||
|
|
||||||
|
## Flux (later)
|
||||||
|
|
||||||
|
When Forgejo is up:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
flux bootstrap git \
|
||||||
|
--url=ssh://git@forgejo.siriusdevops.com:222/sirius/homek8s.git \
|
||||||
|
--branch=master \
|
||||||
|
--path=clusters/home
|
||||||
|
```
|
||||||
|
|
||||||
|
`clusters/home/*.yaml` already point at `./apps/home`, `./infrastructure/home`, and `./monitoring/controllers/home`.
|
||||||
|
|
|
||||||
|
|
@ -1,423 +0,0 @@
|
||||||
# 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.
|
|
||||||
|
|
@ -1,171 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,108 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: customer1
|
|
||||||
labels:
|
|
||||||
app.kubernetes.io/part-of: customer1
|
|
||||||
sirius.dev/purpose: lab-replica-of-client-stack
|
|
||||||
|
|
@ -1,172 +0,0 @@
|
||||||
# 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)
|
|
||||||
|
|
@ -1,261 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,72 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,143 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,305 +0,0 @@
|
||||||
---
|
|
||||||
# Nightly backup of every piece of state on this cluster that is not
|
|
||||||
# rebuildable from git: Forgejo's data PVC, the CloudNativePG databases and the
|
|
||||||
# plain Postgres Deployment in `osint`.
|
|
||||||
#
|
|
||||||
# Why this lives in namespace `forgejo` (and not a `backup` namespace):
|
|
||||||
# the biggest artifact is the `forgejo-data` PVC, and a Kubernetes volume
|
|
||||||
# cannot be mounted from another namespace. The pod therefore runs beside the
|
|
||||||
# data it copies; the portal database is reached over the API (see RBAC).
|
|
||||||
#
|
|
||||||
# Design notes (see docs/cluster-overview.md §8.1):
|
|
||||||
# * Destination is the Linode VPS (`[email protected]:/root/cluster-backup`),
|
|
||||||
# reached over the WireGuard mesh — off the T480 AND off the Pi. The same
|
|
||||||
# host already carries `/root/garage-backup` from the Garage pass.
|
|
||||||
# * Forgejo data is a *link-dest snapshot mirror*: rsync only ships changed
|
|
||||||
# blocks but every night leaves a full, restorable hardlinked snapshot.
|
|
||||||
# Never staged on the T480's root fs (it runs close to DiskPressure) —
|
|
||||||
# data flows PVC -> rsync -> ssh, no local temp file.
|
|
||||||
# * Databases are `pg_dump -Fc` streams taken from inside the CNPG primary
|
|
||||||
# (local socket, `-U postgres`, no password in the manifest and no
|
|
||||||
# cross-namespace Secret copy) piped straight to the Linode.
|
|
||||||
# * Credential-free on the DB side is deliberate: nothing in git, nothing to
|
|
||||||
# rotate. The only secret is the backup SSH key (`cluster-backup-ssh`,
|
|
||||||
# created out of band, `from=`-restricted on the Linode).
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
---
|
|
||||||
# Dump source in this namespace: find the CNPG primary and run pg_dump in it.
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: Role
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
rules:
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods"]
|
|
||||||
verbs: ["get", "list"]
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods/exec"]
|
|
||||||
verbs: ["create"]
|
|
||||||
- apiGroups: ["postgresql.cnpg.io"]
|
|
||||||
resources: ["clusters"]
|
|
||||||
verbs: ["get"]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: RoleBinding
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: Role
|
|
||||||
name: cluster-backup
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup-scripts
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
data:
|
|
||||||
backup.sh: |
|
|
||||||
#!/bin/bash
|
|
||||||
# Nightly state backup: Forgejo data PVC + every CloudNativePG database.
|
|
||||||
#
|
|
||||||
# Layout on the Linode:
|
|
||||||
# /root/cluster-backup/forgejo-data/<UTC stamp>/ hardlinked snapshot
|
|
||||||
# /root/cluster-backup/forgejo-data/latest -> newest snapshot
|
|
||||||
# /root/cluster-backup/db/<ns>-<cluster>-<stamp>.dump pg_dump -Fc
|
|
||||||
# /root/cluster-backup/manifests/<stamp>.txt sizes + sha256
|
|
||||||
#
|
|
||||||
# Everything is streamed: no byte of this backup is staged on siriussec
|
|
||||||
# (the node runs close to DiskPressure and `local-path` lives on it).
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# alpine/k8s ships kubectl/bash but not rsync/ssh; install them per run
|
|
||||||
# (~2 s). Nothing else is needed: the DB dumps run inside the CNPG pod.
|
|
||||||
if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then
|
|
||||||
echo "== installing rsync + openssh-client"
|
|
||||||
apk add --no-cache rsync openssh-client >/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
|
||||||
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
|
||||||
CNPG_TARGETS=${CNPG_TARGETS:-"forgejo/pg sirius-growth/portal"}
|
|
||||||
# Plain (non-CNPG) Postgres Deployments: <namespace>/<deployment>. There is
|
|
||||||
# no Cluster CR to ask for a primary, and no superuser path from outside, so
|
|
||||||
# the dump runs inside the pod and reads its own POSTGRES_USER/POSTGRES_DB
|
|
||||||
# (local socket, trust auth) — no password in git or in this Job.
|
|
||||||
PG_TARGETS=${PG_TARGETS:-"osint/osint-db"}
|
|
||||||
DATA_SRC=${DATA_SRC:-/src}
|
|
||||||
DATA_KEEP=${DATA_KEEP:-7}
|
|
||||||
DB_KEEP=${DB_KEEP:-14}
|
|
||||||
MIN_FREE_GB=${MIN_FREE_GB:-8}
|
|
||||||
STAMP=${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)}
|
|
||||||
|
|
||||||
SSH_OPTS=(-i /keys/id_ed25519
|
|
||||||
-o UserKnownHostsFile=/keys/known_hosts
|
|
||||||
-o StrictHostKeyChecking=yes
|
|
||||||
-o BatchMode=yes
|
|
||||||
-o ConnectTimeout=20
|
|
||||||
-o ServerAliveInterval=30)
|
|
||||||
ssh_r() { ssh "${SSH_OPTS[@]}" "$BACKUP_HOST" "$@"; }
|
|
||||||
|
|
||||||
echo "== target: $BACKUP_HOST:$BACKUP_DIR stamp=$STAMP"
|
|
||||||
ssh_r "mkdir -p '$BACKUP_DIR/forgejo-data' '$BACKUP_DIR/db' '$BACKUP_DIR/manifests'"
|
|
||||||
avail_gb=$(ssh_r "df -Pk '$BACKUP_DIR' | awk 'NR==2{printf \"%d\", \$4/1048576}'")
|
|
||||||
avail_gb=${avail_gb:-0}
|
|
||||||
echo "== remote free space: ${avail_gb} GiB (minimum ${MIN_FREE_GB} GiB)"
|
|
||||||
if [ "$avail_gb" -lt "$MIN_FREE_GB" ]; then
|
|
||||||
echo "FAIL: not enough free space on $BACKUP_HOST"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# First run: --link-dest needs an existing directory to compare against.
|
|
||||||
ssh_r "cd '$BACKUP_DIR/forgejo-data' && [ -e latest ] || { mkdir -p .empty && ln -sfn .empty latest; }"
|
|
||||||
|
|
||||||
echo "== forgejo-data: /src -> forgejo-data/$STAMP (incremental, link-dest)"
|
|
||||||
# Forgejo keeps writing while this runs, so a repack/upload can vanish
|
|
||||||
# mid-copy: rsync reports that as exit 24. That is expected on a live
|
|
||||||
# instance; anything else (23 = partial transfer, 11/12 = protocol) is a
|
|
||||||
# real failure. The two transient upload spools are excluded for the same
|
|
||||||
# reason — they hold half-written packages, never restorable state.
|
|
||||||
rc=0
|
|
||||||
rsync -a --numeric-ids --delete --stats --link-dest=../latest \
|
|
||||||
--exclude=/gitea/data/tmp/ \
|
|
||||||
--exclude=/gitea/data/repo-archive/tmp/ \
|
|
||||||
-e "ssh ${SSH_OPTS[*]}" \
|
|
||||||
"$DATA_SRC/" "$BACKUP_HOST:$BACKUP_DIR/forgejo-data/$STAMP/" || rc=$?
|
|
||||||
case "$rc" in
|
|
||||||
0) ;;
|
|
||||||
24) echo "== rsync exit 24: files changed during the copy (expected on a live Forgejo)" ;;
|
|
||||||
*) echo "FAIL: rsync exit $rc"; exit "$rc" ;;
|
|
||||||
esac
|
|
||||||
ssh_r "cd '$BACKUP_DIR/forgejo-data' && ln -sfn '$STAMP' latest && du -sh '$STAMP'"
|
|
||||||
|
|
||||||
echo "== databases"
|
|
||||||
# A previous run killed mid-stream can leave a zero-byte `.part` behind.
|
|
||||||
ssh_r "find '$BACKUP_DIR/db' -name '*.part' -mmin +60 -delete 2>/dev/null || true"
|
|
||||||
for target in $CNPG_TARGETS; do
|
|
||||||
ns=${target%%/*}
|
|
||||||
cluster=${target##*/}
|
|
||||||
pod=$(kubectl -n "$ns" get cluster "$cluster" -o jsonpath='{.status.currentPrimary}')
|
|
||||||
db=$(kubectl -n "$ns" get cluster "$cluster" -o jsonpath='{.spec.bootstrap.initdb.database}')
|
|
||||||
if [ -z "$pod" ] || [ -z "$db" ]; then
|
|
||||||
echo "FAIL: $ns/$cluster has no currentPrimary/initdb database"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
out="$BACKUP_DIR/db/$ns-$cluster-$STAMP.dump"
|
|
||||||
echo "-- $ns/$cluster primary=$pod db=$db -> $out"
|
|
||||||
sha_file=$(mktemp)
|
|
||||||
kubectl -n "$ns" exec -c postgres "$pod" -- \
|
|
||||||
pg_dump -U postgres -d "$db" -Fc -Z6 \
|
|
||||||
| tee >(sha256sum | awk '{print $1}' > "$sha_file") \
|
|
||||||
| ssh_r "cat > '$out.part'"
|
|
||||||
local_sha=$(cat "$sha_file"); rm -f "$sha_file"
|
|
||||||
remote_sha=$(ssh_r "sha256sum '$out.part' | awk '{print \$1}'")
|
|
||||||
if [ -z "$local_sha" ] || [ "$local_sha" != "$remote_sha" ]; then
|
|
||||||
echo "FAIL: sha256 mismatch for $out (local=${local_sha:-none} remote=${remote_sha:-none})"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ssh_r "mv '$out.part' '$out'"
|
|
||||||
echo " sha256=$local_sha"
|
|
||||||
ssh_r "ls -l '$out'"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "== plain Postgres deployments"
|
|
||||||
for target in $PG_TARGETS; do
|
|
||||||
ns=${target%%/*}
|
|
||||||
deploy=${target##*/}
|
|
||||||
out="$BACKUP_DIR/db/$ns-$deploy-$STAMP.dump"
|
|
||||||
echo "-- $ns/$deploy -> $out"
|
|
||||||
sha_file=$(mktemp)
|
|
||||||
kubectl -n "$ns" exec "deploy/$deploy" -- \
|
|
||||||
sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc -Z6' \
|
|
||||||
| tee >(sha256sum | awk '{print $1}' > "$sha_file") \
|
|
||||||
| ssh_r "cat > '$out.part'"
|
|
||||||
local_sha=$(cat "$sha_file"); rm -f "$sha_file"
|
|
||||||
remote_sha=$(ssh_r "sha256sum '$out.part' | awk '{print \$1}'")
|
|
||||||
if [ -z "$local_sha" ] || [ "$local_sha" != "$remote_sha" ]; then
|
|
||||||
echo "FAIL: sha256 mismatch for $out (local=${local_sha:-none} remote=${remote_sha:-none})"
|
|
||||||
ssh_r "rm -f '$out.part'"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ssh_r "mv '$out.part' '$out'"
|
|
||||||
echo " sha256=$local_sha"
|
|
||||||
ssh_r "ls -l '$out'"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "== manifest"
|
|
||||||
ssh_r "cd '$BACKUP_DIR' && { echo \"stamp $STAMP\"; echo \"host \$(hostname -s)\"; \
|
|
||||||
echo '--- forgejo-data/latest'; du -shL forgejo-data/latest; \
|
|
||||||
echo '--- db'; sha256sum db/*-$STAMP.dump; \
|
|
||||||
echo '--- db listing'; ls -l db; } > manifests/$STAMP.txt && cat manifests/$STAMP.txt"
|
|
||||||
|
|
||||||
echo "== retention: last $DATA_KEEP data snapshots, last $DB_KEEP dump files"
|
|
||||||
ssh_r "cd '$BACKUP_DIR/forgejo-data' && ls -1dt 20* 2>/dev/null | tail -n +$((DATA_KEEP + 1)) | xargs -r rm -rf"
|
|
||||||
ssh_r "cd '$BACKUP_DIR/db' && ls -1t *.dump 2>/dev/null | tail -n +$((DB_KEEP + 1)) | xargs -r rm -f"
|
|
||||||
ssh_r "cd '$BACKUP_DIR/manifests' && ls -1t *.txt 2>/dev/null | tail -n +$((DB_KEEP + 1)) | xargs -r rm -f"
|
|
||||||
ssh_r "df -h '$BACKUP_DIR' | tail -1"
|
|
||||||
|
|
||||||
echo "RESULT=success stamp=$STAMP"
|
|
||||||
---
|
|
||||||
apiVersion: batch/v1
|
|
||||||
kind: CronJob
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
spec:
|
|
||||||
# UTC everywhere, same convention as every other CronJob in this repo.
|
|
||||||
schedule: "37 2 * * *"
|
|
||||||
timeZone: "Etc/UTC"
|
|
||||||
concurrencyPolicy: Forbid
|
|
||||||
# Missed by more than 30 min (cluster down / node rebooting): skip the night
|
|
||||||
# instead of starting a mirror at a random time.
|
|
||||||
startingDeadlineSeconds: 1800
|
|
||||||
successfulJobsHistoryLimit: 3
|
|
||||||
failedJobsHistoryLimit: 3
|
|
||||||
jobTemplate:
|
|
||||||
spec:
|
|
||||||
# First full mirror of an 18 GiB PVC measured ~15 MB/s over WireGuard
|
|
||||||
# (~20 min); two hours leaves room for a slow night without being killed
|
|
||||||
# half-way through a snapshot.
|
|
||||||
activeDeadlineSeconds: 7200
|
|
||||||
backoffLimit: 1
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
spec:
|
|
||||||
restartPolicy: Never
|
|
||||||
serviceAccountName: cluster-backup
|
|
||||||
# The forgejo-data PVC is local-path on siriussec; the pod must run
|
|
||||||
# where the volume is.
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
containers:
|
|
||||||
- name: backup
|
|
||||||
# alpine/k8s carries kubectl 1.36.4 (== cluster version) so the
|
|
||||||
# CNPG dumps can be taken through the exec API; rsync + openssh
|
|
||||||
# are added at start (the pod has normal egress).
|
|
||||||
image: alpine/k8s:1.36.4
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command: ["/bin/bash", "/scripts/backup.sh"]
|
|
||||||
env:
|
|
||||||
- name: BACKUP_HOST
|
|
||||||
value: [email protected]
|
|
||||||
- name: BACKUP_DIR
|
|
||||||
value: /root/cluster-backup
|
|
||||||
- name: CNPG_TARGETS
|
|
||||||
value: "forgejo/pg sirius-growth/portal"
|
|
||||||
- name: PG_TARGETS
|
|
||||||
value: "osint/osint-db"
|
|
||||||
- name: DATA_KEEP
|
|
||||||
value: "7"
|
|
||||||
- name: DB_KEEP
|
|
||||||
value: "14"
|
|
||||||
volumeMounts:
|
|
||||||
- name: forgejo-data
|
|
||||||
mountPath: /src
|
|
||||||
readOnly: true
|
|
||||||
- name: keys
|
|
||||||
mountPath: /keys
|
|
||||||
readOnly: true
|
|
||||||
- name: scripts
|
|
||||||
mountPath: /scripts
|
|
||||||
readOnly: true
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 128Mi
|
|
||||||
limits:
|
|
||||||
# Streaming only — this is a hard cap so a regression can
|
|
||||||
# never stage the 18 GiB PVC on the T480's root filesystem.
|
|
||||||
ephemeral-storage: 1Gi
|
|
||||||
memory: 512Mi
|
|
||||||
volumes:
|
|
||||||
- name: forgejo-data
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: forgejo-data
|
|
||||||
readOnly: true
|
|
||||||
- name: keys
|
|
||||||
secret:
|
|
||||||
secretName: cluster-backup-ssh
|
|
||||||
defaultMode: 0400
|
|
||||||
- name: scripts
|
|
||||||
configMap:
|
|
||||||
name: cluster-backup-scripts
|
|
||||||
defaultMode: 0755
|
|
||||||
|
|
@ -24,19 +24,3 @@ spec:
|
||||||
memory: 256Mi
|
memory: 256Mi
|
||||||
limits:
|
limits:
|
||||||
memory: 1Gi
|
memory: 1Gi
|
||||||
# Metrics on :9187 (CNPG's instance manager), scraped by the PodMonitor in
|
|
||||||
# podmonitor.yaml. `enablePodMonitor` stays false: the operator-generated
|
|
||||||
# PodMonitor cannot carry the `release: kube-prometheus-stack` label that this
|
|
||||||
# Prometheus needs, and upstream deprecated the flag in CNPG 1.27.
|
|
||||||
#
|
|
||||||
# `customQueriesConfigMap` points at the operator's own default query set plus
|
|
||||||
# pg-actions-queries.yaml — the Forgejo Actions queue/outcome metrics that only
|
|
||||||
# this database can answer.
|
|
||||||
monitoring:
|
|
||||||
enablePodMonitor: false
|
|
||||||
disableDefaultQueries: false
|
|
||||||
customQueriesConfigMap:
|
|
||||||
- name: cnpg-default-monitoring
|
|
||||||
key: queries
|
|
||||||
- name: forgejo-actions-queries
|
|
||||||
key: queries
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
# 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,17 +55,9 @@ 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: /
|
||||||
|
|
@ -82,6 +74,3 @@ spec:
|
||||||
- name: data
|
- name: data
|
||||||
persistentVolumeClaim:
|
persistentVolumeClaim:
|
||||||
claimName: forgejo-data
|
claimName: forgejo-data
|
||||||
- name: custom-public
|
|
||||||
configMap:
|
|
||||||
name: forgejo-custom-public
|
|
||||||
|
|
|
||||||
|
|
@ -5,21 +5,10 @@ resources:
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
- pvc.yaml
|
- pvc.yaml
|
||||||
- cluster.yaml
|
- cluster.yaml
|
||||||
- podmonitor.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
|
||||||
# Static PVs/PVCs pinned to rpi: dynamic local-path cannot provision there
|
|
||||||
# (its helper pod is hardcoded to siriussec). Must sort before the runner
|
|
||||||
# Deployments that consume the claims.
|
|
||||||
- runner-dind-storage.yaml
|
|
||||||
- runner-arm64.yaml
|
- runner-arm64.yaml
|
||||||
- runner-amd64.yaml
|
- runner-amd64.yaml
|
||||||
- runner-deploy-arm64.yaml
|
- runner-deploy-arm64.yaml
|
||||||
- prune-cronjob.yaml
|
- prune-cronjob.yaml
|
||||||
# Nightly disaster-recovery backup of forgejo-data + every CNPG database to
|
|
||||||
# the Linode VPS. Lives here because a PVC cannot be mounted cross-namespace.
|
|
||||||
- cluster-backup.yaml
|
|
||||||
|
|
|
||||||
|
|
@ -1,111 +0,0 @@
|
||||||
# Custom CNPG monitoring queries for Forgejo's Actions tables.
|
|
||||||
#
|
|
||||||
# Why this ConfigMap exists: Forgejo's Actions queue lives in PostgreSQL, not in
|
|
||||||
# any exporter. `action_run_job` is the only place that knows how many jobs are
|
|
||||||
# waiting for a runner and how the last N runs ended, so the runner dashboard
|
|
||||||
# reads it through CNPG's built-in metrics exporter (`:9187`) instead of
|
|
||||||
# inventing a new exporter.
|
|
||||||
#
|
|
||||||
# How it is wired: `Cluster/pg` lists this ConfigMap under
|
|
||||||
# `spec.monitoring.customQueriesConfigMap` (alongside the operator's own
|
|
||||||
# `cnpg-default-monitoring`), so every query here runs on the cluster's *main*
|
|
||||||
# database — `forgejo` for this cluster, per CNPG's initdb.database rule — and is
|
|
||||||
# exported as `cnpg_<name>_<column>` on the instance's metrics port.
|
|
||||||
#
|
|
||||||
# Privileges: CNPG runs custom queries as the `cnpg_metrics_exporter` role
|
|
||||||
# (pg_monitor, NOT superuser). That role cannot read Forgejo's tables until it
|
|
||||||
# is granted, and the grant is a database-side step that cannot live in this
|
|
||||||
# file. When the dashboard shows an empty queue metric, run:
|
|
||||||
#
|
|
||||||
# GRANT USAGE ON SCHEMA public TO cnpg_metrics_exporter;
|
|
||||||
# GRANT SELECT ON action_run_job, action_task,
|
|
||||||
# action_runner TO cnpg_metrics_exporter;
|
|
||||||
#
|
|
||||||
# (see docs/monitoring-dashboards.md for the exact kubectl one-liner).
|
|
||||||
#
|
|
||||||
# Semantics, verified against this instance rather than guessed (task t_c45b2d73):
|
|
||||||
# action_run_job.status / action_run.status: 1 = success, 2 = failure,
|
|
||||||
# 3 = cancelled, 4 = skipped. Cross-checked against
|
|
||||||
# GET /api/v1/repos/sirius/onionwire/actions/runs, where DB run 1189
|
|
||||||
# (status 1) reports conclusion "success" and run 1191 (status 2) "failure".
|
|
||||||
# A job that has not started yet carries started = 0; a job that has not
|
|
||||||
# finished carries stopped = 0. Rows for skipped jobs never start, never stop
|
|
||||||
# and are kept forever, so queue depth deliberately excludes status 4 —
|
|
||||||
# otherwise the queue would read "3" at all times with nothing queued.
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: forgejo-actions-queries
|
|
||||||
namespace: forgejo
|
|
||||||
data:
|
|
||||||
queries: |
|
|
||||||
# Queue depth: jobs handed to a runner that have not started, plus the age
|
|
||||||
# of the oldest of them. Always returns exactly one row, so the panel shows
|
|
||||||
# a hard 0 instead of "No data" when the queue is empty.
|
|
||||||
actions_queue:
|
|
||||||
query: |
|
|
||||||
SELECT count(*) AS depth
|
|
||||||
, COALESCE(max(EXTRACT(EPOCH FROM pg_catalog.now())::bigint - NULLIF(j.created, 0)), 0) AS oldest_pending_seconds
|
|
||||||
FROM action_run_job j
|
|
||||||
WHERE j.started = 0
|
|
||||||
AND j.stopped = 0
|
|
||||||
AND j.status <> 4
|
|
||||||
metrics:
|
|
||||||
- depth:
|
|
||||||
usage: "GAUGE"
|
|
||||||
description: "Jobs assigned to a runner that have not started yet"
|
|
||||||
- oldest_pending_seconds:
|
|
||||||
usage: "GAUGE"
|
|
||||||
description: "Age in seconds of the oldest not-yet-started job"
|
|
||||||
# Jobs currently executing (a runner picked them up and has not finished).
|
|
||||||
actions_running:
|
|
||||||
query: |
|
|
||||||
SELECT count(*) AS total
|
|
||||||
FROM action_run_job j
|
|
||||||
WHERE j.started > 0
|
|
||||||
AND j.stopped = 0
|
|
||||||
metrics:
|
|
||||||
- total:
|
|
||||||
usage: "GAUGE"
|
|
||||||
description: "Jobs currently running on a runner"
|
|
||||||
# Job outcomes inside a rolling window. A rolling count (not a counter):
|
|
||||||
# Forgejo prunes old rows, so rate() over a row count would lie; asking for
|
|
||||||
# "stopped within the last hour/day" is always right.
|
|
||||||
actions_jobs_window:
|
|
||||||
query: |
|
|
||||||
SELECT w.label AS window
|
|
||||||
, s.status AS status
|
|
||||||
, COALESCE((
|
|
||||||
SELECT count(*)
|
|
||||||
FROM action_run_job j
|
|
||||||
WHERE j.status = s.status
|
|
||||||
AND j.stopped > (EXTRACT(EPOCH FROM pg_catalog.now())::bigint - w.secs)
|
|
||||||
), 0) AS total
|
|
||||||
FROM (VALUES ('1h', 3600), ('24h', 86400)) AS w(label, secs)
|
|
||||||
CROSS JOIN (VALUES (0), (1), (2), (3), (4)) AS s(status)
|
|
||||||
metrics:
|
|
||||||
- window:
|
|
||||||
usage: "LABEL"
|
|
||||||
description: "Rolling window: 1h or 24h"
|
|
||||||
- status:
|
|
||||||
usage: "LABEL"
|
|
||||||
description: "1 success, 2 failure, 3 cancelled, 4 skipped"
|
|
||||||
- total:
|
|
||||||
usage: "GAUGE"
|
|
||||||
description: "Jobs that finished inside the window with this status"
|
|
||||||
# How long ago each runner last polled Forgejo. This is the only signal that
|
|
||||||
# says "the runner process is alive" independently of the pod being Ready —
|
|
||||||
# a runner that cannot reach the forge stays Running but goes stale here.
|
|
||||||
actions_runners:
|
|
||||||
query: |
|
|
||||||
SELECT r.name AS runner
|
|
||||||
, COALESCE(EXTRACT(EPOCH FROM pg_catalog.now())::bigint - NULLIF(r.last_online, 0), -1) AS last_online_seconds
|
|
||||||
FROM action_runner r
|
|
||||||
metrics:
|
|
||||||
- runner:
|
|
||||||
usage: "LABEL"
|
|
||||||
description: "Runner name as registered with Forgejo"
|
|
||||||
- last_online_seconds:
|
|
||||||
usage: "GAUGE"
|
|
||||||
description: "Seconds since the runner last polled (-1 = never)"
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
# Prometheus scrape config for the Forgejo Postgres cluster (CNPG).
|
|
||||||
#
|
|
||||||
# Hand-written on purpose. CNPG's `spec.monitoring.enablePodMonitor: true` still
|
|
||||||
# works on operator 1.30 but is deprecated upstream (CloudNativePG 1.27 release
|
|
||||||
# notes: "we strongly recommend you remove or set enablePodMonitor to false and
|
|
||||||
# manually create a PodMonitor"), because the operator-owned PodMonitor gives no
|
|
||||||
# control over labels — and labels are exactly what this stack needs:
|
|
||||||
# Prometheus here keeps the chart defaults
|
|
||||||
# (`podMonitorSelectorNilUsesHelmValues: true`), so it only honours PodMonitors
|
|
||||||
# carrying `release: kube-prometheus-stack`. The Cilium ServiceMonitors in
|
|
||||||
# kube-system land for the same reason. Owning the PodMonitor in git makes that
|
|
||||||
# selector contract explicit instead of depending on what the operator decides
|
|
||||||
# to stamp on the object.
|
|
||||||
#
|
|
||||||
# One PodMonitor per cluster, in the cluster's own namespace: the PodMonitor
|
|
||||||
# namespaceSelector is empty on the Prometheus CRD, so any namespace is honoured.
|
|
||||||
apiVersion: monitoring.coreos.com/v1
|
|
||||||
kind: PodMonitor
|
|
||||||
metadata:
|
|
||||||
name: cnpg-pg
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
release: kube-prometheus-stack
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
cnpg.io/cluster: pg
|
|
||||||
podMetricsEndpoints:
|
|
||||||
- port: metrics
|
|
||||||
interval: 30s
|
|
||||||
# The instance manager serves /metrics on 9187 for the primary; replicas
|
|
||||||
# serve it too, so a future `instances: 2` needs no change here.
|
|
||||||
|
|
@ -1,264 +1,14 @@
|
||||||
---
|
---
|
||||||
# Disk hygiene for every Docker daemon the Forgejo Actions runners build on.
|
# Disk hygiene for the Pi's build host.
|
||||||
#
|
#
|
||||||
# Two kinds of daemon exist in this lab and the old version of this job only
|
# Every push builds images on the Pi's own docker daemon (deploy-site's arm64
|
||||||
# ever saw the first one:
|
# image, onionwire's ci build containers) and nothing ever removed them: the
|
||||||
|
# single / volume sat at 76% (666G/917G) with weeks of exited job containers
|
||||||
|
# and superseded image layers. On one volume that is a slow-motion outage.
|
||||||
#
|
#
|
||||||
# 1. the Pi's *host* daemon (arm64 runners bind /var/run/docker.sock),
|
# Prune keeps a week of images (a rollback window), 48h of exited containers,
|
||||||
# reachable from a pod only through a hostPath socket, and
|
# and 72h of builder cache. It runs against the host socket, so it sees exactly
|
||||||
# 2. the in-pod `docker:dind` daemons (amd64 runner today, the arm64
|
# the containers the runners created.
|
||||||
# migration adds more) which live on their own PVC and are reachable
|
|
||||||
# only by exec'ing into the pod.
|
|
||||||
#
|
|
||||||
# So the Job runs two containers: `host-daemon` mounts the Pi socket,
|
|
||||||
# `dind-daemons` discovers dind pods by label and prunes each one over the
|
|
||||||
# Kubernetes exec API with a namespace-scoped ServiceAccount. No pod names are
|
|
||||||
# hardcoded; a new dind runner is picked up the first night it exists.
|
|
||||||
#
|
|
||||||
# The build-cache cap is enforced by *age windows*, not by the capacity flags.
|
|
||||||
# `--keep-storage` / `--max-storage` / `--max-used-space` are accepted by the
|
|
||||||
# installed buildx (0.20.1) but do not reclaim anything here (measured
|
|
||||||
# 2026-10-27: 21.44 GB cache with `--max-used-space 20GB` -> "Total: 0B";
|
|
||||||
# 541 MB cache with `--max-used-space 100MB` -> "Total: 0B"). That no-op is
|
|
||||||
# why the previous job reported `Complete` while 21 GB of builder cache sat
|
|
||||||
# untouched. `--filter until=<age>` *does* reclaim (541 MB -> 0 with
|
|
||||||
# `until=1s`), so the script walks the window down from CACHE_AGE_H to 0s and
|
|
||||||
# stops as soon as the cache is under the cap: newest layers survive, a cold
|
|
||||||
# cache is the last resort, never the default.
|
|
||||||
#
|
|
||||||
# Named volumes are NEVER pruned (docker volume prune is forbidden): they hold
|
|
||||||
# the shared CI caches (onionwire-target-ci, the Android SDK/Gradle/registry
|
|
||||||
# volumes). Their sizes are printed every run and their growth is covered by
|
|
||||||
# the `RunnerDindDisk*` / `NodeFilesystemFillingUp` alerts (per-PVC bytes are
|
|
||||||
# not exported by kubelet 1.34+, so those alerts are node-filesystem scoped).
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ServiceAccount
|
|
||||||
metadata:
|
|
||||||
name: forgejo-prune
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
role: prune
|
|
||||||
---
|
|
||||||
# Least privilege: the job needs to find dind pods (get/list) and to run
|
|
||||||
# docker inside them (pods/exec create) — in namespace forgejo only.
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: Role
|
|
||||||
metadata:
|
|
||||||
name: forgejo-prune
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
role: prune
|
|
||||||
rules:
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods"]
|
|
||||||
verbs: ["get", "list"]
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods/exec"]
|
|
||||||
verbs: ["create"]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: RoleBinding
|
|
||||||
metadata:
|
|
||||||
name: forgejo-prune
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
role: prune
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: Role
|
|
||||||
name: forgejo-prune
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: forgejo-prune
|
|
||||||
namespace: forgejo
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: forgejo-prune-scripts
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
role: prune
|
|
||||||
data:
|
|
||||||
host-daemon.sh: |
|
|
||||||
#!/bin/sh
|
|
||||||
# Prune the Pi's host Docker daemon (the socket the arm64 runners use).
|
|
||||||
set -eu
|
|
||||||
|
|
||||||
CAP_BYTES=${CACHE_CAP_BYTES:-20000000000}
|
|
||||||
CACHE_AGE_H=${CACHE_AGE_H:-72}
|
|
||||||
IMAGE_AGE_H=${IMAGE_AGE_H:-168}
|
|
||||||
CONTAINER_AGE_H=${CONTAINER_AGE_H:-48}
|
|
||||||
BUSY_MINUTES=${BUSY_MINUTES:-180}
|
|
||||||
|
|
||||||
to_bytes() {
|
|
||||||
awk -v v="$1" 'BEGIN{
|
|
||||||
n = v + 0; u = "B";
|
|
||||||
if (match(v, /[A-Za-z]+$/)) u = substr(v, RSTART);
|
|
||||||
m = 1;
|
|
||||||
if (u == "kB") m = 1e3; else if (u == "MB") m = 1e6;
|
|
||||||
else if (u == "GB") m = 1e9; else if (u == "TB") m = 1e12;
|
|
||||||
printf "%.0f\n", n * m }'
|
|
||||||
}
|
|
||||||
|
|
||||||
cache_bytes() {
|
|
||||||
docker buildx du 2>/dev/null | awk '/^Total:/{print $2}' | tail -n1 \
|
|
||||||
| { read -r v; to_bytes "${v:-0B}"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
# A build is live if a *running* container was started inside the busy
|
|
||||||
# window. The Pi's standing containers (sites, garage, registry) are days
|
|
||||||
# old, so this needs no name whitelist: job containers are minutes old.
|
|
||||||
busy() {
|
|
||||||
docker ps --format '{{.Names}}|{{.Status}}' | awk -F'|' -v win="$1" '
|
|
||||||
{ st = $2; sub(/^Up /, "", st); split(st, a, " ");
|
|
||||||
if (st ~ /^Less than a second/) age = 0;
|
|
||||||
else if (st ~ /^About a minute/) age = 60;
|
|
||||||
else { n = a[1] + 0; u = a[2];
|
|
||||||
if (u ~ /^seconds?$/) age = n;
|
|
||||||
else if (u ~ /^minutes?$/) age = n * 60;
|
|
||||||
else if (u ~ /^hours?$/) age = n * 3600;
|
|
||||||
else if (u ~ /^days?$/) age = n * 86400;
|
|
||||||
else if (u ~ /^weeks?$/) age = n * 604800;
|
|
||||||
else age = 99999999 }
|
|
||||||
if (age < win * 60) { print " " $1 " (Up " st ")"; found = 1 } }
|
|
||||||
END { exit(found ? 0 : 1) }'
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "== daemon: pi-host (/var/run/docker.sock)"
|
|
||||||
docker system df
|
|
||||||
echo "== named volumes (never pruned, listed for growth tracking)"
|
|
||||||
docker system df -v | sed -n '/Local Volumes/,$p'
|
|
||||||
echo "== df -h / (before)"; df -h / | tail -n1
|
|
||||||
|
|
||||||
if busy "$BUSY_MINUTES"; then
|
|
||||||
echo "BUSY: a build looks live on this daemon (running container younger than ${BUSY_MINUTES}m above)"
|
|
||||||
echo "SKIP: not pruning pi-host tonight (job exits 0 by design)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "== container prune (exited > ${CONTAINER_AGE_H}h)"
|
|
||||||
docker container prune -f --filter until="${CONTAINER_AGE_H}h" 2>&1 | tail -n1
|
|
||||||
echo "== image prune (unused, created > ${IMAGE_AGE_H}h)"
|
|
||||||
docker image prune -af --filter until="${IMAGE_AGE_H}h" 2>&1 | tail -n1
|
|
||||||
|
|
||||||
echo "== builder prune (cap ${CAP_BYTES}B by age window)"
|
|
||||||
for w in "${CACHE_AGE_H}h" 48h 24h 12h 6h 3h 1h 0s; do
|
|
||||||
cur=$(cache_bytes)
|
|
||||||
echo "[builder] cache=${cur}B cap=${CAP_BYTES}B (next window until=$w)"
|
|
||||||
if [ "$cur" -le "$CAP_BYTES" ]; then
|
|
||||||
echo "[builder] within cap — warm cache kept"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "[builder] over cap -> docker builder prune -af --filter until=$w"
|
|
||||||
docker builder prune -af --filter until="$w" 2>&1 | tail -n1
|
|
||||||
done
|
|
||||||
echo "[builder] final cache=$(cache_bytes)B"
|
|
||||||
|
|
||||||
echo "== after"
|
|
||||||
docker system df
|
|
||||||
echo "== df -h / (after)"; df -h / | tail -n1
|
|
||||||
echo "daemon pi-host: OK"
|
|
||||||
dind-daemons.sh: |
|
|
||||||
#!/bin/sh
|
|
||||||
# Prune every in-cluster dind daemon, discovered by label.
|
|
||||||
# Selector: pods with app=forgejo-runner in namespace forgejo that have a
|
|
||||||
# container named `dind`. Nothing here is keyed to a pod name, so a new
|
|
||||||
# dind runner (e.g. the arm64 migration) is pruned the night it appears.
|
|
||||||
set -u
|
|
||||||
|
|
||||||
NS=${NAMESPACE:-forgejo}
|
|
||||||
CAP_BYTES=${CACHE_CAP_BYTES:-4000000000}
|
|
||||||
CACHE_AGE_H=${CACHE_AGE_H:-72}
|
|
||||||
CONTAINER_AGE_H=${CONTAINER_AGE_H:-48}
|
|
||||||
|
|
||||||
to_bytes() {
|
|
||||||
awk -v v="$1" 'BEGIN{
|
|
||||||
n = v + 0; u = "B";
|
|
||||||
if (match(v, /[A-Za-z]+$/)) u = substr(v, RSTART);
|
|
||||||
m = 1;
|
|
||||||
if (u == "kB") m = 1e3; else if (u == "MB") m = 1e6;
|
|
||||||
else if (u == "GB") m = 1e9; else if (u == "TB") m = 1e12;
|
|
||||||
printf "%.0f\n", n * m }'
|
|
||||||
}
|
|
||||||
|
|
||||||
dk() { kubectl -n "$NS" exec -c dind "$pod" -- docker "$@"; }
|
|
||||||
|
|
||||||
dk_cache_bytes() {
|
|
||||||
dk buildx du 2>/dev/null | awk '/^Total:/{print $2}' | tail -n1 \
|
|
||||||
| { read -r v; to_bytes "${v:-0B}"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
found=0
|
|
||||||
failed=0
|
|
||||||
skipped=0
|
|
||||||
for pod in $(kubectl -n "$NS" get pods -l app=forgejo-runner \
|
|
||||||
-o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}'); do
|
|
||||||
phase=$(kubectl -n "$NS" get pod "$pod" -o jsonpath='{.status.phase}' 2>/dev/null || echo Unknown)
|
|
||||||
if [ "$phase" != "Running" ]; then
|
|
||||||
echo "skip pod/$pod: phase $phase"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
ctrs=$(kubectl -n "$NS" get pod "$pod" -o jsonpath='{.spec.containers[*].name}' 2>/dev/null || echo "")
|
|
||||||
case " $ctrs " in
|
|
||||||
*" dind "*) ;;
|
|
||||||
*) echo "skip pod/$pod: no dind container (containers: ${ctrs:-none})"; continue ;;
|
|
||||||
esac
|
|
||||||
found=$((found + 1))
|
|
||||||
echo "=============================================================="
|
|
||||||
echo "== daemon: dind in pod/$pod"
|
|
||||||
if ! dk system df; then
|
|
||||||
echo "FAILED: docker not answering in pod/$pod"
|
|
||||||
failed=$((failed + 1))
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
echo "== named volumes in pod/$pod (never pruned, listed for growth tracking)"
|
|
||||||
dk system df -v | sed -n '/Local Volumes/,$p'
|
|
||||||
|
|
||||||
running=$(dk ps -q | wc -l)
|
|
||||||
if [ "$running" -gt 0 ]; then
|
|
||||||
echo "BUSY: pod/$pod has $running running container(s) — a job is in flight"
|
|
||||||
echo "SKIP: not pruning dind in pod/$pod (job exits 0 by design)"
|
|
||||||
skipped=$((skipped + 1))
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
before=$(dk_cache_bytes)
|
|
||||||
echo "== container prune in pod/$pod (exited > ${CONTAINER_AGE_H}h)"
|
|
||||||
dk container prune -f --filter until="${CONTAINER_AGE_H}h" 2>&1 | tail -n1
|
|
||||||
# Dangling images only. An `until` filter on pulled images compares the
|
|
||||||
# image's *creation* date (the upstream build date), so it would delete
|
|
||||||
# node:20-bullseye / rust:*-bookworm every night and make every job cold.
|
|
||||||
echo "== dangling image prune in pod/$pod"
|
|
||||||
dk image prune -f 2>&1 | tail -n1
|
|
||||||
|
|
||||||
echo "== builder prune in pod/$pod (cap ${CAP_BYTES}B by age window)"
|
|
||||||
for w in "${CACHE_AGE_H}h" 48h 24h 12h 6h 3h 1h 0s; do
|
|
||||||
cur=$(dk_cache_bytes)
|
|
||||||
echo "[builder $pod] cache=${cur}B cap=${CAP_BYTES}B (next window until=$w)"
|
|
||||||
if [ "$cur" -le "$CAP_BYTES" ]; then
|
|
||||||
echo "[builder $pod] within cap — warm cache kept"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
echo "[builder $pod] over cap -> docker builder prune -af --filter until=$w"
|
|
||||||
dk builder prune -af --filter until="$w" 2>&1 | tail -n1
|
|
||||||
done
|
|
||||||
after=$(dk_cache_bytes)
|
|
||||||
echo "== after pod/$pod (build cache ${before}B -> ${after}B)"
|
|
||||||
dk system df
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "=============================================================="
|
|
||||||
echo "summary: dind daemons found=$found pruned=$((found - failed - skipped)) skipped=$skipped failed=$failed"
|
|
||||||
if [ "$found" -eq 0 ]; then
|
|
||||||
echo "WARNING: no dind pod matched label app=forgejo-runner in ns $NS"
|
|
||||||
fi
|
|
||||||
[ "$failed" -eq 0 ]
|
|
||||||
---
|
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: CronJob
|
kind: CronJob
|
||||||
metadata:
|
metadata:
|
||||||
|
|
@ -269,37 +19,17 @@ metadata:
|
||||||
role: prune
|
role: prune
|
||||||
spec:
|
spec:
|
||||||
schedule: "17 4 * * *"
|
schedule: "17 4 * * *"
|
||||||
# One timezone convention for every CronJob in this repo: UTC.
|
|
||||||
timeZone: "Etc/UTC"
|
timeZone: "Etc/UTC"
|
||||||
concurrencyPolicy: Forbid
|
concurrencyPolicy: Forbid
|
||||||
# Missed by more than 30 min (Pi down, cluster flapping): skip the night
|
|
||||||
# rather than start a prune at an unpredictable time.
|
|
||||||
startingDeadlineSeconds: 1800
|
|
||||||
successfulJobsHistoryLimit: 3
|
successfulJobsHistoryLimit: 3
|
||||||
failedJobsHistoryLimit: 3
|
failedJobsHistoryLimit: 3
|
||||||
jobTemplate:
|
jobTemplate:
|
||||||
spec:
|
spec:
|
||||||
# Container/image removal on the Pi runs at minutes-per-dozen under load
|
|
||||||
# (measured: 48 containers in ~10 min). One hour keeps a slow night from
|
|
||||||
# being killed half-way through a prune.
|
|
||||||
activeDeadlineSeconds: 3600
|
|
||||||
# A failed prune is worth one retry (transient API/exec hiccup), not a
|
|
||||||
# loop: a broken prune must show up as a failed Job (and alert) instead
|
|
||||||
# of retrying all night.
|
|
||||||
backoffLimit: 1
|
backoffLimit: 1
|
||||||
|
activeDeadlineSeconds: 1800
|
||||||
template:
|
template:
|
||||||
metadata:
|
|
||||||
# Deliberately NOT app=forgejo-runner: dind discovery selects that
|
|
||||||
# label, and this pod must never be considered a daemon (it only has
|
|
||||||
# a host-daemon and a dind-daemons container).
|
|
||||||
labels:
|
|
||||||
app: forgejo-prune
|
|
||||||
role: prune
|
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
serviceAccountName: forgejo-prune
|
|
||||||
# The Pi socket only exists on rpi; the dind daemons are reached over
|
|
||||||
# the API, so both containers ride along here.
|
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: rpi
|
kubernetes.io/hostname: rpi
|
||||||
tolerations:
|
tolerations:
|
||||||
|
|
@ -308,64 +38,30 @@ spec:
|
||||||
value: network
|
value: network
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
containers:
|
containers:
|
||||||
- name: host-daemon
|
- name: prune
|
||||||
image: docker:27-cli
|
image: docker:27-cli
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
command: ["/bin/sh", "/scripts/host-daemon.sh"]
|
command:
|
||||||
env:
|
- sh
|
||||||
- name: CACHE_CAP_BYTES
|
- -c
|
||||||
value: "20000000000"
|
- |
|
||||||
- name: CACHE_AGE_H
|
set -e
|
||||||
value: "72"
|
echo "== before"; docker system df
|
||||||
- name: IMAGE_AGE_H
|
docker container prune -f --filter until=48h || true
|
||||||
value: "168"
|
docker image prune -af --filter until=168h || true
|
||||||
- name: CONTAINER_AGE_H
|
docker builder prune -af --filter until=72h || true
|
||||||
value: "48"
|
echo "== after"; docker system df
|
||||||
- name: BUSY_MINUTES
|
|
||||||
value: "180"
|
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: docker-sock
|
- name: docker-sock
|
||||||
mountPath: /var/run/docker.sock
|
mountPath: /var/run/docker.sock
|
||||||
- name: scripts
|
|
||||||
mountPath: /scripts
|
|
||||||
readOnly: true
|
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 10m
|
cpu: 10m
|
||||||
memory: 32Mi
|
memory: 32Mi
|
||||||
limits:
|
limits:
|
||||||
memory: 256Mi
|
memory: 128Mi
|
||||||
- name: dind-daemons
|
|
||||||
# kubectl 1.36.4 == the cluster version; alpine/k8s ships kubectl,
|
|
||||||
# bash and awk on arm64, so it can exec into the dind pods.
|
|
||||||
image: alpine/k8s:1.36.4
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command: ["/bin/sh", "/scripts/dind-daemons.sh"]
|
|
||||||
env:
|
|
||||||
- name: NAMESPACE
|
|
||||||
value: forgejo
|
|
||||||
- name: CACHE_CAP_BYTES
|
|
||||||
value: "4000000000"
|
|
||||||
- name: CACHE_AGE_H
|
|
||||||
value: "72"
|
|
||||||
- name: CONTAINER_AGE_H
|
|
||||||
value: "48"
|
|
||||||
volumeMounts:
|
|
||||||
- name: scripts
|
|
||||||
mountPath: /scripts
|
|
||||||
readOnly: true
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 10m
|
|
||||||
memory: 32Mi
|
|
||||||
limits:
|
|
||||||
memory: 256Mi
|
|
||||||
volumes:
|
volumes:
|
||||||
- name: docker-sock
|
- name: docker-sock
|
||||||
hostPath:
|
hostPath:
|
||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
type: Socket
|
type: Socket
|
||||||
- name: scripts
|
|
||||||
configMap:
|
|
||||||
name: forgejo-prune-scripts
|
|
||||||
defaultMode: 0755
|
|
||||||
|
|
|
||||||
|
|
@ -76,23 +76,7 @@ spec:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
# A reboot restarts this container inside the same pod, so the
|
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 &
|
||||||
# dind-run emptyDir keeps the previous daemon's pid file. dockerd
|
|
||||||
# then refuses to start ("process with PID N is still running")
|
|
||||||
# and the runner crashloops until the pod is deleted by hand.
|
|
||||||
# Clear the stale runtime state first so a restart is
|
|
||||||
# self-healing.
|
|
||||||
rm -f /var/run/docker.pid /var/run/docker.sock
|
|
||||||
# Forgejo's container registry is reached in-cluster as a plain
|
|
||||||
# HTTP ClusterIP (forgejo.forgejo.svc.cluster.local:3000).
|
|
||||||
# Docker only treats 127.0.0.0/8 as insecure by default, so
|
|
||||||
# without this a workflow that logs in to or pushes to that host
|
|
||||||
# dies with "server gave HTTP response to HTTPS client".
|
|
||||||
# The public hostname stays HTTPS via Cloudflare, which 413s
|
|
||||||
# layer uploads >~100MB, so in-cluster pushes are the reliable
|
|
||||||
# path for large images.
|
|
||||||
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
|
||||||
--insecure-registry=forgejo.forgejo.svc.cluster.local:3000 &
|
|
||||||
pid=$!
|
pid=$!
|
||||||
i=0
|
i=0
|
||||||
while [ "$i" -lt 30 ]; do
|
while [ "$i" -lt 30 ]; do
|
||||||
|
|
@ -117,23 +101,10 @@ 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
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
# The image runs as uid 1000. The dind socket is created 660
|
|
||||||
# root:docker and the one-shot chmod 666 in the dind container can
|
|
||||||
# race a dockerd restart, after which the runner crashloops on
|
|
||||||
# "permission denied ... /var/run/docker.sock" (its wait loop only
|
|
||||||
# checks that the socket exists). Running the runner as root removes
|
|
||||||
# the dependency on that race; it is the uid the dind setup assumes.
|
|
||||||
securityContext:
|
|
||||||
runAsUser: 0
|
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ spec:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: forgejo-runner
|
app: forgejo-runner
|
||||||
arch: arm64
|
arch: arm64
|
||||||
# RWO PVC: never two pods on one data-root.
|
|
||||||
strategy:
|
strategy:
|
||||||
type: Recreate
|
type: Recreate
|
||||||
template:
|
template:
|
||||||
|
|
@ -28,112 +27,49 @@ spec:
|
||||||
operator: Equal
|
operator: Equal
|
||||||
value: network
|
value: network
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
# No supplementalGroups: there is no host docker socket and no host
|
securityContext:
|
||||||
# docker gid to match any more. The only daemon this runner talks to is
|
supplementalGroups: [984]
|
||||||
# the privileged `dind` sidecar below.
|
|
||||||
containers:
|
containers:
|
||||||
# In-pod Docker daemon. Same shape as forgejo-runner-amd64: privileged,
|
|
||||||
# socket on an emptyDir shared with the runner, data-root on the PVC.
|
|
||||||
# The container MUST be named `dind`, not `docker`/`dockerd`: the
|
|
||||||
# nightly prune (prune-cronjob.yaml) discovers daemons by
|
|
||||||
# `app=forgejo-runner` plus a container literally named `dind`, and
|
|
||||||
# silently prunes nothing for any other name while still reporting
|
|
||||||
# success.
|
|
||||||
- name: dind
|
|
||||||
image: docker:27-dind
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
# A reboot restarts this container inside the same pod, so the
|
|
||||||
# dind-run emptyDir keeps the previous daemon's pid file. dockerd
|
|
||||||
# then refuses to start ("process with PID N is still running")
|
|
||||||
# and the runner crashloops until the pod is deleted by hand.
|
|
||||||
# Clear the stale runtime state first so a restart is
|
|
||||||
# self-healing.
|
|
||||||
rm -f /var/run/docker.pid /var/run/docker.sock
|
|
||||||
# --insecure-registry: the Pi registry is plain HTTP on the WG
|
|
||||||
# hub IP. Docker only treats 127.0.0.0/8 as insecure by default,
|
|
||||||
# so without this `docker push 10.10.0.1:5000/...` from a job
|
|
||||||
# fails with "server gave HTTP response to HTTPS client".
|
|
||||||
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
|
||||||
--insecure-registry=10.10.0.1:5000 &
|
|
||||||
pid=$!
|
|
||||||
i=0
|
|
||||||
while [ "$i" -lt 30 ]; do
|
|
||||||
if [ -S /var/run/docker.sock ]; then
|
|
||||||
chmod 666 /var/run/docker.sock
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
wait "$pid"
|
|
||||||
securityContext:
|
|
||||||
privileged: true
|
|
||||||
volumeMounts:
|
|
||||||
- name: dind-run
|
|
||||||
mountPath: /var/run
|
|
||||||
- name: data
|
|
||||||
mountPath: /var/lib/docker
|
|
||||||
subPath: docker
|
|
||||||
resources:
|
|
||||||
# Measured peak RSS of a real ci.yml-shaped Rust job inside dind on
|
|
||||||
# this Pi: 3.10 GiB (docs/arm64-runner-dind.md §2.6). The previous
|
|
||||||
# 512Mi limit OOM-killed the daemon on the first build; 4Gi copies
|
|
||||||
# the amd64 runner, which runs the same load shape.
|
|
||||||
requests:
|
|
||||||
cpu: 200m
|
|
||||||
memory: 512Mi
|
|
||||||
limits:
|
|
||||||
memory: 4Gi
|
|
||||||
- name: runner
|
- name: runner
|
||||||
# code.forgejo.org/forgejo/runner is genuinely multi-arch and works on
|
# code.forgejo.org/forgejo/runner is genuinely multi-arch and works on
|
||||||
# both the amd64 (siriussec) and arm64 (rpi) runners. Do NOT swap this
|
# both the amd64 (siriussec) and arm64 (rpi) runners. Do NOT swap this
|
||||||
# for alex3305/forgejo-runner-dind:* on the arm64 runner: that image's
|
# for alex3305/forgejo-runner-dind:* on the arm64 runner: that image's
|
||||||
# arm64 manifest ships an x86-64 forgejo-runner binary, so the Pi dies
|
# arm64 manifest ships an x86-64 forgejo-runner binary, so the Pi dies
|
||||||
# with "exec format error" and the pi runner (the only runner declaring
|
# with "exec format error" and the pi-runner (the only runner declaring
|
||||||
# the bare `docker` label) goes offline, stalling every `runs-on: docker`
|
# the bare `docker` label) goes offline, stalling every `runs-on: docker`
|
||||||
# job in onionwire/siriusdevops-contact.
|
# job in onionwire/siriusdevops-contact.
|
||||||
image: code.forgejo.org/forgejo/runner:5.0.1
|
image: code.forgejo.org/forgejo/runner:5.0.1
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
# uid 1000 in this image vs a `660 root:docker` dind socket: the dind
|
|
||||||
# container's one-shot chmod 666 can race a dockerd restart and the
|
|
||||||
# runner's wait loop only checks that the socket exists, so it would
|
|
||||||
# crashloop on "permission denied". Running as root is what the amd64
|
|
||||||
# runner proved deterministic (2eff85b).
|
|
||||||
securityContext:
|
|
||||||
runAsUser: 0
|
|
||||||
command:
|
command:
|
||||||
- sh
|
- forgejo-runner
|
||||||
- -c
|
- --config
|
||||||
- |
|
- /config/config.toml
|
||||||
set -e
|
- daemon
|
||||||
i=0
|
|
||||||
while [ "$i" -lt 60 ]; do
|
|
||||||
if [ -S /var/run/docker.sock ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
exec forgejo-runner --config /config/config.toml daemon
|
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_HOST
|
- name: DOCKER_HOST
|
||||||
value: unix:///var/run/docker.sock
|
value: unix:///var/run/docker.sock
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
runAsUser: 0
|
||||||
|
runAsGroup: 0
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
- name: docker-sock
|
||||||
|
mountPath: /var/run/docker.sock
|
||||||
|
- name: docker-static
|
||||||
|
mountPath: /usr/bin/docker
|
||||||
|
readOnly: true
|
||||||
|
- name: cli-plugins
|
||||||
|
mountPath: /usr/local/lib/docker/cli-plugins
|
||||||
|
readOnly: true
|
||||||
- name: config-toml
|
- name: config-toml
|
||||||
mountPath: /config/config.toml
|
mountPath: /config/config.toml
|
||||||
subPath: arm64.toml
|
subPath: arm64.toml
|
||||||
# runner.ini + actions cache live on the same PVC as the dind
|
- name: runner-ini
|
||||||
# data-root (subPath docker), so one Retain PV holds the whole
|
mountPath: /config/runner.ini
|
||||||
# runner identity. Copied from the Pi host before first start —
|
- name: cache
|
||||||
# never registered here, the uuid must survive.
|
mountPath: /opt/siriusdevops/runner/cache
|
||||||
- name: data
|
- name: siriusdevops
|
||||||
mountPath: /data
|
mountPath: /opt/siriusdevops
|
||||||
- name: dind-run
|
|
||||||
mountPath: /var/run
|
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 50m
|
cpu: 50m
|
||||||
|
|
@ -141,11 +77,30 @@ spec:
|
||||||
limits:
|
limits:
|
||||||
memory: 512Mi
|
memory: 512Mi
|
||||||
volumes:
|
volumes:
|
||||||
|
- name: docker-sock
|
||||||
|
hostPath:
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
type: Socket
|
||||||
|
- name: docker-static
|
||||||
|
hostPath:
|
||||||
|
path: /usr/local/bin/docker-static
|
||||||
|
type: File
|
||||||
|
- name: cli-plugins
|
||||||
|
hostPath:
|
||||||
|
path: /opt/siriusdevops/runner/cli-plugins
|
||||||
|
type: DirectoryOrCreate
|
||||||
- name: config-toml
|
- name: config-toml
|
||||||
configMap:
|
configMap:
|
||||||
name: forgejo-runner-config
|
name: forgejo-runner-config
|
||||||
- name: data
|
- name: runner-ini
|
||||||
persistentVolumeClaim:
|
hostPath:
|
||||||
claimName: forgejo-runner-arm64-dind
|
path: /opt/siriusdevops/runner/config/runner.ini
|
||||||
- name: dind-run
|
type: File
|
||||||
emptyDir: {}
|
- name: cache
|
||||||
|
hostPath:
|
||||||
|
path: /opt/siriusdevops/runner/cache
|
||||||
|
type: DirectoryOrCreate
|
||||||
|
- name: siriusdevops
|
||||||
|
hostPath:
|
||||||
|
path: /opt/siriusdevops
|
||||||
|
type: Directory
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,7 @@ data:
|
||||||
log:
|
log:
|
||||||
level: info
|
level: info
|
||||||
runner:
|
runner:
|
||||||
# runner.ini lives on the runner's data PVC now (was a hostPath file), so
|
file: /config/runner.ini
|
||||||
# the registration survives the move to in-cluster dind with the same
|
|
||||||
# uuid. Nothing in the Deployment registers a runner.
|
|
||||||
file: /data/runner.ini
|
|
||||||
# capacity 1: ci.yml builds every job's Rust target into ONE shared named
|
# capacity 1: ci.yml builds every job's Rust target into ONE shared named
|
||||||
# volume (onionwire-target-ci, mounted at /target). Two jobs writing that
|
# volume (onionwire-target-ci, mounted at /target). Two jobs writing that
|
||||||
# volume concurrently clobber each other's freshly-linked test binaries,
|
# volume concurrently clobber each other's freshly-linked test binaries,
|
||||||
|
|
@ -21,25 +18,16 @@ data:
|
||||||
# runs of the same group on this runner (446 + 447 overlapped).
|
# runs of the same group on this runner (446 + 447 overlapped).
|
||||||
capacity: 1
|
capacity: 1
|
||||||
timeout: 1h
|
timeout: 1h
|
||||||
cache: /data/cache
|
cache: /opt/siriusdevops/runner/cache
|
||||||
cache:
|
cache:
|
||||||
enabled: true
|
enabled: true
|
||||||
dir: /data/cache
|
dir: /opt/siriusdevops/runner/cache
|
||||||
container:
|
container:
|
||||||
privileged: true
|
privileged: true
|
||||||
# No docker_host here: setting it makes the runner inject the socket bind
|
# No docker_host here: setting it makes the runner inject the host socket
|
||||||
# into the job container itself, which collides with the explicit
|
# bind into the job container itself, which collides with the explicit
|
||||||
# -v /var/run/docker.sock in options ("Duplicate mount point"). The
|
# -v /var/run/docker.sock in options ("Duplicate mount point").
|
||||||
# options bind is the deliberate choice — nested `docker create/start` in
|
options: -v /usr/local/bin/docker-static:/usr/bin/docker:ro -v /opt/siriusdevops/runner/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock --memory 3g --memory-swap 3g
|
||||||
# ci.yml, fuzz.yml and release.yml depends on it.
|
|
||||||
#
|
|
||||||
# The docker CLI/plugins come out of the `dind` sidecar's own filesystem
|
|
||||||
# (docker:27-dind ships /usr/local/bin/docker, docker-buildx,
|
|
||||||
# docker-compose), not the Pi host's docker-static. Paths resolve inside
|
|
||||||
# the dind container, which is what the daemon bind-mounts from. This
|
|
||||||
# keeps `docker buildx` working without installing a CLI in five
|
|
||||||
# workflows.
|
|
||||||
options: -v /usr/local/bin/docker:/usr/bin/docker:ro -v /usr/local/libexec/docker/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock --memory 3g --memory-swap 3g
|
|
||||||
valid_volumes:
|
valid_volumes:
|
||||||
- "**"
|
- "**"
|
||||||
# Dedicated runner for site deploys. It declares ONLY the `deploy-arm64`
|
# Dedicated runner for site deploys. It declares ONLY the `deploy-arm64`
|
||||||
|
|
@ -48,19 +36,13 @@ data:
|
||||||
# can never occupy the Pi's `docker` runner, whose capacity 1 exists to
|
# can never occupy the Pi's `docker` runner, whose capacity 1 exists to
|
||||||
# serialize onionwire jobs sharing the onionwire-target-ci volume.
|
# serialize onionwire jobs sharing the onionwire-target-ci volume.
|
||||||
#
|
#
|
||||||
# It runs on the Pi because deploy-site.yml needs Pi-local resources: the Pi
|
# It runs on the Pi because deploy-site.yml needs Pi-local resources:
|
||||||
# registry and Garage are now addressed over the WireGuard hub IP
|
# 127.0.0.1:5000 (registry), 127.0.0.1:3900 (Garage) via `--network host`,
|
||||||
# (10.10.0.1:5000, 10.10.0.1:3900) instead of loopback, because 127.0.0.1
|
# and the host docker socket to build the arm64 site image.
|
||||||
# inside a pod is the pod. Its own `dind` sidecar builds the arm64 site image;
|
|
||||||
# no host Docker is involved.
|
|
||||||
deploy-arm64.toml: |
|
deploy-arm64.toml: |
|
||||||
log:
|
log:
|
||||||
level: info
|
level: info
|
||||||
runner:
|
runner:
|
||||||
# Copied onto the data PVC from /opt/siriusdevops/runner-deploy/data on
|
|
||||||
# the Pi host before first start. The require-registration init container
|
|
||||||
# refuses to start without it (registering would burn the single-use
|
|
||||||
# token and create a second action_runner row).
|
|
||||||
file: /data/runner.ini
|
file: /data/runner.ini
|
||||||
capacity: 1
|
capacity: 1
|
||||||
timeout: 30m
|
timeout: 30m
|
||||||
|
|
@ -72,13 +54,11 @@ data:
|
||||||
privileged: true
|
privileged: true
|
||||||
# Same injection as arm64.toml: the job container is node:20-bullseye,
|
# Same injection as arm64.toml: the job container is node:20-bullseye,
|
||||||
# which has no docker CLI and no buildx, and deploy-site.yml needs both.
|
# which has no docker CLI and no buildx, and deploy-site.yml needs both.
|
||||||
# Both come from the dind sidecar's own filesystem. binfmt/QEMU is
|
# buildx is the host's cli-plugins binary and binfmt/QEMU is registered on
|
||||||
# registered kernel-globally on the Pi (the POC pod's
|
# the Pi host, so amd64 cross-builds work here exactly as on the arm64
|
||||||
# /proc/sys/fs/binfmt_misc was empty yet an amd64 build ran as x86_64),
|
# runner. --memory caps the job container only (sibling `docker run`
|
||||||
# so the `--platform linux/amd64` cross build works inside the pod.
|
# containers a workflow spawns are outside the runner's control).
|
||||||
# --memory caps the job container only (sibling `docker run` containers a
|
options: -v /usr/local/bin/docker-static:/usr/bin/docker:ro -v /opt/siriusdevops/runner/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock --memory 3g --memory-swap 3g
|
||||||
# workflow spawns are outside the runner's control).
|
|
||||||
options: -v /usr/local/bin/docker:/usr/bin/docker:ro -v /usr/local/libexec/docker/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock --memory 3g --memory-swap 3g
|
|
||||||
valid_volumes:
|
valid_volumes:
|
||||||
- "**"
|
- "**"
|
||||||
|
|
||||||
|
|
@ -99,18 +79,7 @@ data:
|
||||||
dir: /data/cache
|
dir: /data/cache
|
||||||
container:
|
container:
|
||||||
privileged: true
|
privileged: true
|
||||||
# No docker_host: it injects the socket bind into the job container,
|
docker_host: "unix:///var/run/docker.sock"
|
||||||
# which collides with the explicit -v /var/run/docker.sock in options
|
|
||||||
# ("Duplicate mount point"). The options bind is the deliberate choice.
|
|
||||||
#
|
|
||||||
# The job image is node:20-bullseye, which ships no docker CLI, so the
|
|
||||||
# socket alone is not enough — `docker login`/`build`/`push` die with
|
|
||||||
# "docker: command not found". The CLI and cli-plugins come from the
|
|
||||||
# dind sidecar's own filesystem (docker:27-dind ships /usr/local/bin/
|
|
||||||
# docker, docker-buildx, docker-compose), same as arm64.toml.
|
|
||||||
# No --memory cap: this runner also carries the existing amd64 release
|
|
||||||
# builds, which were already uncapped.
|
|
||||||
options: -v /usr/local/bin/docker:/usr/bin/docker:ro -v /usr/local/libexec/docker/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
force_pull: true
|
force_pull: true
|
||||||
valid_volumes:
|
valid_volumes:
|
||||||
- "**"
|
- "**"
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,6 @@
|
||||||
# cheap; the labels are disjoint in both directions, so neither class can
|
# cheap; the labels are disjoint in both directions, so neither class can
|
||||||
# starve the other. Keep capacity 1: a deploy must not overlap itself (the Pi
|
# starve the other. Keep capacity 1: a deploy must not overlap itself (the Pi
|
||||||
# registry tag :latest and the k8s restartedAt patch are last-writer-wins).
|
# registry tag :latest and the k8s restartedAt patch are last-writer-wins).
|
||||||
#
|
|
||||||
# Since the arm64 dind cutover this runner has its own in-pod daemon too, so a
|
|
||||||
# deploy no longer shares the Pi's host Docker with anything.
|
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
|
|
@ -46,111 +43,80 @@ spec:
|
||||||
operator: Equal
|
operator: Equal
|
||||||
value: network
|
value: network
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
|
securityContext:
|
||||||
|
supplementalGroups: [984]
|
||||||
initContainers:
|
initContainers:
|
||||||
# Registration guard, NOT a registration step. The runner's identity
|
# Self-registration, like the amd64 runner. runner.ini lives on the Pi
|
||||||
# (`runner.ini`, action_runner id 14 / uuid a41aad73-…) is copied onto
|
# host (/opt/siriusdevops/runner-deploy/data) so a pod restart reuses the
|
||||||
# the PVC from the Pi host before the first start. The previous version
|
# existing registration instead of burning a single-use runner token.
|
||||||
# of this init container registered a *new* runner whenever the file was
|
- name: register
|
||||||
# missing, which burns a single-use token and leaves a second
|
# Must be the multi-arch code.forgejo.org image: alex3305/
|
||||||
# action_runner row polling under a new uuid. Refuse instead: a missing
|
# forgejo-runner-dind ships an x86-64 binary in its arm64 manifest and
|
||||||
# file is an operator error, not something to paper over.
|
# dies with "exec format error" on the Pi.
|
||||||
- name: require-registration
|
|
||||||
image: code.forgejo.org/forgejo/runner:5.0.1
|
image: code.forgejo.org/forgejo/runner:5.0.1
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
|
# The hostPath /data dir is created root:root by kubelet, and the
|
||||||
|
# runner image's default user cannot write runner.ini into it.
|
||||||
securityContext:
|
securityContext:
|
||||||
runAsUser: 0
|
runAsUser: 0
|
||||||
|
runAsGroup: 0
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
set -e
|
set -e
|
||||||
if [ ! -s /data/runner.ini ]; then
|
if [ -s /data/runner.ini ]; then
|
||||||
echo "runner.ini missing on the data PVC — refusing to register a second uuid" >&2
|
echo already-registered
|
||||||
echo "restore it: ssh rpi sudo install -m600 -o root -g root /opt/siriusdevops/runner-deploy/data/runner.ini /opt/local-path-provisioner/forgejo-runner-deploy-arm64-dind/runner.ini" >&2
|
exit 0
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
echo "registration present: $(grep -o '\"uuid\": \"[^\"]*\"' /data/runner.ini)"
|
forgejo-runner register --no-interactive \
|
||||||
volumeMounts:
|
--instance https://forgejo.siriusdevops.com \
|
||||||
- name: data
|
--token "$RUNNER_TOKEN" \
|
||||||
mountPath: /data
|
--name pi-deploy-arm64 \
|
||||||
containers:
|
--labels 'deploy-arm64:docker://node:20-bullseye' \
|
||||||
- name: dind
|
--config /config/config.toml
|
||||||
image: docker:27-dind
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
# --insecure-registry: the Pi registry is plain HTTP on the WG
|
|
||||||
# hub IP. Docker only treats 127.0.0.0/8 as insecure by default,
|
|
||||||
# so without this `docker push 10.10.0.1:5000/...` from a job
|
|
||||||
# fails with "server gave HTTP response to HTTPS client".
|
|
||||||
dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 \
|
|
||||||
--insecure-registry=10.10.0.1:5000 &
|
|
||||||
pid=$!
|
|
||||||
i=0
|
|
||||||
while [ "$i" -lt 30 ]; do
|
|
||||||
if [ -S /var/run/docker.sock ]; then
|
|
||||||
chmod 666 /var/run/docker.sock
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
wait "$pid"
|
|
||||||
securityContext:
|
|
||||||
privileged: true
|
|
||||||
volumeMounts:
|
|
||||||
- name: dind-run
|
|
||||||
mountPath: /var/run
|
|
||||||
- name: data
|
|
||||||
mountPath: /var/lib/docker
|
|
||||||
subPath: docker
|
|
||||||
resources:
|
|
||||||
# Deliberately smaller than the shared runner's 4Gi. A deploy is two
|
|
||||||
# nginx-based site images (112-143 MB each) plus buildx's
|
|
||||||
# docker-container driver and one `--platform linux/amd64` cross
|
|
||||||
# build under qemu; nothing like the Rust ci.yml job that peaked at
|
|
||||||
# 3.10 GiB. The Pi has 7.0 GiB available and capacity 1 per runner
|
|
||||||
# bounds each runner but nothing bounds both: 4Gi + 2Gi limits leave
|
|
||||||
# ~1 GiB for kubelet/Cilium/cloudflared/host Docker even if a CI run
|
|
||||||
# and a deploy overlap, and an OOM here fails one deploy visibly.
|
|
||||||
# (A 4Gi deploy limit would let two runners claim every byte.)
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
memory: 2Gi
|
|
||||||
- name: runner
|
|
||||||
image: code.forgejo.org/forgejo/runner:5.0.1
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
securityContext:
|
|
||||||
runAsUser: 0
|
|
||||||
command:
|
|
||||||
- sh
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
set -e
|
|
||||||
i=0
|
|
||||||
while [ "$i" -lt 60 ]; do
|
|
||||||
if [ -S /var/run/docker.sock ]; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
i=$((i+1))
|
|
||||||
sleep 2
|
|
||||||
done
|
|
||||||
exec forgejo-runner --config /config/config.toml daemon
|
|
||||||
env:
|
env:
|
||||||
- name: DOCKER_HOST
|
- name: RUNNER_TOKEN
|
||||||
value: unix:///var/run/docker.sock
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: forgejo-runner-deploy-arm64-token
|
||||||
|
key: token
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: config-toml
|
- name: config-toml
|
||||||
mountPath: /config/config.toml
|
mountPath: /config/config.toml
|
||||||
subPath: deploy-arm64.toml
|
subPath: deploy-arm64.toml
|
||||||
- name: data
|
- name: data
|
||||||
mountPath: /data
|
mountPath: /data
|
||||||
- name: dind-run
|
containers:
|
||||||
mountPath: /var/run
|
- name: runner
|
||||||
|
image: code.forgejo.org/forgejo/runner:5.0.1
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
command:
|
||||||
|
- forgejo-runner
|
||||||
|
- --config
|
||||||
|
- /config/config.toml
|
||||||
|
- daemon
|
||||||
|
env:
|
||||||
|
- name: DOCKER_HOST
|
||||||
|
value: unix:///var/run/docker.sock
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
runAsUser: 0
|
||||||
|
runAsGroup: 0
|
||||||
|
volumeMounts:
|
||||||
|
- name: docker-sock
|
||||||
|
mountPath: /var/run/docker.sock
|
||||||
|
- name: docker-static
|
||||||
|
mountPath: /usr/bin/docker
|
||||||
|
readOnly: true
|
||||||
|
- name: cli-plugins
|
||||||
|
mountPath: /usr/local/lib/docker/cli-plugins
|
||||||
|
readOnly: true
|
||||||
|
- name: config-toml
|
||||||
|
mountPath: /config/config.toml
|
||||||
|
subPath: deploy-arm64.toml
|
||||||
|
- name: data
|
||||||
|
mountPath: /data
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 50m
|
cpu: 50m
|
||||||
|
|
@ -158,11 +124,22 @@ spec:
|
||||||
limits:
|
limits:
|
||||||
memory: 512Mi
|
memory: 512Mi
|
||||||
volumes:
|
volumes:
|
||||||
|
- name: docker-sock
|
||||||
|
hostPath:
|
||||||
|
path: /var/run/docker.sock
|
||||||
|
type: Socket
|
||||||
|
- name: docker-static
|
||||||
|
hostPath:
|
||||||
|
path: /usr/local/bin/docker-static
|
||||||
|
type: File
|
||||||
|
- name: cli-plugins
|
||||||
|
hostPath:
|
||||||
|
path: /opt/siriusdevops/runner/cli-plugins
|
||||||
|
type: DirectoryOrCreate
|
||||||
- name: config-toml
|
- name: config-toml
|
||||||
configMap:
|
configMap:
|
||||||
name: forgejo-runner-config
|
name: forgejo-runner-config
|
||||||
- name: data
|
- name: data
|
||||||
persistentVolumeClaim:
|
hostPath:
|
||||||
claimName: forgejo-runner-deploy-arm64-dind
|
path: /opt/siriusdevops/runner-deploy/data
|
||||||
- name: dind-run
|
type: DirectoryOrCreate
|
||||||
emptyDir: {}
|
|
||||||
|
|
|
||||||
|
|
@ -1,122 +0,0 @@
|
||||||
---
|
|
||||||
# Static storage for the arm64 runners' in-cluster dind daemons.
|
|
||||||
#
|
|
||||||
# Why static PVs and not the default `local-path` StorageClass: the
|
|
||||||
# provisioner's helper pod is hardcoded to siriussec
|
|
||||||
# (infrastructure/storage/local-path-storage.yaml, helper-pod nodeSelector) and
|
|
||||||
# for a local filesystem it never sets spec.nodeName, so a `local-path` PVC
|
|
||||||
# consumed by a pod on rpi stays Pending forever ("NodeAffinity failed").
|
|
||||||
# Measured 2026-10-27 in a throwaway namespace; see
|
|
||||||
# docs/arm64-runner-dind.md §6.1.
|
|
||||||
#
|
|
||||||
# `persistentVolumeReclaimPolicy: Retain` is deliberate: the runner's
|
|
||||||
# registration (`runner.ini`, uuid of the Forgejo action_runner row) lives in
|
|
||||||
# this directory. Deleting the PVC must never delete the identity — a re-
|
|
||||||
# registered runner burns a single-use token and leaves an orphaned
|
|
||||||
# action_runner row behind.
|
|
||||||
#
|
|
||||||
# Sizes come from measured steady state (docs/arm64-runner-dind.md §4):
|
|
||||||
# shared runner 146.5 GiB steady -> 200Gi request (named CI volumes)
|
|
||||||
# deploy runner ~0.3 GiB steady -> 40Gi request (image + buildx generations)
|
|
||||||
# 240 GiB of the Pi's 390 GiB free. A static PV does not enforce the request —
|
|
||||||
# the 70 % node-filesystem alert in monitoring/controllers/home/prune-alerts.yaml
|
|
||||||
# is the real cap.
|
|
||||||
apiVersion: storage.k8s.io/v1
|
|
||||||
kind: StorageClass
|
|
||||||
metadata:
|
|
||||||
name: local-static
|
|
||||||
# No provisioner: every PV with this class is hand-made, so a typo'd claim
|
|
||||||
# hangs in Pending instead of silently landing somewhere unexpected.
|
|
||||||
provisioner: kubernetes.io/no-provisioner
|
|
||||||
volumeBindingMode: WaitForFirstConsumer
|
|
||||||
reclaimPolicy: Retain
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolume
|
|
||||||
metadata:
|
|
||||||
name: forgejo-runner-arm64-dind
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
arch: arm64
|
|
||||||
spec:
|
|
||||||
capacity:
|
|
||||||
storage: 200Gi
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
persistentVolumeReclaimPolicy: Retain
|
|
||||||
storageClassName: local-static
|
|
||||||
volumeMode: Filesystem
|
|
||||||
hostPath:
|
|
||||||
# Same filesystem/tree the local-path provisioner uses, so df and the
|
|
||||||
# existing node-exporter alerting see it as ordinary node disk.
|
|
||||||
path: /opt/local-path-provisioner/forgejo-runner-arm64-dind
|
|
||||||
type: DirectoryOrCreate
|
|
||||||
nodeAffinity:
|
|
||||||
required:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- rpi
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: forgejo-runner-arm64-dind
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
arch: arm64
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: local-static
|
|
||||||
volumeName: forgejo-runner-arm64-dind
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 200Gi
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolume
|
|
||||||
metadata:
|
|
||||||
name: forgejo-runner-deploy-arm64-dind
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
role: deploy
|
|
||||||
spec:
|
|
||||||
capacity:
|
|
||||||
storage: 40Gi
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
persistentVolumeReclaimPolicy: Retain
|
|
||||||
storageClassName: local-static
|
|
||||||
volumeMode: Filesystem
|
|
||||||
hostPath:
|
|
||||||
path: /opt/local-path-provisioner/forgejo-runner-deploy-arm64-dind
|
|
||||||
type: DirectoryOrCreate
|
|
||||||
nodeAffinity:
|
|
||||||
required:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- rpi
|
|
||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: forgejo-runner-deploy-arm64-dind
|
|
||||||
namespace: forgejo
|
|
||||||
labels:
|
|
||||||
app: forgejo-runner
|
|
||||||
role: deploy
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: local-static
|
|
||||||
volumeName: forgejo-runner-deploy-arm64-dind
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 40Gi
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: metabase
|
|
||||||
labels:
|
|
||||||
app.kubernetes.io/part-of: metabase
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: metabase
|
|
||||||
namespace: metabase
|
|
||||||
spec:
|
|
||||||
type: ClusterIP
|
|
||||||
selector:
|
|
||||||
app: metabase
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 3000
|
|
||||||
targetPort: 3000
|
|
||||||
protocol: TCP
|
|
||||||
|
|
@ -1,179 +0,0 @@
|
||||||
# OSINT Dashboard stack (namespace `osint`)
|
|
||||||
|
|
||||||
Ported from the Pi docker-compose stack in `sirius/osint-dashboard` so the
|
|
||||||
dashboard is served from the cluster at **https://osint.siriusdevops.com**
|
|
||||||
instead of a host Docker container on the Pi.
|
|
||||||
|
|
||||||
## Workloads
|
|
||||||
|
|
||||||
| Deployment | Image | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `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-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-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-news-scraper` | `forgejo…/sirius/osint-news-scraper:amd64-58f71f5b4520` | Scrapy news scraper loop |
|
|
||||||
| `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
|
|
||||||
co-location + local-path PVs).
|
|
||||||
|
|
||||||
## Images
|
|
||||||
|
|
||||||
**CI builds the cluster images.** Since PR #63 in `sirius/osint-dashboard`,
|
|
||||||
`.forgejo/workflows/build.yml` runs on the `amd64` runner (`runs-on: amd64`),
|
|
||||||
tags `amd64-<sha12>`, and pushes straight into the in-cluster registry
|
|
||||||
(`forgejo.forgejo.svc.cluster.local:3000`, plain HTTP, whitelisted by
|
|
||||||
`--insecure-registry` on the runner's dind). Deploying is then just a pin
|
|
||||||
change here in `apps/base/osint/` — check the run's `## Pin in homek8s` summary
|
|
||||||
for the exact tags. Builds are **path-filtered**, so one image can be several
|
|
||||||
commits older than another: the app tag is normally master tip, the summarizer
|
|
||||||
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
|
|
||||||
# fallback only — the normal path is: let CI build, then pin the tag here
|
|
||||||
git -C ~/osint-dashboard fetch origin
|
|
||||||
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"
|
|
||||||
docker build -f Dockerfile -t 127.0.0.1:3000/sirius/osint-dashboard:$TAG .
|
|
||||||
docker build -f news/scraper/Dockerfile -t 127.0.0.1:3000/sirius/osint-news-scraper:$TAG news/scraper
|
|
||||||
docker build -f news/summerizer/Dockerfile -t 127.0.0.1:3000/sirius/osint-news-summarizer:$TAG news/summerizer
|
|
||||||
docker build -f pg-image/Dockerfile -t 127.0.0.1:3000/sirius/osint-dashboard-pg:$TAG-r2 .
|
|
||||||
```
|
|
||||||
|
|
||||||
`pg-image/Dockerfile` is the cluster copy of `Dockerfile.pg`. **It pins
|
|
||||||
`postgres:16.16-bookworm`**: the upstream file's bare `postgres:16` now resolves
|
|
||||||
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
|
|
||||||
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
|
|
||||||
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)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n osint create secret generic osint-db --from-literal=password='<strong>'
|
|
||||||
```
|
|
||||||
`osint-db/password` is used for `POSTGRES_PASSWORD` and every workload's
|
|
||||||
`DB_PASSWORD`. Regenerating it requires the Postgres role password to be changed
|
|
||||||
too (`ALTER ROLE osint PASSWORD …`), not just the Secret.
|
|
||||||
|
|
||||||
API keys (Nous Portal `NOUS_API_KEY`, FIRMS, AISStream, VesselAPI) are **not**
|
|
||||||
Kubernetes Secrets: they live in the dashboard's `api_keys` table and are set
|
|
||||||
from the Keys page in the UI (`GET/PUT /api/keys`). The summarizer reads
|
|
||||||
`NOUS_API_KEY` from the env first, then from that table. Since the auth change
|
|
||||||
the Keys page is **admin-only**, so set them while signed in (`/login`).
|
|
||||||
|
|
||||||
### Admin login (`osint-admin`)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# password -> pbkdf2 hash (from a checkout of sirius/osint-dashboard)
|
|
||||||
python app/auth.py hash '<password>'
|
|
||||||
python -c 'import secrets; print(secrets.token_urlsafe(48))' # session secret
|
|
||||||
|
|
||||||
kubectl -n osint create secret generic osint-admin \
|
|
||||||
--from-literal=ADMIN_USER=lance \
|
|
||||||
--from-literal=ADMIN_PASSWORD_HASH='pbkdf2_sha256$…' \
|
|
||||||
--from-literal=ADMIN_SESSION_SECRET='…'
|
|
||||||
kubectl -n osint rollout restart deploy/osint-app # env is fixed at container start
|
|
||||||
```
|
|
||||||
|
|
||||||
`ADMIN_USER=lance`; the current password lives in
|
|
||||||
`~/.hermes/secrets/osint_admin_password` (0600, Legion) — never in git. The
|
|
||||||
three refs in `app-deployment.yaml` are `optional: true` on purpose: a missing
|
|
||||||
Secret must not block startup, and the app then **fails closed** (admin routes
|
|
||||||
`403 {"detail":"admin auth not configured"}`) while the public HUD keeps
|
|
||||||
serving.
|
|
||||||
|
|
||||||
The session cookie is `HttpOnly` + `SameSite=Lax` + `Secure`. `Secure` comes from
|
|
||||||
`ADMIN_COOKIE_SECURE=1` (ConfigMap), **not** from header inference: the tunnel
|
|
||||||
origins at plain HTTP and Cilium Envoy rewrites `X-Forwarded-Proto` to `http`, so
|
|
||||||
`app/auth.py::_is_https()` never sees https (an explicit request header is
|
|
||||||
discarded too — verified). Leave the flag unset only if you ever serve this over
|
|
||||||
plain http locally; browsers will not send a `Secure` cookie there.
|
|
||||||
|
|
||||||
## News list hygiene
|
|
||||||
|
|
||||||
`/api/news` orders by `articles.timestamp DESC`, so anything dated in the future
|
|
||||||
pins the top of the feed indefinitely. Two guards (PR #52):
|
|
||||||
|
|
||||||
- the Scrapy pipeline drops items dated more than **2 h** ahead
|
|
||||||
(`FUTURE_TOLERANCE` in `newsScraper/pipelines.py`), counting them under the
|
|
||||||
`future_dated_dropped` stat and logging one INFO line per crawl;
|
|
||||||
- `GET /api/news` additionally excludes `timestamp > now()` (keeping
|
|
||||||
`timestamp IS NULL` rows), so rows already in the table can never resurface
|
|
||||||
early.
|
|
||||||
|
|
||||||
Items with an unparseable date are still kept — the guard only fires on a date
|
|
||||||
it can actually parse.
|
|
||||||
|
|
||||||
## Analyst model
|
|
||||||
|
|
||||||
`SUMMARY_MODEL=meituan/longcat-2.5:free` (free tier on the Nous Portal,
|
|
||||||
1M context, verified to honour `response_format: json_object`). It is set in
|
|
||||||
`configmap.yaml`; changing it in the UI (`PUT /api/settings`) only takes effect
|
|
||||||
when the env var is empty, because `resolve_model()` prefers the env.
|
|
||||||
|
|
||||||
## Analyst grading (PR #53 + #54)
|
|
||||||
|
|
||||||
The map call scores every article **0-100** against a rubric in the same request
|
|
||||||
(no extra round-trip): 90+ breaking geopolitical/military/disaster, 70-89
|
|
||||||
significant national/international, 40-69 notable regional, 10-39 routine/crime,
|
|
||||||
0-9 noise (sport, celebrity, market tape, **event-calendar listings**). Only
|
|
||||||
blocks scoring `>= SUMMARY_MIN_SCORE` (60) reach the reduce prompt, capped at
|
|
||||||
`SUMMARY_TOP_N` (12). If nothing clears the bar the fallback may only pick blocks
|
|
||||||
`>= SUMMARY_FALLBACK_MIN_SCORE` (40), and if none clear that the brief is the
|
|
||||||
honest `No significant developments in this window.` — `SUMMARY_FALLBACK_TOP=0`
|
|
||||||
disables the fallback entirely.
|
|
||||||
|
|
||||||
`get_recent_news()` uses a closed window `(now - window, now]`: future-dated rows
|
|
||||||
must never be re-graded every 15 minutes (they are dropped at ingest and hidden
|
|
||||||
in `/api/news` — see above).
|
|
||||||
|
|
||||||
Every graded article is persisted to `article_scores` (`score`, `category`,
|
|
||||||
`selected`, `model`, `summary_id`) for threshold tuning, e.g.
|
|
||||||
|
|
||||||
```sql
|
|
||||||
select width_bucket(score, 0, 100, 10) * 10 as bucket, count(*), avg(selected::int)
|
|
||||||
from article_scores group by 1 order by 1;
|
|
||||||
```
|
|
||||||
|
|
||||||
Before the threshold/cap, `dedupe_blocks()` collapses **syndicated wire copies**
|
|
||||||
(six Hearst stations carrying one AP story) onto the best-scoring representative,
|
|
||||||
comparing normalised titles — lowercase, source suffix (` - KCCI`, ` | CNN`)
|
|
||||||
stripped when the tail is short and digit-free — with word-set Jaccard /
|
|
||||||
sequence similarity `>= SUMMARY_DEDUPE_SIMILARITY` (0.85). Duplicates are still
|
|
||||||
graded and persisted, with `selected=false` and `duplicate_of` pointing at the
|
|
||||||
survivor. `SUMMARY_DEDUPE=0` disables the collapse.
|
|
||||||
|
|
||||||
## Ingress
|
|
||||||
|
|
||||||
Cloudflare tunnel `sirius home` already carries `osint.siriusdevops.com` →
|
|
||||||
`http://10.10.0.2:8080`. DNS is a proxied CNAME to
|
|
||||||
`6d0702eb-99cc-4062-b57d-e70e2f1a7895.cfargotunnel.com`. HTTPRoute rule order:
|
|
||||||
`/titiler` (prefix stripped) → `osint-titiler:8000`, then `/` → `osint-app:8000`
|
|
||||||
(WebSocket `/ws/live` included).
|
|
||||||
|
|
@ -1,107 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-app
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-app
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-app
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-app
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
initContainers:
|
|
||||||
# Wait for Postgres before alembic runs (the entrypoint migrates).
|
|
||||||
- name: wait-for-db
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-54897b49bc57
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command:
|
|
||||||
- python
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
import os, socket, sys, time
|
|
||||||
host, port = os.environ.get("DB_HOST", "osint-db"), int(os.environ.get("DB_PORT", "5432"))
|
|
||||||
deadline = time.time() + 300
|
|
||||||
while time.time() < deadline:
|
|
||||||
try:
|
|
||||||
with socket.create_connection((host, port), timeout=3):
|
|
||||||
print("postgres is reachable"); sys.exit(0)
|
|
||||||
except OSError:
|
|
||||||
time.sleep(3)
|
|
||||||
sys.exit("postgres did not become reachable in 300s")
|
|
||||||
containers:
|
|
||||||
- name: app
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-54897b49bc57
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
ports:
|
|
||||||
- containerPort: 8000
|
|
||||||
name: http
|
|
||||||
envFrom:
|
|
||||||
- configMapRef:
|
|
||||||
name: osint-env
|
|
||||||
env:
|
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
# Single-admin auth (app/auth.py). optional: true on purpose — a
|
|
||||||
# missing Secret must not block startup; the app then fails closed
|
|
||||||
# (admin routes 403 "admin auth not configured") while the public
|
|
||||||
# read-only HUD still serves.
|
|
||||||
- name: ADMIN_USER
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-admin
|
|
||||||
key: ADMIN_USER
|
|
||||||
optional: true
|
|
||||||
- name: ADMIN_PASSWORD_HASH
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-admin
|
|
||||||
key: ADMIN_PASSWORD_HASH
|
|
||||||
optional: true
|
|
||||||
- name: ADMIN_SESSION_SECRET
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-admin
|
|
||||||
key: ADMIN_SESSION_SECRET
|
|
||||||
optional: true
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /api/health
|
|
||||||
port: 8000
|
|
||||||
initialDelaySeconds: 10
|
|
||||||
periodSeconds: 15
|
|
||||||
failureThreshold: 6
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /api/health
|
|
||||||
port: 8000
|
|
||||||
initialDelaySeconds: 90
|
|
||||||
periodSeconds: 30
|
|
||||||
failureThreshold: 5
|
|
||||||
volumeMounts:
|
|
||||||
- name: snapshots
|
|
||||||
mountPath: /data/snapshots
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
memory: 1Gi
|
|
||||||
volumes:
|
|
||||||
- name: snapshots
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: osint-camera-snapshots
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: osint-app
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: osint-app
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8000
|
|
||||||
targetPort: 8000
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
---
|
|
||||||
# Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of the
|
|
||||||
# plain (non-CNPG) Postgres Deployment `osint/osint-db` through the exec API.
|
|
||||||
#
|
|
||||||
# `osint-db` is a stock `postgres` Deployment, so there is no Cluster object and
|
|
||||||
# no `status.currentPrimary` to look up; the dump is taken inside the pod over
|
|
||||||
# the local socket and uses the pod's own `POSTGRES_USER`/`POSTGRES_DB`, so no
|
|
||||||
# password is copied into `forgejo`, git or the Job.
|
|
||||||
#
|
|
||||||
# Least privilege: the ServiceAccount may run one command inside this
|
|
||||||
# namespace's pods — nothing else.
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: Role
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
rules:
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods"]
|
|
||||||
verbs: ["get", "list"]
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods/exec"]
|
|
||||||
verbs: ["create"]
|
|
||||||
# `kubectl exec deploy/osint-db` resolves the Deployment's ReplicaSet/pod, so
|
|
||||||
# it needs read access to the deployment itself.
|
|
||||||
- apiGroups: ["apps"]
|
|
||||||
resources: ["deployments"]
|
|
||||||
verbs: ["get"]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: RoleBinding
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: Role
|
|
||||||
name: cluster-backup
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-camera-service
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-camera-service
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-camera-service
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-camera-service
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
containers:
|
|
||||||
- name: camera-service
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-915f6cbe25be
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command: ["python", "app/run_camera_service.py"]
|
|
||||||
envFrom:
|
|
||||||
- configMapRef:
|
|
||||||
name: osint-env
|
|
||||||
env:
|
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
volumeMounts:
|
|
||||||
- name: snapshots
|
|
||||||
mountPath: /data/snapshots
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 128Mi
|
|
||||||
limits:
|
|
||||||
memory: 512Mi
|
|
||||||
volumes:
|
|
||||||
# Shared with osint-app (same node, RWO): the app serves cached snapshots.
|
|
||||||
- name: snapshots
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: osint-camera-snapshots
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: osint-camera-snapshots
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: local-path
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 3Gi
|
|
||||||
|
|
@ -1,96 +0,0 @@
|
||||||
# Shared, non-secret runtime configuration for every OSINT workload.
|
|
||||||
# Secrets (Postgres password, Nous API key, FIRMS/AIS keys) are NOT here:
|
|
||||||
# * Postgres password -> Secret `osint-db` (created out of band, never in git)
|
|
||||||
# * API keys -> dashboard Keys page, stored in the `api_keys` table
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: osint-env
|
|
||||||
namespace: osint
|
|
||||||
data:
|
|
||||||
DB_HOST: osint-db
|
|
||||||
DB_PORT: "5432"
|
|
||||||
DB_NAME: osint_data
|
|
||||||
DB_USER: osint
|
|
||||||
NATS_URL: nats://osint-nats:4222
|
|
||||||
|
|
||||||
# SAR tile proxy, exposed same-origin under /titiler by the HTTPRoute.
|
|
||||||
TITILER_INTERNAL_URL: http://osint-titiler:8000
|
|
||||||
TITILER_PUBLIC_BASE: /titiler
|
|
||||||
|
|
||||||
TZ: America/New_York
|
|
||||||
OSINT_USER_AGENT: "osint-dashboard/1.0 (self-hosted; [email protected])"
|
|
||||||
|
|
||||||
# ── ingester ────────────────────────────────────────────────────────────
|
|
||||||
INGEST_INTERVAL: "300"
|
|
||||||
INGEST_EARTHQUAKES: "1"
|
|
||||||
INGEST_FIRES: "1"
|
|
||||||
FIRMS_DATASETS: "VIIRS_NOAA20_NRT,VIIRS_NOAA21_NRT"
|
|
||||||
FIRMS_BBOX: "-180,-60,180,75"
|
|
||||||
FIRMS_INTERVAL: "900"
|
|
||||||
VESSELAPI_BBOX: "25.5,55.4,27.3,57.2"
|
|
||||||
VESSELAPI_INTERVAL: "17280"
|
|
||||||
VESSELAPI_MAX_CALLS_PER_DAY: "5"
|
|
||||||
AISSTREAM_IN_APP: "1"
|
|
||||||
AISSTREAM_IN_INGEST: "0"
|
|
||||||
VESSELAPI_IN_APP: "0"
|
|
||||||
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_SOURCE_URLS: ""
|
|
||||||
CAMERA_SCRAPE_INTERVAL: "3600"
|
|
||||||
CAMERA_REQUEST_DELAY: "2.0"
|
|
||||||
CAMERA_MAX_PER_SOURCE: "20000"
|
|
||||||
NOMINATIM_URL: https://nominatim.openstreetmap.org
|
|
||||||
NOMINATIM_MIN_INTERVAL: "1.1"
|
|
||||||
SNAPSHOT_CACHE_DIR: /data/snapshots
|
|
||||||
SNAPSHOT_TTL_SECONDS: "300"
|
|
||||||
|
|
||||||
# ── news scraper ────────────────────────────────────────────────────────
|
|
||||||
LOG_LEVEL: INFO
|
|
||||||
NEWS_SCRAPE_INTERVAL_S: "10"
|
|
||||||
NEWS_SCRAPE_RUN_ON_START: "1"
|
|
||||||
|
|
||||||
# ── auth (see README, Secret `osint-admin`) ──────────────────────────────
|
|
||||||
# The Cloudflare tunnel origins at the Cilium Gateway on plain HTTP and Envoy
|
|
||||||
# normalizes X-Forwarded-Proto to http, so app/auth.py's header inference can
|
|
||||||
# never see https here: this flag is what puts `Secure` on the session cookie.
|
|
||||||
ADMIN_COOKIE_SECURE: "1"
|
|
||||||
|
|
||||||
# ── news summarizer (analyst) — Nous Portal, free tier model ────────────
|
|
||||||
NOUS_BASE_URL: https://inference-api.nousresearch.com/v1
|
|
||||||
SUMMARY_MODEL: meituan/longcat-2.5:free
|
|
||||||
# 4, not the upstream default 50: the map phase runs with a hard 60 s httpx
|
|
||||||
# timeout (news/summerizer/nous_client.py, json_mode=False), and this free
|
|
||||||
# model needs ~30 s for 8 articles, so bigger batches time out and silently
|
|
||||||
# contribute nothing to the reduce phase.
|
|
||||||
BATCH_SIZE: "4"
|
|
||||||
# Map-phase grading (PR #53): the map call scores every article 0-100 against
|
|
||||||
# a rubric and only blocks >= SUMMARY_MIN_SCORE reach the brief. When nothing
|
|
||||||
# clears the bar the top SUMMARY_FALLBACK_TOP are used so the HUD is not blank
|
|
||||||
# (set 0 for a genuinely empty "no significant developments" brief).
|
|
||||||
SUMMARY_MIN_SCORE: "60"
|
|
||||||
SUMMARY_TOP_N: "12"
|
|
||||||
SUMMARY_FALLBACK_TOP: "3"
|
|
||||||
# Lowest score the fallback may pick when nothing clears SUMMARY_MIN_SCORE;
|
|
||||||
# below this the brief is the honest "no significant developments" one.
|
|
||||||
SUMMARY_FALLBACK_MIN_SCORE: "40"
|
|
||||||
# Syndication dedupe (PR #55): identical wire copy from sister stations is
|
|
||||||
# collapsed to one representative before the threshold/cap, so top_n buys
|
|
||||||
# distinct stories. SUMMARY_DEDUPE=0 disables it.
|
|
||||||
SUMMARY_DEDUPE: "1"
|
|
||||||
SUMMARY_DEDUPE_SIMILARITY: "0.85"
|
|
||||||
NEWS_SUMMARIZE_INTERVAL_S: "900"
|
|
||||||
NEWS_SUMMARIZE_RUN_ON_START: "1"
|
|
||||||
NEWS_RECAP_HOUR: "23"
|
|
||||||
NEWS_RECAP_MINUTE: "0"
|
|
||||||
INCLUDE_FUTURES: "0"
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
apiVersion: gateway.networking.k8s.io/v1
|
|
||||||
kind: HTTPRoute
|
|
||||||
metadata:
|
|
||||||
name: osint
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
parentRefs:
|
|
||||||
- name: public
|
|
||||||
namespace: gateway-system
|
|
||||||
hostnames:
|
|
||||||
- osint.siriusdevops.com
|
|
||||||
rules:
|
|
||||||
# Same-origin SAR tile proxy: /titiler/... -> titiler /... (prefix stripped,
|
|
||||||
# matching the old nginx vhost's `proxy_pass ...:8001/`).
|
|
||||||
- matches:
|
|
||||||
- path:
|
|
||||||
type: PathPrefix
|
|
||||||
value: /titiler
|
|
||||||
filters:
|
|
||||||
- type: URLRewrite
|
|
||||||
urlRewrite:
|
|
||||||
path:
|
|
||||||
type: ReplacePrefixMatch
|
|
||||||
replacePrefixMatch: /
|
|
||||||
backendRefs:
|
|
||||||
- name: osint-titiler
|
|
||||||
port: 8000
|
|
||||||
- matches:
|
|
||||||
- path:
|
|
||||||
type: PathPrefix
|
|
||||||
value: /
|
|
||||||
backendRefs:
|
|
||||||
- name: osint-app
|
|
||||||
port: 8000
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-ingester
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-ingester
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-ingester
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-ingester
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
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:
|
|
||||||
kubernetes.io/arch: amd64
|
|
||||||
containers:
|
|
||||||
- name: ingester
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-76035535bcb2
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command: ["python", "app/run_ingester.py"]
|
|
||||||
envFrom:
|
|
||||||
- configMapRef:
|
|
||||||
name: osint-env
|
|
||||||
env:
|
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
memory: 512Mi
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
resources:
|
|
||||||
- namespace.yaml
|
|
||||||
- configmap.yaml
|
|
||||||
- postgres-pvc.yaml
|
|
||||||
- postgres-pvc-linode.yaml
|
|
||||||
- postgres-deployment.yaml
|
|
||||||
- postgres-service.yaml
|
|
||||||
- nats-deployment.yaml
|
|
||||||
- nats-service.yaml
|
|
||||||
- app-deployment.yaml
|
|
||||||
- app-service.yaml
|
|
||||||
- ingester-deployment.yaml
|
|
||||||
- camera-pvc.yaml
|
|
||||||
- camera-deployment.yaml
|
|
||||||
- titiler-deployment.yaml
|
|
||||||
- titiler-service.yaml
|
|
||||||
- news-scraper-deployment.yaml
|
|
||||||
- news-summarizer-deployment.yaml
|
|
||||||
- httproute.yaml
|
|
||||||
# exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's plain
|
|
||||||
# Postgres Deployment (osint-db) — not a CNPG cluster, so it needs its own path.
|
|
||||||
- backup-exec-rbac.yaml
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: osint
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-nats
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-nats
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-nats
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-nats
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
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:
|
|
||||||
kubernetes.io/arch: amd64
|
|
||||||
containers:
|
|
||||||
- name: nats
|
|
||||||
image: forgejo.siriusdevops.com/sirius/nats:2.10
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
args: ["-js", "-m", "8222", "-sd", "/data"]
|
|
||||||
ports:
|
|
||||||
- containerPort: 4222
|
|
||||||
name: client
|
|
||||||
- containerPort: 8222
|
|
||||||
name: monitor
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /healthz
|
|
||||||
port: 8222
|
|
||||||
initialDelaySeconds: 5
|
|
||||||
periodSeconds: 10
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 64Mi
|
|
||||||
limits:
|
|
||||||
memory: 256Mi
|
|
||||||
volumes:
|
|
||||||
# JetStream is a transient bus here (compose had no volume either):
|
|
||||||
# events are written to Postgres by the consumer loop.
|
|
||||||
- name: data
|
|
||||||
emptyDir: {}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: osint-nats
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: osint-nats
|
|
||||||
ports:
|
|
||||||
- name: client
|
|
||||||
port: 4222
|
|
||||||
targetPort: 4222
|
|
||||||
- name: monitor
|
|
||||||
port: 8222
|
|
||||||
targetPort: 8222
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-news-scraper
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-news-scraper
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-news-scraper
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-news-scraper
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
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:
|
|
||||||
kubernetes.io/arch: amd64
|
|
||||||
containers:
|
|
||||||
- name: news-scraper
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-58f71f5b4520
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
# Image ENTRYPOINT is `scrapy`; the loop crawls, sleeps, crawls again.
|
|
||||||
command: ["python", "run_news_scraper.py"]
|
|
||||||
envFrom:
|
|
||||||
- configMapRef:
|
|
||||||
name: osint-env
|
|
||||||
env:
|
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
memory: 768Mi
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-news-summarizer
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-news-summarizer
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-news-summarizer
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-news-summarizer
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
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:
|
|
||||||
kubernetes.io/arch: amd64
|
|
||||||
containers:
|
|
||||||
- name: news-summarizer
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-fe2b5df369d0
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
# Loop: batch the last window, call Nous Portal, write summaries.
|
|
||||||
command: ["python", "run_news_summarizer.py"]
|
|
||||||
envFrom:
|
|
||||||
- configMapRef:
|
|
||||||
name: osint-env
|
|
||||||
env:
|
|
||||||
- name: DB_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 128Mi
|
|
||||||
limits:
|
|
||||||
memory: 512Mi
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
# Cluster build of the OSINT Postgres image (amd64).
|
|
||||||
#
|
|
||||||
# Identical to `Dockerfile.pg` in sirius/osint-dashboard EXCEPT the base image
|
|
||||||
# is pinned to Debian bookworm AND to the 16.16 minor. The upstream file's bare
|
|
||||||
# `FROM postgres:16` now resolves to Debian trixie, where
|
|
||||||
# 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":
|
|
||||||
# undefined symbol: heap_datum_check
|
|
||||||
# On bookworm (+pgdg12) both extensions load and create_hypertable() works.
|
|
||||||
#
|
|
||||||
# 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 \
|
|
||||||
ca-certificates curl gnupg lsb-release && \
|
|
||||||
curl -fsSL https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash && \
|
|
||||||
apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
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 && \
|
|
||||||
echo "shared_preload_libraries = 'timescaledb'" > /etc/postgresql/16/main/conf.d/timescaledb.conf && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
# The official postgres entrypoint remains the CMD and handles
|
|
||||||
# POSTGRES_USER / POSTGRES_DB / POSTGRES_PASSWORD and pg_hba setup.
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
||||||
# TimescaleDB + PostGIS, single instance on local-path.
|
|
||||||
# NOT CloudNativePG: the app's alembic chain requires CREATE EXTENSION
|
|
||||||
# postgis AND timescaledb plus create_hypertable()/continuous aggregates, and
|
|
||||||
# this image (Dockerfile.pg, built amd64) is the exact Postgres the Pi stack
|
|
||||||
# ran. A CNPG cluster would need a custom CNPG-conformant Timescale image.
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-db
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-db
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
# ReadWriteOnce PVC: old and new pod cannot both mount it.
|
|
||||||
strategy:
|
|
||||||
type: Recreate
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-db
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-db
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
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:
|
|
||||||
kubernetes.io/arch: amd64
|
|
||||||
affinity:
|
|
||||||
nodeAffinity:
|
|
||||||
requiredDuringSchedulingIgnoredDuringExecution:
|
|
||||||
nodeSelectorTerms:
|
|
||||||
- matchExpressions:
|
|
||||||
- key: kubernetes.io/hostname
|
|
||||||
operator: In
|
|
||||||
values:
|
|
||||||
- linode
|
|
||||||
containers:
|
|
||||||
- name: postgres
|
|
||||||
image: forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-c48788d4b614-r3
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
args:
|
|
||||||
- -c
|
|
||||||
- shared_preload_libraries=timescaledb
|
|
||||||
- -c
|
|
||||||
- shared_buffers=1GB
|
|
||||||
- -c
|
|
||||||
- max_connections=100
|
|
||||||
ports:
|
|
||||||
- containerPort: 5432
|
|
||||||
name: postgres
|
|
||||||
env:
|
|
||||||
- name: POSTGRES_USER
|
|
||||||
value: osint
|
|
||||||
- name: POSTGRES_DB
|
|
||||||
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
|
|
||||||
value: /var/lib/postgresql/data/pgdata
|
|
||||||
- name: POSTGRES_PASSWORD
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: osint-db
|
|
||||||
key: password
|
|
||||||
readinessProbe:
|
|
||||||
exec:
|
|
||||||
command: ["pg_isready", "-U", "osint", "-d", "osint_data", "-h", "127.0.0.1"]
|
|
||||||
initialDelaySeconds: 10
|
|
||||||
periodSeconds: 10
|
|
||||||
failureThreshold: 6
|
|
||||||
livenessProbe:
|
|
||||||
exec:
|
|
||||||
command: ["pg_isready", "-U", "osint", "-d", "osint_data", "-h", "127.0.0.1"]
|
|
||||||
initialDelaySeconds: 60
|
|
||||||
periodSeconds: 30
|
|
||||||
failureThreshold: 6
|
|
||||||
volumeMounts:
|
|
||||||
- name: pgdata
|
|
||||||
mountPath: /var/lib/postgresql/data
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 200m
|
|
||||||
memory: 512Mi
|
|
||||||
limits:
|
|
||||||
memory: 2Gi
|
|
||||||
volumes:
|
|
||||||
- name: pgdata
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: osint-pgdata-linode
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: osint-pgdata
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: local-path
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 15Gi
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: osint-db
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: osint-db
|
|
||||||
ports:
|
|
||||||
- name: postgres
|
|
||||||
port: 5432
|
|
||||||
targetPort: 5432
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: osint-titiler
|
|
||||||
namespace: osint
|
|
||||||
labels:
|
|
||||||
app: osint-titiler
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: osint-titiler
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: osint-titiler
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
containers:
|
|
||||||
- name: titiler
|
|
||||||
image: forgejo.siriusdevops.com/sirius/titiler:0.26.0
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
ports:
|
|
||||||
- containerPort: 8000
|
|
||||||
name: http
|
|
||||||
env:
|
|
||||||
- name: PORT
|
|
||||||
value: "8000"
|
|
||||||
- name: WORKERS_PER_CORE
|
|
||||||
value: "1"
|
|
||||||
- name: WEB_CONCURRENCY
|
|
||||||
value: "1"
|
|
||||||
- name: GDAL_CACHEMAX
|
|
||||||
value: "128"
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /healthz
|
|
||||||
port: 8000
|
|
||||||
initialDelaySeconds: 5
|
|
||||||
periodSeconds: 15
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 128Mi
|
|
||||||
limits:
|
|
||||||
memory: 512Mi
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: osint-titiler
|
|
||||||
namespace: osint
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
app: osint-titiler
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8000
|
|
||||||
targetPort: 8000
|
|
||||||
|
|
@ -21,10 +21,8 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: contact-api
|
- name: contact-api
|
||||||
# Built and pushed by sirius/websites/.forgejo/workflows/deploy-phs-contact.yml
|
image: forgejo.siriusdevops.com/sirius/phs-contact:latest
|
||||||
# as :$sha (see docs/site-image-pinning.md).
|
imagePullPolicy: Always
|
||||||
image: forgejo.siriusdevops.com/sirius/phs-contact:5035443abb62913362e416ab7030a64726886886
|
|
||||||
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:
|
||||||
- containerPort: 8090
|
- containerPort: 8090
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: forgejo.siriusdevops.com/sirius/phs-site:5b590cddab6d7889fdd3c272255f28c4560e752e
|
image: forgejo.siriusdevops.com/sirius/phs-site:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
name: http
|
name: http
|
||||||
|
|
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
---
|
|
||||||
# Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of this
|
|
||||||
# namespace's CloudNativePG cluster through the exec API (namespace `forgejo`
|
|
||||||
# cannot mount a Secret from here, and the dump runs as the in-pod `postgres`
|
|
||||||
# superuser over the local socket, so no database password exists in git).
|
|
||||||
#
|
|
||||||
# Least privilege: that ServiceAccount may look up the Cluster object and run
|
|
||||||
# one command inside this namespace's pods — nothing else.
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: Role
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: sirius-growth
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
rules:
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods"]
|
|
||||||
verbs: ["get", "list"]
|
|
||||||
- apiGroups: [""]
|
|
||||||
resources: ["pods/exec"]
|
|
||||||
verbs: ["create"]
|
|
||||||
- apiGroups: ["postgresql.cnpg.io"]
|
|
||||||
resources: ["clusters"]
|
|
||||||
verbs: ["get"]
|
|
||||||
---
|
|
||||||
apiVersion: rbac.authorization.k8s.io/v1
|
|
||||||
kind: RoleBinding
|
|
||||||
metadata:
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: sirius-growth
|
|
||||||
labels:
|
|
||||||
app: cluster-backup
|
|
||||||
roleRef:
|
|
||||||
apiGroup: rbac.authorization.k8s.io
|
|
||||||
kind: Role
|
|
||||||
name: cluster-backup
|
|
||||||
subjects:
|
|
||||||
- kind: ServiceAccount
|
|
||||||
name: cluster-backup
|
|
||||||
namespace: forgejo
|
|
||||||
|
|
@ -24,45 +24,3 @@ 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
|
|
||||||
# in apps/base/forgejo/podmonitor.yaml for why enablePodMonitor is false).
|
|
||||||
# Only the operator's default query set here — this database needs no custom
|
|
||||||
# application metrics.
|
|
||||||
monitoring:
|
|
||||||
enablePodMonitor: false
|
|
||||||
disableDefaultQueries: false
|
|
||||||
customQueriesConfigMap:
|
|
||||||
- name: cnpg-default-monitoring
|
|
||||||
key: queries
|
|
||||||
|
|
|
||||||
|
|
@ -1,69 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: sirius-growth-portal-gate
|
|
||||||
namespace: sirius-growth
|
|
||||||
data:
|
|
||||||
default.conf: |
|
|
||||||
# Sirius Growth portal login gate. One job: cap credential attempts per client
|
|
||||||
# IP before they reach the API. The HTTPRoute sends only /api/portal/login* here
|
|
||||||
# (login, plus a trailing-slash variant); everything else goes straight to the
|
|
||||||
# portal service, so this pod can never break uploads, downloads or the admin API.
|
|
||||||
|
|
||||||
# The TCP peer is always cluster ingress, so $remote_addr is meaningless until
|
|
||||||
# the forwarded chain is resolved: Envoy (hostNetwork, siriussec) appends the
|
|
||||||
# caller to X-Forwarded-For. Trusting the pod / service / node ranges makes
|
|
||||||
# $remote_addr the real client. A caller cannot spoof it by sending its own
|
|
||||||
# X-Forwarded-For, because Envoy appends the true address to the right of
|
|
||||||
# whatever the client supplied and nginx walks the chain from the right.
|
|
||||||
set_real_ip_from 10.244.0.0/16;
|
|
||||||
set_real_ip_from 10.96.0.0/12;
|
|
||||||
set_real_ip_from 10.10.0.0/24;
|
|
||||||
real_ip_header X-Forwarded-For;
|
|
||||||
real_ip_recursive on;
|
|
||||||
|
|
||||||
# 12 attempts/min per IP with 6 in hand: a fat-fingered operator gets several
|
|
||||||
# tries, a password guesser gets nowhere. Tune the two numbers here only.
|
|
||||||
limit_req_zone $binary_remote_addr zone=portal_login:10m rate=12r/m;
|
|
||||||
limit_req_status 429;
|
|
||||||
limit_req_log_level warn;
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 8080;
|
|
||||||
server_name _;
|
|
||||||
default_type application/json;
|
|
||||||
|
|
||||||
client_max_body_size 8k;
|
|
||||||
client_body_timeout 10s;
|
|
||||||
|
|
||||||
location ^~ /api/portal/login {
|
|
||||||
limit_req zone=portal_login burst=6 nodelay;
|
|
||||||
|
|
||||||
# JSON, not nginx's HTML error page: portal.js shows the body's `error`
|
|
||||||
# string on the sign-in page instead of "Portal API is not reachable".
|
|
||||||
error_page 429 @login_limited;
|
|
||||||
|
|
||||||
proxy_pass http://sirius-growth-portal:8091;
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
# Pass the chain through verbatim; uvicorn reads the leftmost entry.
|
|
||||||
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_connect_timeout 5s;
|
|
||||||
proxy_read_timeout 15s;
|
|
||||||
proxy_send_timeout 15s;
|
|
||||||
proxy_buffering off;
|
|
||||||
}
|
|
||||||
|
|
||||||
location @login_limited {
|
|
||||||
internal;
|
|
||||||
default_type application/json;
|
|
||||||
add_header Cache-Control "no-store" always;
|
|
||||||
return 429 '{"error":"too many sign-in attempts - wait a minute and try again"}';
|
|
||||||
}
|
|
||||||
|
|
||||||
# Nothing else is routed to this pod. An honest 404 beats a proxied surprise.
|
|
||||||
location / {
|
|
||||||
return 404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
apiVersion: batch/v1
|
|
||||||
kind: CronJob
|
|
||||||
metadata:
|
|
||||||
name: sgs-leadgen-ncda
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
# 10:00, not 08:00: on a Monday-the-1st the weekly job owns the RWO volume at
|
|
||||||
# 08:00 and concurrencyPolicy is per-CronJob, so a 2h gap keeps them apart.
|
|
||||||
schedule: "0 10 1 * *"
|
|
||||||
timeZone: America/New_York
|
|
||||||
concurrencyPolicy: Forbid
|
|
||||||
startingDeadlineSeconds: 3600
|
|
||||||
suspend: false
|
|
||||||
successfulJobsHistoryLimit: 3
|
|
||||||
failedJobsHistoryLimit: 3
|
|
||||||
jobTemplate:
|
|
||||||
spec:
|
|
||||||
backoffLimit: 1
|
|
||||||
activeDeadlineSeconds: 1800
|
|
||||||
ttlSecondsAfterFinished: 604800
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: sgs-leadgen-ncda
|
|
||||||
spec:
|
|
||||||
restartPolicy: Never
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
securityContext:
|
|
||||||
fsGroup: 10001
|
|
||||||
containers:
|
|
||||||
- name: leadgen
|
|
||||||
image: forgejo.siriusdevops.com/sirius/sgs-leadgen:eef935874bb19b6cee73bd93d7fd9ab4001ec184
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
env:
|
|
||||||
- name: DATABASE_URL
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-portal-app
|
|
||||||
key: database-url
|
|
||||||
- name: TELEGRAM_BOT_TOKEN
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-contact
|
|
||||||
key: TG_TOKEN
|
|
||||||
- name: TELEGRAM_CHAT_ID
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-contact
|
|
||||||
key: TG_CHAT
|
|
||||||
- name: SGS_DATA_DIR
|
|
||||||
value: /data
|
|
||||||
- name: SGS_STATE_PATH
|
|
||||||
value: /data/state.json
|
|
||||||
- name: SGS_CSV
|
|
||||||
value: /data/leads.csv
|
|
||||||
# Monthly-only source: the NCDA&CS licensed-nursery register.
|
|
||||||
- name: SGS_NCDA
|
|
||||||
value: "1"
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
- name: tmp
|
|
||||||
mountPath: /tmp
|
|
||||||
securityContext:
|
|
||||||
runAsNonRoot: true
|
|
||||||
allowPrivilegeEscalation: false
|
|
||||||
readOnlyRootFilesystem: true
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
memory: 1Gi
|
|
||||||
volumes:
|
|
||||||
- name: data
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: sgs-leadgen-data
|
|
||||||
- name: tmp
|
|
||||||
emptyDir:
|
|
||||||
sizeLimit: 256Mi
|
|
||||||
|
|
@ -1,85 +0,0 @@
|
||||||
apiVersion: batch/v1
|
|
||||||
kind: CronJob
|
|
||||||
metadata:
|
|
||||||
name: sgs-leadgen
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
schedule: "0 8 * * 1"
|
|
||||||
timeZone: America/New_York
|
|
||||||
concurrencyPolicy: Forbid
|
|
||||||
startingDeadlineSeconds: 3600
|
|
||||||
suspend: false
|
|
||||||
successfulJobsHistoryLimit: 3
|
|
||||||
failedJobsHistoryLimit: 3
|
|
||||||
jobTemplate:
|
|
||||||
spec:
|
|
||||||
backoffLimit: 1
|
|
||||||
activeDeadlineSeconds: 1800
|
|
||||||
ttlSecondsAfterFinished: 604800
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: sgs-leadgen
|
|
||||||
spec:
|
|
||||||
restartPolicy: Never
|
|
||||||
# local-path is a node-local volume: the pod must run where the PV is.
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
# local-path mounts root-owned; the image runs as uid 10001, so fsGroup
|
|
||||||
# makes /data group-writable for it.
|
|
||||||
securityContext:
|
|
||||||
fsGroup: 10001
|
|
||||||
containers:
|
|
||||||
- name: leadgen
|
|
||||||
image: forgejo.siriusdevops.com/sirius/sgs-leadgen:eef935874bb19b6cee73bd93d7fd9ab4001ec184
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
env:
|
|
||||||
- name: DATABASE_URL
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-portal-app
|
|
||||||
key: database-url
|
|
||||||
- name: TELEGRAM_BOT_TOKEN
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-contact
|
|
||||||
key: TG_TOKEN
|
|
||||||
- name: TELEGRAM_CHAT_ID
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-contact
|
|
||||||
key: TG_CHAT
|
|
||||||
- name: SGS_DATA_DIR
|
|
||||||
value: /data
|
|
||||||
- name: SGS_STATE_PATH
|
|
||||||
value: /data/state.json
|
|
||||||
- name: SGS_CSV
|
|
||||||
value: /data/leads.csv
|
|
||||||
volumeMounts:
|
|
||||||
- name: data
|
|
||||||
mountPath: /data
|
|
||||||
# tempfile.NamedTemporaryFile() needs a writable TMPDIR; the rest
|
|
||||||
# of the root filesystem stays read-only.
|
|
||||||
- name: tmp
|
|
||||||
mountPath: /tmp
|
|
||||||
securityContext:
|
|
||||||
runAsNonRoot: true
|
|
||||||
allowPrivilegeEscalation: false
|
|
||||||
readOnlyRootFilesystem: true
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 100m
|
|
||||||
memory: 256Mi
|
|
||||||
limits:
|
|
||||||
memory: 1Gi
|
|
||||||
volumes:
|
|
||||||
- name: data
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: sgs-leadgen-data
|
|
||||||
- name: tmp
|
|
||||||
emptyDir:
|
|
||||||
sizeLimit: 256Mi
|
|
||||||
34
apps/base/sirius-growth/deployer.yaml
Normal file
34
apps/base/sirius-growth/deployer.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Deployer identity used by the sirius-growth site repo's CI to roll the
|
||||||
|
# Deployment after pushing a new image. Deliberately minimal: patch/get/list on
|
||||||
|
# deployments in this namespace only. The kubeconfig is a repo secret
|
||||||
|
# (KUBE_CONFIG) in sirius/sirius-growth; the token is minted with
|
||||||
|
# # kubectl -n sirius-growth create token site-deployer --duration=8760h
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: site-deployer
|
||||||
|
namespace: sirius-growth
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: site-deployer
|
||||||
|
namespace: sirius-growth
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["apps"]
|
||||||
|
resources: ["deployments"]
|
||||||
|
verbs: ["get", "list", "patch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: site-deployer
|
||||||
|
namespace: sirius-growth
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: site-deployer
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: site-deployer
|
||||||
|
namespace: sirius-growth
|
||||||
|
|
@ -21,10 +21,8 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: contact-api
|
- name: contact-api
|
||||||
# Built and pushed by sirius-growth/.forgejo/workflows/deploy-contact.yml
|
image: forgejo.siriusdevops.com/sirius/sirius-growth-contact:latest
|
||||||
# as :$sha (see docs/site-image-pinning.md).
|
imagePullPolicy: Always
|
||||||
image: forgejo.siriusdevops.com/sirius/sirius-growth-contact:c9c9379ebceca6879d3bbeff1c2601b6484e87b0
|
|
||||||
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:
|
||||||
- containerPort: 8090
|
- containerPort: 8090
|
||||||
|
|
|
||||||
|
|
@ -1,91 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: sirius-growth-blog
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: sirius-growth-blog
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: sirius-growth-blog
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
containers:
|
|
||||||
- name: blog
|
|
||||||
# Pinned by immutable tag. The blog is mounted at /journal by the
|
|
||||||
# site nginx, so it has no Service hostname of its own and no
|
|
||||||
# HTTPRoute - the marketing site proxies to this ClusterIP service.
|
|
||||||
image: forgejo.siriusdevops.com/sirius/sirius-growth-blog:4378680888a7d3976106533111003e2cb257a362
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
ports:
|
|
||||||
- containerPort: 8092
|
|
||||||
name: http
|
|
||||||
env:
|
|
||||||
- name: DATABASE_URL
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-app
|
|
||||||
key: database-url
|
|
||||||
- name: SESSION_SECRET
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-app
|
|
||||||
key: session-secret
|
|
||||||
- name: S3_ENDPOINT
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-s3
|
|
||||||
key: endpoint
|
|
||||||
- name: S3_BUCKET
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-s3
|
|
||||||
key: bucket
|
|
||||||
- name: S3_ACCESS_KEY
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-s3
|
|
||||||
key: access-key
|
|
||||||
- name: S3_SECRET_KEY
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-s3
|
|
||||||
key: secret-key
|
|
||||||
- name: S3_REGION
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-blog-s3
|
|
||||||
key: region
|
|
||||||
# Every URL the service emits (canonical, RSS, sitemap, media,
|
|
||||||
# admin form actions) hangs off this; the mount is /journal.
|
|
||||||
- name: PUBLIC_BASE_URL
|
|
||||||
value: https://siriusgrowthsolutions.com/journal
|
|
||||||
- name: PORTAL_BASE_URL
|
|
||||||
value: https://siriusgrowthsolutions.com
|
|
||||||
readinessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /health
|
|
||||||
port: 8092
|
|
||||||
initialDelaySeconds: 5
|
|
||||||
periodSeconds: 10
|
|
||||||
livenessProbe:
|
|
||||||
httpGet:
|
|
||||||
path: /health
|
|
||||||
port: 8092
|
|
||||||
initialDelaySeconds: 20
|
|
||||||
periodSeconds: 20
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 128Mi
|
|
||||||
limits:
|
|
||||||
memory: 384Mi
|
|
||||||
|
|
@ -1,53 +0,0 @@
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: sirius-growth-portal-gate
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
app: sirius-growth-portal-gate
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: sirius-growth-portal-gate
|
|
||||||
spec:
|
|
||||||
tolerations:
|
|
||||||
- key: dedicated
|
|
||||||
operator: Exists
|
|
||||||
effect: PreferNoSchedule
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
containers:
|
|
||||||
- name: nginx
|
|
||||||
image: nginx:1.27-alpine
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
ports:
|
|
||||||
- containerPort: 8080
|
|
||||||
name: http
|
|
||||||
volumeMounts:
|
|
||||||
- name: conf
|
|
||||||
mountPath: /etc/nginx/conf.d/default.conf
|
|
||||||
subPath: default.conf
|
|
||||||
readOnly: true
|
|
||||||
readinessProbe:
|
|
||||||
tcpSocket:
|
|
||||||
port: 8080
|
|
||||||
initialDelaySeconds: 2
|
|
||||||
periodSeconds: 10
|
|
||||||
livenessProbe:
|
|
||||||
tcpSocket:
|
|
||||||
port: 8080
|
|
||||||
initialDelaySeconds: 10
|
|
||||||
periodSeconds: 20
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 10m
|
|
||||||
memory: 16Mi
|
|
||||||
limits:
|
|
||||||
memory: 64Mi
|
|
||||||
volumes:
|
|
||||||
- name: conf
|
|
||||||
configMap:
|
|
||||||
name: sirius-growth-portal-gate
|
|
||||||
|
|
@ -21,8 +21,8 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: portal-api
|
- name: portal-api
|
||||||
image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:ce350ed04749d57833020bda8604b1d16896d25c
|
image: forgejo.siriusdevops.com/sirius/sirius-growth-portal:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8091
|
- containerPort: 8091
|
||||||
name: http
|
name: http
|
||||||
|
|
@ -72,16 +72,6 @@ spec:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: sirius-growth-portal-app
|
name: sirius-growth-portal-app
|
||||||
key: s3-region
|
key: s3-region
|
||||||
- name: TG_TOKEN
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-contact
|
|
||||||
key: TG_TOKEN
|
|
||||||
- name: TG_CHAT
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
name: sirius-growth-contact
|
|
||||||
key: TG_CHAT
|
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /api/portal/health
|
path: /api/portal/health
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: forgejo.siriusdevops.com/sirius/sirius-growth-site:413d98f6e079fd236c8f17b522be5294bced7875
|
image: forgejo.siriusdevops.com/sirius/sirius-growth-site:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
name: http
|
name: http
|
||||||
|
|
|
||||||
|
|
@ -18,13 +18,6 @@ spec:
|
||||||
backendRefs:
|
backendRefs:
|
||||||
- name: sirius-growth-contact
|
- name: sirius-growth-contact
|
||||||
port: 8090
|
port: 8090
|
||||||
- matches:
|
|
||||||
- path:
|
|
||||||
type: PathPrefix
|
|
||||||
value: /api/portal/login
|
|
||||||
backendRefs:
|
|
||||||
- name: sirius-growth-portal-gate
|
|
||||||
port: 8080
|
|
||||||
- matches:
|
- matches:
|
||||||
- path:
|
- path:
|
||||||
type: PathPrefix
|
type: PathPrefix
|
||||||
|
|
|
||||||
|
|
@ -5,25 +5,9 @@ resources:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
- deployment-api.yaml
|
- deployment-api.yaml
|
||||||
- deployment-portal.yaml
|
- deployment-portal.yaml
|
||||||
- deployment-blog.yaml
|
|
||||||
- deployment-portal-gate.yaml
|
|
||||||
- configmap-portal-gate.yaml
|
|
||||||
- service.yaml
|
- service.yaml
|
||||||
- service-api.yaml
|
- service-api.yaml
|
||||||
- service-portal.yaml
|
- service-portal.yaml
|
||||||
- service-blog.yaml
|
|
||||||
- service-portal-gate.yaml
|
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
# The WAL archive store must exist before the Cluster references it.
|
- deployer.yaml
|
||||||
- objectstore-portal-wal.yaml
|
|
||||||
- cluster.yaml
|
- cluster.yaml
|
||||||
- scheduled-backup.yaml
|
|
||||||
- podmonitor.yaml
|
|
||||||
- pvc-leadgen.yaml
|
|
||||||
- cronjob-leadgen.yaml
|
|
||||||
- cronjob-leadgen-ncda.yaml
|
|
||||||
# exec-only RBAC so forgejo/cluster-backup can pg_dump this namespace's CNPG
|
|
||||||
# cluster (portal) without copying a database password across namespaces.
|
|
||||||
- backup-exec-rbac.yaml
|
|
||||||
# Snapshot mirror of the lead-gen capture PVC to the Linode.
|
|
||||||
- leadgen-backup.yaml
|
|
||||||
|
|
|
||||||
|
|
@ -1,150 +0,0 @@
|
||||||
---
|
|
||||||
# backup: `sgs-leadgen-data` PVC (4.9 MiB) -> Linode VPS over the WireGuard mesh.
|
|
||||||
#
|
|
||||||
# The lead-gen CronJobs (`cronjob-leadgen.yaml`, `cronjob-leadgen-ncda.yaml`)
|
|
||||||
# read and write this claim, so a pod of this namespace must mount it — a PVC
|
|
||||||
# cannot be mounted from `forgejo` where the main cluster-backup job lives.
|
|
||||||
# The mirror is a hardlink `--link-dest` snapshot chain (same shape as the
|
|
||||||
# forgejo-data mirror) so each night is a full restorable directory and only
|
|
||||||
# changed blocks cross the tunnel.
|
|
||||||
apiVersion: v1
|
|
||||||
kind: ConfigMap
|
|
||||||
metadata:
|
|
||||||
name: leadgen-backup-scripts
|
|
||||||
namespace: sirius-growth
|
|
||||||
labels:
|
|
||||||
app: leadgen-backup
|
|
||||||
data:
|
|
||||||
backup.sh: |
|
|
||||||
#!/bin/bash
|
|
||||||
# Snapshot mirror of /src -> $BACKUP_DIR/leadgen-data/<stamp>/ + `latest`.
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
if ! command -v rsync >/dev/null || ! command -v ssh >/dev/null; then
|
|
||||||
echo "== installing rsync + openssh-client"
|
|
||||||
apk add --no-cache rsync openssh-client >/dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
BACKUP_HOST=${BACKUP_HOST:[email protected]}
|
|
||||||
BACKUP_DIR=${BACKUP_DIR:-/root/cluster-backup}
|
|
||||||
DATA_SRC=${DATA_SRC:-/src}
|
|
||||||
DATA_KEEP=${DATA_KEEP:-7}
|
|
||||||
MIN_FREE_GB=${MIN_FREE_GB:-8}
|
|
||||||
STAMP=${STAMP:-$(date -u +%Y%m%dT%H%M%SZ)}
|
|
||||||
|
|
||||||
SSH_OPTS=(-i /keys/id_ed25519
|
|
||||||
-o UserKnownHostsFile=/keys/known_hosts
|
|
||||||
-o StrictHostKeyChecking=yes
|
|
||||||
-o BatchMode=yes
|
|
||||||
-o ConnectTimeout=20
|
|
||||||
-o ServerAliveInterval=30)
|
|
||||||
ssh_r() { ssh "${SSH_OPTS[@]}" "$BACKUP_HOST" "$@"; }
|
|
||||||
|
|
||||||
echo "== target: $BACKUP_HOST:$BACKUP_DIR stamp=$STAMP"
|
|
||||||
ssh_r "mkdir -p '$BACKUP_DIR/leadgen-data' '$BACKUP_DIR/manifests'"
|
|
||||||
avail_gb=$(ssh_r "df -Pk '$BACKUP_DIR' | awk 'NR==2{printf \"%d\", \$4/1048576}'")
|
|
||||||
avail_gb=${avail_gb:-0}
|
|
||||||
echo "== remote free space: ${avail_gb} GiB (minimum ${MIN_FREE_GB} GiB)"
|
|
||||||
if [ "$avail_gb" -lt "$MIN_FREE_GB" ]; then
|
|
||||||
echo "FAIL: not enough free space on $BACKUP_HOST"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
ssh_r "cd '$BACKUP_DIR/leadgen-data' && [ -e latest ] || { mkdir -p .empty && ln -sfn .empty latest; }"
|
|
||||||
|
|
||||||
echo "== leadgen-data: $DATA_SRC -> leadgen-data/$STAMP (link-dest)"
|
|
||||||
rc=0
|
|
||||||
rsync -a --numeric-ids --delete --stats --link-dest=../latest \
|
|
||||||
-e "ssh ${SSH_OPTS[*]}" \
|
|
||||||
"$DATA_SRC/" "$BACKUP_HOST:$BACKUP_DIR/leadgen-data/$STAMP/" || rc=$?
|
|
||||||
case "$rc" in
|
|
||||||
0) ;;
|
|
||||||
24) echo "== rsync exit 24: files changed during the copy (expected)" ;;
|
|
||||||
*) echo "FAIL: rsync exit $rc"; exit "$rc" ;;
|
|
||||||
esac
|
|
||||||
ssh_r "cd '$BACKUP_DIR/leadgen-data' && ln -sfn '$STAMP' latest && du -sh '$STAMP'"
|
|
||||||
|
|
||||||
echo "== manifest"
|
|
||||||
ssh_r "cd '$BACKUP_DIR' && { echo 'stamp $STAMP'; echo \"host \$(hostname -s)\"; \
|
|
||||||
echo '--- leadgen-data/latest'; du -shL leadgen-data/latest; \
|
|
||||||
find leadgen-data/latest -type f -exec sha256sum {} + | sed 's| leadgen-data/latest/| |'; } \
|
|
||||||
>> manifests/$STAMP.txt && tail -8 manifests/$STAMP.txt"
|
|
||||||
|
|
||||||
echo "== retention: last $DATA_KEEP leadgen snapshots"
|
|
||||||
ssh_r "cd '$BACKUP_DIR/leadgen-data' && ls -1dt 20* 2>/dev/null | tail -n +$((DATA_KEEP + 1)) | xargs -r rm -rf"
|
|
||||||
ssh_r "df -h '$BACKUP_DIR' | tail -1"
|
|
||||||
|
|
||||||
echo "RESULT=success stamp=$STAMP"
|
|
||||||
---
|
|
||||||
apiVersion: batch/v1
|
|
||||||
kind: CronJob
|
|
||||||
metadata:
|
|
||||||
name: leadgen-backup
|
|
||||||
namespace: sirius-growth
|
|
||||||
labels:
|
|
||||||
app: leadgen-backup
|
|
||||||
spec:
|
|
||||||
# 07 minutes after the grafana job; the dataset is tiny, this is only so the
|
|
||||||
# three nightly jobs never overlap on the mesh.
|
|
||||||
schedule: "7 3 * * *"
|
|
||||||
timeZone: "Etc/UTC"
|
|
||||||
concurrencyPolicy: Forbid
|
|
||||||
startingDeadlineSeconds: 1800
|
|
||||||
successfulJobsHistoryLimit: 3
|
|
||||||
failedJobsHistoryLimit: 3
|
|
||||||
jobTemplate:
|
|
||||||
spec:
|
|
||||||
activeDeadlineSeconds: 900
|
|
||||||
backoffLimit: 1
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: leadgen-backup
|
|
||||||
spec:
|
|
||||||
restartPolicy: Never
|
|
||||||
# The PVC is local-path on siriussec.
|
|
||||||
nodeSelector:
|
|
||||||
kubernetes.io/hostname: siriussec
|
|
||||||
containers:
|
|
||||||
- name: backup
|
|
||||||
image: alpine/k8s:1.36.4
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command: ["/bin/bash", "/scripts/backup.sh"]
|
|
||||||
env:
|
|
||||||
- name: BACKUP_HOST
|
|
||||||
value: [email protected]
|
|
||||||
- name: BACKUP_DIR
|
|
||||||
value: /root/cluster-backup
|
|
||||||
- name: DATA_KEEP
|
|
||||||
value: "7"
|
|
||||||
volumeMounts:
|
|
||||||
- name: leadgen-data
|
|
||||||
mountPath: /src
|
|
||||||
readOnly: true
|
|
||||||
- name: keys
|
|
||||||
mountPath: /keys
|
|
||||||
readOnly: true
|
|
||||||
- name: scripts
|
|
||||||
mountPath: /scripts
|
|
||||||
readOnly: true
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 50m
|
|
||||||
memory: 64Mi
|
|
||||||
limits:
|
|
||||||
ephemeral-storage: 512Mi
|
|
||||||
memory: 256Mi
|
|
||||||
volumes:
|
|
||||||
- name: leadgen-data
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: sgs-leadgen-data
|
|
||||||
readOnly: true
|
|
||||||
- name: keys
|
|
||||||
secret:
|
|
||||||
# Copy of forgejo/cluster-backup-ssh, created out of band.
|
|
||||||
secretName: cluster-backup-ssh
|
|
||||||
defaultMode: 0400
|
|
||||||
- name: scripts
|
|
||||||
configMap:
|
|
||||||
name: leadgen-backup-scripts
|
|
||||||
defaultMode: 0755
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
# 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"
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
# Prometheus scrape config for the Sirius Growth Postgres cluster (CNPG).
|
|
||||||
# See apps/base/forgejo/podmonitor.yaml for why this is hand-written rather than
|
|
||||||
# produced by `spec.monitoring.enablePodMonitor` (deprecated as of CNPG 1.27).
|
|
||||||
apiVersion: monitoring.coreos.com/v1
|
|
||||||
kind: PodMonitor
|
|
||||||
metadata:
|
|
||||||
name: cnpg-portal
|
|
||||||
namespace: sirius-growth
|
|
||||||
labels:
|
|
||||||
release: kube-prometheus-stack
|
|
||||||
spec:
|
|
||||||
selector:
|
|
||||||
matchLabels:
|
|
||||||
cnpg.io/cluster: portal
|
|
||||||
podMetricsEndpoints:
|
|
||||||
- port: metrics
|
|
||||||
interval: 30s
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: sgs-leadgen-data
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
storageClassName: local-path
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: 1Gi
|
|
||||||
|
|
@ -1,24 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: sirius-growth-blog
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
type: ClusterIP
|
|
||||||
selector:
|
|
||||||
app: sirius-growth-blog
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8092
|
|
||||||
targetPort: 8092
|
|
||||||
protocol: TCP
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
name: sirius-growth-portal-gate
|
|
||||||
namespace: sirius-growth
|
|
||||||
spec:
|
|
||||||
type: ClusterIP
|
|
||||||
selector:
|
|
||||||
app: sirius-growth-portal-gate
|
|
||||||
ports:
|
|
||||||
- name: http
|
|
||||||
port: 8080
|
|
||||||
targetPort: 8080
|
|
||||||
protocol: TCP
|
|
||||||
34
apps/base/siriusdevops/deployer.yaml
Normal file
34
apps/base/siriusdevops/deployer.yaml
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Deployer identity used by the siriusdevops site repo's CI to roll the
|
||||||
|
# Deployments after pushing a new image. Deliberately minimal: patch/get/list on
|
||||||
|
# deployments in this namespace only. The kubeconfig is a repo secret
|
||||||
|
# (KUBE_CONFIG) in sirius/siriusdevops-contact; the token is minted with
|
||||||
|
# kubectl -n siriusdevops create token site-deployer --duration=8760h
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
metadata:
|
||||||
|
name: site-deployer
|
||||||
|
namespace: siriusdevops
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: site-deployer
|
||||||
|
namespace: siriusdevops
|
||||||
|
rules:
|
||||||
|
- apiGroups: ["apps"]
|
||||||
|
resources: ["deployments"]
|
||||||
|
verbs: ["get", "list", "patch"]
|
||||||
|
---
|
||||||
|
apiVersion: rbac.authorization.k8s.io/v1
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: site-deployer
|
||||||
|
namespace: siriusdevops
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: site-deployer
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: site-deployer
|
||||||
|
namespace: siriusdevops
|
||||||
|
|
@ -21,8 +21,8 @@ spec:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
containers:
|
containers:
|
||||||
- name: contact-api
|
- name: contact-api
|
||||||
image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:8642f1a14b1dd9f217e32856b7a9ea0a0c37e3aa
|
image: forgejo.siriusdevops.com/sirius/siriusdevops-contact:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"]
|
command: ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8090"]
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 8090
|
- containerPort: 8090
|
||||||
|
|
|
||||||
|
|
@ -19,70 +19,13 @@ spec:
|
||||||
effect: PreferNoSchedule
|
effect: PreferNoSchedule
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
kubernetes.io/hostname: siriussec
|
kubernetes.io/hostname: siriussec
|
||||||
# Owner media is NOT in the image, and the Garage bucket stays private
|
|
||||||
# (WireGuard-only: no website access, no public hostname). This
|
|
||||||
# initContainer pulls s3://siriusdevops-media over the mesh into an
|
|
||||||
# emptyDir that nginx serves at /media/. Baked assets (site.css, og.png,
|
|
||||||
# favicon, screenshots) stay baked - scope is owner media only.
|
|
||||||
#
|
|
||||||
# It must never take the site down: if Garage is unreachable at boot it
|
|
||||||
# retries a few times, then exits 0 with a warning and the page serves
|
|
||||||
# with the monogram fallback instead of the headshot.
|
|
||||||
initContainers:
|
|
||||||
- name: media-sync
|
|
||||||
image: amazon/aws-cli@sha256:7a77ccb39e3272191adbf905c50db8c127db88fd79454911a41a6b1c0e419e9b
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
command:
|
|
||||||
- /bin/sh
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
set -u
|
|
||||||
for attempt in 1 2 3 4 5; do
|
|
||||||
if aws s3 sync "s3://siriusdevops-media/" /media/ \
|
|
||||||
--endpoint-url http://10.10.0.1:3900 \
|
|
||||||
--only-show-errors; then
|
|
||||||
echo "media sync ok (attempt $attempt): $(ls -R /media | head -20)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "media sync attempt $attempt failed; retrying in 10s"
|
|
||||||
sleep 10
|
|
||||||
done
|
|
||||||
echo "WARNING: media sync failed after 5 attempts - serving without /media (headshot falls back to monogram)"
|
|
||||||
exit 0
|
|
||||||
env:
|
|
||||||
# aws-cli v2 sends a CRC32 checksum header on PutObject/HeadObject
|
|
||||||
# by default and Garage v1.1.0 rejects it as "invalid checksum
|
|
||||||
# algorithm" - only send checksums when an operation requires one.
|
|
||||||
- name: AWS_DEFAULT_REGION
|
|
||||||
value: garage
|
|
||||||
- name: AWS_EC2_METADATA_DISABLED
|
|
||||||
value: "true"
|
|
||||||
- name: AWS_REQUEST_CHECKSUM_CALCULATION
|
|
||||||
value: when_required
|
|
||||||
- name: AWS_RESPONSE_CHECKSUM_VALIDATION
|
|
||||||
value: when_required
|
|
||||||
envFrom:
|
|
||||||
- secretRef:
|
|
||||||
name: garage-media-s3
|
|
||||||
volumeMounts:
|
|
||||||
- name: media
|
|
||||||
mountPath: /media
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
cpu: 10m
|
|
||||||
memory: 32Mi
|
|
||||||
limits:
|
|
||||||
memory: 128Mi
|
|
||||||
containers:
|
containers:
|
||||||
- name: nginx
|
- name: nginx
|
||||||
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:399c421f51a2fd74a87e810641226d58e4e22690
|
image: forgejo.siriusdevops.com/sirius/siriusdevops-site:latest
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
ports:
|
ports:
|
||||||
- containerPort: 80
|
- containerPort: 80
|
||||||
name: http
|
name: http
|
||||||
volumeMounts:
|
|
||||||
- name: media
|
|
||||||
mountPath: /usr/share/nginx/html/media
|
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /
|
path: /
|
||||||
|
|
@ -95,6 +38,3 @@ spec:
|
||||||
memory: 64Mi
|
memory: 64Mi
|
||||||
limits:
|
limits:
|
||||||
memory: 256Mi
|
memory: 256Mi
|
||||||
volumes:
|
|
||||||
- name: media
|
|
||||||
emptyDir: {}
|
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,4 @@ resources:
|
||||||
- service-site.yaml
|
- service-site.yaml
|
||||||
- service-api.yaml
|
- service-api.yaml
|
||||||
- httproute.yaml
|
- httproute.yaml
|
||||||
- networkpolicy-site-egress.yaml
|
- deployer.yaml
|
||||||
|
|
|
||||||
|
|
@ -1,70 +0,0 @@
|
||||||
# Egress policy for the public site pod — the first policy in this namespace
|
|
||||||
# (there were zero before 2026-11-19, so every pod could reach every WireGuard
|
|
||||||
# address).
|
|
||||||
#
|
|
||||||
# What it is for: `siriusdevops-site` runs an initContainer that pulls owner
|
|
||||||
# media out of the private Garage bucket over the mesh
|
|
||||||
# (http://10.10.0.1:3900). Nothing else about that pod needs to talk to the
|
|
||||||
# WireGuard network, and the pod is internet-facing, so it is the right first
|
|
||||||
# pod to fence off.
|
|
||||||
#
|
|
||||||
# WHY A CiliumNetworkPolicy AND NOT A networking.k8s.io NetworkPolicy:
|
|
||||||
# 10.10.0.1 is a CLUSTER NODE (rpi, the WireGuard hub), not a bare address.
|
|
||||||
# Cilium resolves it to `reserved:remote-node` (identity 6) in its ipcache
|
|
||||||
# (`cilium-dbg bpf ipcache list | grep 10.10.0.1` -> identity=6), and `ipBlock`
|
|
||||||
# / toCIDR rules are only evaluated for `reserved:world`. A standard
|
|
||||||
# NetworkPolicy with `ipBlock: 10.10.0.1/32` is silently inert here — measured:
|
|
||||||
# the pod's request to 10.10.0.1:3900 timed out exactly like the denied ports,
|
|
||||||
# while Prometheus (unrestricted namespace) scraped the same host fine.
|
|
||||||
#
|
|
||||||
# The narrower `toNodes: [{matchLabels: {kubernetes.io/hostname: rpi}}]` form
|
|
||||||
# would name the node exactly, but the agent rejects it unless Cilium runs with
|
|
||||||
# `enable-node-selector-labels: true` — status: "FromNodes/ToNodes rules can
|
|
||||||
# only be applied when the \"enable-node-selector-labels\" flag is set". Rather
|
|
||||||
# than change a cluster-wide Cilium flag for one policy, this uses the
|
|
||||||
# `remote-node` entity: any cluster node, TCP 3900 only. Every cluster node is
|
|
||||||
# on the WireGuard overlay, so this still cannot reach the LAN or the public
|
|
||||||
# internet, and the port scope is what makes the denial test meaningful.
|
|
||||||
#
|
|
||||||
# Scope: Egress only, one pod selector. Other pods in siriusdevops (and every
|
|
||||||
# other namespace) remain unrestricted — this proves the pattern, it is not
|
|
||||||
# namespace segregation. Ingress is untouched: the Cilium Gateway must still be
|
|
||||||
# able to reach nginx on :80.
|
|
||||||
#
|
|
||||||
# The policy is a whitelist: once it selects a pod, ALL egress from that pod is
|
|
||||||
# denied except what is listed. Two allowances:
|
|
||||||
# 1. TCP 3900 to a cluster node — Garage's S3 API on 10.10.0.1. Deliberately
|
|
||||||
# port-scoped: 10.10.0.1 also serves the container registry on 5000, and
|
|
||||||
# that stays unreachable from this pod.
|
|
||||||
# 2. Cluster DNS. Nothing in this pod resolves names today (the S3 endpoint
|
|
||||||
# is a literal IP); the rule costs one line and removes the trap of
|
|
||||||
# breaking name resolution in a pod that later grows a container.
|
|
||||||
apiVersion: cilium.io/v2
|
|
||||||
kind: CiliumNetworkPolicy
|
|
||||||
metadata:
|
|
||||||
name: siriusdevops-site-egress
|
|
||||||
namespace: siriusdevops
|
|
||||||
spec:
|
|
||||||
endpointSelector:
|
|
||||||
matchLabels:
|
|
||||||
app: siriusdevops-site
|
|
||||||
egress:
|
|
||||||
# Garage S3 API, on a WireGuard-overlay node, port 3900 only.
|
|
||||||
- toEntities:
|
|
||||||
- remote-node
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "3900"
|
|
||||||
protocol: TCP
|
|
||||||
|
|
||||||
# Cluster DNS (CoreDNS) only.
|
|
||||||
- toEndpoints:
|
|
||||||
- matchLabels:
|
|
||||||
io.kubernetes.pod.namespace: kube-system
|
|
||||||
k8s-app: kube-dns
|
|
||||||
toPorts:
|
|
||||||
- ports:
|
|
||||||
- port: "53"
|
|
||||||
protocol: UDP
|
|
||||||
- port: "53"
|
|
||||||
protocol: TCP
|
|
||||||
|
|
@ -5,6 +5,3 @@ resources:
|
||||||
- ../base/siriusdevops
|
- ../base/siriusdevops
|
||||||
- ../base/piedmont
|
- ../base/piedmont
|
||||||
- ../base/sirius-growth
|
- ../base/sirius-growth
|
||||||
- ../base/osint
|
|
||||||
- ../base/metabase
|
|
||||||
- ../base/customer1
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
# NOT RECONCILED. The bootstrapped `flux-system` Kustomization reads
|
|
||||||
# ./clusters/homek8s (see clusters/homek8s/flux-system/gotk-sync.yaml), so
|
|
||||||
# nothing in this directory is ever applied. It is kept only as a placeholder;
|
|
||||||
# add Flux Kustomizations under clusters/homek8s/ instead. (Until 2026-10-27
|
|
||||||
# the `monitoring` Kustomization lived only here, which is why it never
|
|
||||||
# existed on the cluster.)
|
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
resources:
|
resources:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,3 @@ 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
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
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
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
|
||||||
kind: Kustomization
|
|
||||||
metadata:
|
|
||||||
name: databases
|
|
||||||
namespace: flux-system
|
|
||||||
spec:
|
|
||||||
interval: 10m0s
|
|
||||||
retryInterval: 1m
|
|
||||||
timeout: 5m
|
|
||||||
sourceRef:
|
|
||||||
kind: GitRepository
|
|
||||||
name: flux-system
|
|
||||||
path: ./infrastructure/databases/base
|
|
||||||
# The CloudNativePG operator bundle contains its 11 CRDs, and the vendored
|
|
||||||
# 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
|
|
||||||
# reasoning as gateway-api-crds. Reverting the operator Deployment args is a
|
|
||||||
# git change, not a prune.
|
|
||||||
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
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
|
||||||
kind: Kustomization
|
|
||||||
metadata:
|
|
||||||
name: monitoring
|
|
||||||
namespace: flux-system
|
|
||||||
spec:
|
|
||||||
interval: 1m0s
|
|
||||||
retryInterval: 1m
|
|
||||||
timeout: 15m
|
|
||||||
sourceRef:
|
|
||||||
kind: GitRepository
|
|
||||||
name: flux-system
|
|
||||||
path: ./monitoring/controllers/home
|
|
||||||
prune: true
|
|
||||||
dependsOn:
|
|
||||||
- name: infrastructure
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,978 +0,0 @@
|
||||||
---
|
|
||||||
title: Home Lab Kubernetes Cluster — Current State
|
|
||||||
created: 2026-10-26
|
|
||||||
updated: 2026-10-26
|
|
||||||
author: Lance Walters (written with Hermes devops agent)
|
|
||||||
tags: [homelab, kubernetes, kubeadm, wireguard, cilium, forgejo, garage]
|
|
||||||
status: current
|
|
||||||
verified: 2026-10-26T19:17Z
|
|
||||||
---
|
|
||||||
|
|
||||||
# Home Lab Kubernetes Cluster — Current State
|
|
||||||
|
|
||||||
> **Provenance.** Everything marked *(live)* was read off the running cluster or hosts on **2026-10-26 between 19:00 and 19:17 UTC**. Anything not marked live comes from the GitOps repo `sirius/homek8s` at commit `bd5057c` or from the `home-k8s` Hermes skill, and is labelled as such. Section 10 is the command log. Where the skill and reality disagree, **reality is written here** and the disagreement is listed in §9.3.
|
|
||||||
|
|
||||||
Related: [[WireGuard Mesh]], [[Home Lab Runbook]], [[Pi Reboot Recovery]]
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. At a glance
|
|
||||||
|
|
||||||
*(all live)*
|
|
||||||
|
|
||||||
| Property | Value |
|
|
||||||
|---|---|
|
|
||||||
| Nodes | **3** — `siriussec` (control-plane + worker), `rpi` (worker / network edge), `linode` (worker, remote cloud) |
|
|
||||||
| Kubernetes | `v1.36.4` on all three, kubeadm-bootstrapped, single control plane |
|
|
||||||
| API endpoint | `https://10.10.0.2:6443` — WireGuard overlay address only |
|
|
||||||
| CNI | Cilium **v1.20.1** (Helm-managed by Flux), kube-proxy replacement, **native routing** (`ipv4NativeRoutingCIDR: 10.244.0.0/16`, `autoDirectNodeRoutes`), no VXLAN in the data path |
|
|
||||||
| Gateway API | Cilium Gateway, hostNetwork Envoy on nodes labelled `node-role.kubernetes.io/gateway=true` |
|
|
||||||
| Pod network | `10.244.0.0/16`, /24 per node: siriussec `10.244.0.0/24`, rpi `10.244.1.0/24`, linode `10.244.2.0/24` |
|
|
||||||
| Service network | `10.96.0.0/12` |
|
|
||||||
| Storage | `local-path` (rancher.io/local-path, default SC, provisioner pinned to siriussec), data under `/opt/local-path-provisioner` |
|
|
||||||
| GitOps | Flux v2 (`source`, `kustomize`, `helm`, `notification` controllers), watching `sirius/homek8s` `master`, applied revision `bd5057c` |
|
|
||||||
| Databases | CloudNativePG **1.30.0**, two clusters: `forgejo/pg` (10Gi) and `sirius-growth/portal` (5Gi) |
|
|
||||||
| Public ingress | Cloudflare tunnel **`sirius home`** → `cloudflared` (systemd on rpi) → `http://10.10.0.2:8080` |
|
|
||||||
| Workloads | **31 running pods** across 9 namespaces, plus 6 completed pods (CI prune jobs and leftovers) |
|
|
||||||
| Metrics | **none** — `metrics-server` is not installed, `kubectl top` fails *(live: `error: Metrics API not available`)* |
|
|
||||||
|
|
||||||
**In one paragraph.** This is a three-node kubeadm cluster stitched together over WireGuard rather than a LAN. The T480 (`siriussec`) is the control plane and does the heavy lifting — app pods, databases, Forgejo, the AMD64 CI runner all live there because it is the only `amd64` box with real disk. The Raspberry Pi (`rpi`) is the network edge: it is the WireGuard hub, the Cloudflare tunnel host, and the ARM64 CI runner. The Linode VPS (`linode`) rejoined as a third worker on 2026-10-26 and carries pod CIDR `10.244.2.0/24` over the Pi's `wg-remote` tunnel. There is no VXLAN and no kube-proxy: Cilium routes pod traffic natively, so every node must be reachable at its pod CIDR over WireGuard, and the API server is firewalled to the overlay plus pod CIDR only.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. Topology
|
|
||||||
|
|
||||||
*(live — `kubectl get nodes -o wide`, node JSON)*
|
|
||||||
|
|
||||||
| Node | Hardware | OS / kernel | Arch | LAN | Overlay | Pod CIDR | Roles / labels | Taints |
|
|
||||||
|---|---|---|---|---|---|---|---|---|
|
|
||||||
| `siriussec` | ThinkPad T480 | Arch Linux, `6.18.50-2-lts` | amd64 | `192.168.1.179` (`enp0s31f6`) | `10.10.0.2` (`wg0`) | `10.244.0.0/24` | `control-plane`, `worker`, `gateway=true`, `node-role…/gateway=true`, `exclude-from-external-load-balancers` | **none** |
|
|
||||||
| `rpi` | Raspberry Pi (8 GiB) | Debian 13 trixie, `6.18.39+rpt-rpi-2712` | arm64 | `192.168.1.125` (`eth0`) | `10.10.0.1` (`wg0`), `10.20.0.2` (`wg-remote`) | `10.244.1.0/24` | `worker`, `node-role…/traffic`, `dedicated=network` (**no** `gateway=true` since 2026-10-27) | **none** |
|
|
||||||
| `linode` | Linode VPS, Atlanta | Debian 13 trixie, `6.12.113+deb13-amd64` | amd64 | public `50.116.38.217` | `10.10.0.5` (`dummy-k8s`), `10.20.0.1` (`wg0`, hub role) | `10.244.2.0/24` | `dedicated=network` | **none** |
|
|
||||||
|
|
||||||
Node conditions are clean on all three: `Ready=True`, `MemoryPressure/DiskPressure/PIDPressure/NetworkUnavailable=False` *(live)*.
|
|
||||||
|
|
||||||
### 2.1 What the roles actually mean
|
|
||||||
|
|
||||||
**`siriussec` — control plane and the only real compute node.** Runs `kube-apiserver`, `etcd`, `kube-controller-manager`, `kube-scheduler` as static pods, plus every application pod, both CNPG database instances, Forgejo, and the AMD64 CI runner. There is deliberately **no** `NoSchedule` taint on the control plane so it can also be a worker. It sits on the API-over-WireGuard side: `:6443` is reachable only from `lo`, `wg0`, and the pod CIDR (§3.4).
|
|
||||||
|
|
||||||
**`rpi` — network edge, not app compute.** WireGuard hub, `cloudflared` tunnel host, ARM64 CI runner (two runners, actually), and Gateway node. The skill says `rpi` carries `dedicated=network:PreferNoSchedule`; **live, it carries the label but no taint** *(drift, §9.3)*. Pods that must not land there still pin by `nodeSelector` rather than relying on the taint.
|
|
||||||
|
|
||||||
**`linode` — a real kubeadm worker again.** It runs a full Cilium agent and has pod CIDR `10.244.2.0/24`. It is **not** a `wg0` peer of the Pi: it is reached over the Pi's `wg-remote` interface (`10.20.0.2` ↔ `10.20.0.1`) with a static route for its pod CIDR. See §3.2.
|
|
||||||
|
|
||||||
### 2.2 Pinning rules (live, from Deployment specs)
|
|
||||||
|
|
||||||
| Rule | Who uses it | Why |
|
|
||||||
|---|---|---|
|
|
||||||
| `nodeSelector: kubernetes.io/hostname: siriussec` | `forgejo`, `forgejo-runner-amd64`, `local-path-provisioner`, `piedmont-*`, `sirius-growth-*`, `siriusdevops-*`, `cilium-operator` | amd64 images; rpi is arm64, and the PVs live on siriussec's NVMe |
|
|
||||||
| `nodeSelector: kubernetes.io/hostname: rpi` | `forgejo-runner-arm64`, `forgejo-runner-deploy-arm64` | needs the Pi's Docker socket and arm64 host |
|
|
||||||
| label `dedicated=network` (on rpi and linode) | none currently — both are labellable targets for future network/light pods | intended for traffic/edge workloads |
|
|
||||||
| `node-role.kubernetes.io/gateway=true` (**siriussec only**; rpi lost it 2026-10-27, linode never had it) | `cilium-envoy` DaemonSet | Gateway listeners follow the label. Exactly one node must carry it: a gateway node that does not run the backend pods binds the ports and answers **503 after 5 s** for everything |
|
|
||||||
|
|
||||||
Several app Deployments also carry a stray `tolerations: [{key: dedicated, effect: PreferNoSchedule}]` — harmless today because no node has that taint; it is residue from when rpi was tainted.
|
|
||||||
|
|
||||||
**Why apps are pinned to `siriussec` and not spread:** the PVs are `local-path` on siriussec's `/opt/local-path-provisioner`, so a pod with a PVC cannot move. The public site images are `amd64` only, and rpi is arm64. All three production site namespaces and both databases therefore live on one machine — that is a deliberate, documented single point of failure, not an oversight.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. WireGuard
|
|
||||||
|
|
||||||
### 3.1 Two hubs, three paths
|
|
||||||
|
|
||||||
There are **two independent WireGuard topologies** in play, and conflating them is the classic mistake here.
|
|
||||||
|
|
||||||
```
|
|
||||||
┌───────────────────────────────────────────┐
|
|
||||||
│ rpi (LAN 192.168.1.125) │
|
|
||||||
│ wg0 10.10.0.1/24 ← MESH HUB │
|
|
||||||
│ wg-remote 10.20.0.2/24 ← spoke of the │
|
|
||||||
│ Linode hub │
|
|
||||||
└───────┬───────────────────────┬───────────┘
|
|
||||||
wg0 (10.10.0.2/32) │ │ wg-remote (UDP 49194)
|
|
||||||
PSK, endpoint │ │ → 50.116.38.217:51820
|
|
||||||
192.168.1.179:50013 │ ▼
|
|
||||||
┌─────────────▼──────────┐ ┌──────────────────────────┐
|
|
||||||
│ siriussec 10.10.0.2 │ │ linode 10.20.0.1/24 │
|
|
||||||
│ (cluster API :6443) │ │ REMOTE HUB (wg0 :51820) │
|
|
||||||
└────────────────────────┘ │ dummy-k8s 10.10.0.5/32 │
|
|
||||||
│ node, pod 10.244.2.0/24 │
|
|
||||||
┌────────────────────────┐ └───────┬───────────┬──────┘
|
|
||||||
│ Legion (laptop) │ │ │
|
|
||||||
│ k8snet 10.10.0.3/32 │ 10.20.0.3 10.20.0.5 + 10.10.0.3
|
|
||||||
│ admin kubectl only │ (phone) (Legion's hub-side leg)
|
|
||||||
│ NOT a node │ │
|
|
||||||
└────────────────────────┘ 10.20.0.4 + 10.10.0.6 (SG VPS + its pod CIDR 10.244.3.0/24)
|
|
||||||
```
|
|
||||||
|
|
||||||
*(live — `wg show` on rpi, `wg show wg0` on siriussec, `wg show wg0` on linode)*
|
|
||||||
|
|
||||||
**Mesh hub — `wg0` on rpi, `10.10.0.1/24`, UDP 51820.** Public key `tvPloMcBwTDciWi5WbFDpQQ2xcgidcKzRI/G3IqeuCQ=`. Peers:
|
|
||||||
|
|
||||||
| Mesh addr | Peer | Endpoint seen | Handshake (live) | AllowedIPs on hub | Notes |
|
|
||||||
|---|---|---|---|---|---|
|
|
||||||
| `10.10.0.2/32` | **siriussec** | `192.168.1.179:50013` | 1 min ago | `10.10.0.2/32, 10.244.0.0/24` | PSK enabled; 301 GiB in / 12.7 GiB out |
|
|
||||||
| `10.10.0.3/32` | **Legion** (`k8snet`) | `192.168.1.126:52000` | 48 min ago | `10.10.0.3/32` | admin/kubectl spoke, on the LAN; PSK enabled |
|
|
||||||
| `10.10.0.4/32` | unnamed spoke | `100.91.7.84:44094` (Tailscale) | **6 days 5 h ago** | `10.10.0.4/32` | **stale** — peer defined but effectively dead |
|
|
||||||
|
|
||||||
`wg show wg0 dump | wc -l` = **4** (header + 3 peers) *(live)*.
|
|
||||||
|
|
||||||
**Remote hub — `wg0` on the Linode, `10.20.0.1/24`, UDP 51820.** Public key `/2Y0XpJYd9Vl9Al6zNAlQimEYA+xY9Y5PO6nUDkfKEA=`. Peers *(live)*:
|
|
||||||
|
|
||||||
| Hub addr | Peer | AllowedIPs | Handshake |
|
|
||||||
|---|---|---|---|
|
|
||||||
| `10.20.0.2/32` | **rpi** (`wg-remote`, pubkey `h1v1Rhrnq2N2kt454xQamL1Y1x0TaICa1zoKgyZHpkM=`) | `10.20.0.2/32, 10.10.0.0/24, 10.96.0.0/12, 10.244.0.0/16` | ~1 min |
|
|
||||||
| `10.20.0.3/32` | phone | `10.20.0.3/32` | ~43 s |
|
|
||||||
| `10.20.0.5/32` + `10.10.0.3/32` | Legion (hub-side leg) | `10.20.0.5/32, 10.10.0.3/32` | ~1 min |
|
|
||||||
| `10.20.0.4/32` + `10.10.0.6/32` | SG VPS | `10.20.0.4/32, 10.10.0.6/32, 10.244.3.0/24` | *(no handshake shown — idle)* |
|
|
||||||
|
|
||||||
**Pi's `wg-remote` side** (`10.20.0.2/24`, local UDP 49194) has exactly one peer, the Linode hub, with `AllowedIPs = 10.20.0.0/24, 10.10.0.5/32, 10.244.2.0/24` and a 25 s keepalive. That single line is why `10.10.0.5` (the Linode node's dummy address) and the Linode pod CIDR are reachable from the Pi at all.
|
|
||||||
|
|
||||||
### 3.2 Address plan and AllowedIPs
|
|
||||||
|
|
||||||
- **Mesh `10.10.0.0/24`** — the cluster's transport network. Node InternalIPs are `10.10.0.1/.2/.5`; the API is `10.10.0.2:6443`.
|
|
||||||
- **Remote hub `10.20.0.0/24`** — the Linode's hub addressing, plus phone and SG VPS spokes that never touch the mesh directly.
|
|
||||||
- **Spoke AllowedIPs are `10.10.0.0/24, 10.244.0.0/16`**, not a full tunnel — client traffic to the internet never traverses the Pi. siriussec's conf is exactly `Address = 10.10.0.2/32`, `Endpoint = 192.168.1.125:51820`, `AllowedIPs = 10.10.0.0/24, 10.244.0.0/16` *(live)*.
|
|
||||||
- **Pod CIDRs must be in some peer's AllowedIPs.** WireGuard cryptokey routing matches the *destination address*, so `autoDirectNodeRoutes` is useless unless the peer line covers the destination pod CIDR. That is why the hub's peer entries carry `10.244.x.0/24`, and why the Linode hub carries `10.96.0.0/12` and `10.244.0.0/16` toward the Pi.
|
|
||||||
|
|
||||||
### 3.3 Why the mesh exists at all
|
|
||||||
|
|
||||||
There is no flat L2 between the T480, the Pi and a cloud VPS. Two properties force the overlay:
|
|
||||||
|
|
||||||
1. **Cilium native routing has no encapsulation.** With `routing-mode: native` and no VXLAN, a pod on siriussec addressed as `10.244.1.x` is sent as a plain packet, and the node must have a route to it. WireGuard supplies that route (`ip route get <podIP>` → `via 10.10.0.1 dev wg0`).
|
|
||||||
2. **The API server is firewalled to the overlay.** On siriussec, `/etc/nftables.d/k8s-api.nft` (loaded by `k8s-api-firewall.service`, active) is:
|
|
||||||
```
|
|
||||||
tcp dport 6443 iifname "lo" accept
|
|
||||||
tcp dport 6443 iifname "wg0" accept
|
|
||||||
ip saddr 10.244.0.0/16 tcp dport 6443 accept
|
|
||||||
tcp dport 6443 drop
|
|
||||||
```
|
|
||||||
*(live)* — so joins, kubelets and in-cluster controllers must arrive over `wg0` or from the pod network. LAN `192.168.1.179:6443` is closed by design.
|
|
||||||
|
|
||||||
### 3.4 The `10.10.0.0/24` route-conflict hazard
|
|
||||||
|
|
||||||
On the Pi the prefix `10.10.0.0/24` is claimed **twice**: by `wg0` (interface address `10.10.0.1/24`) and by `wg-remote`'s peer AllowedIPs (`10.10.0.0/24` toward the Linode, needed for the `10.10.0.5` dummy address). The kernel prefers `wg-remote`, which silently black-holes the Pi's path to the API while every tunnel still shows "up".
|
|
||||||
|
|
||||||
The installed fix is `/32` pins on the hub's own peers:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
sudo ip route replace 10.10.0.2/32 dev wg0
|
|
||||||
sudo ip route replace 10.10.0.4/32 dev wg0
|
|
||||||
# 10.10.0.5 stays on wg-remote — it is the Linode's dummy address
|
|
||||||
```
|
|
||||||
|
|
||||||
*(live, current state)*
|
|
||||||
```
|
|
||||||
$ ip route get 10.10.0.2 → 10.10.0.2 dev wg0 src 10.10.0.1
|
|
||||||
$ ip route get 10.10.0.5 → 10.10.0.5 dev wg-remote src 10.20.0.2
|
|
||||||
$ ip route get 10.10.0.3 → 10.10.0.3 dev wg0 src 10.10.0.1
|
|
||||||
```
|
|
||||||
|
|
||||||
Persisted by `wg0-routes.service` on the Pi (oneshot, `[email protected] [email protected]`, `Before=kubelet.service`, **no `Requires=`** so a manually-started wg0 does not fail the unit).
|
|
||||||
|
|
||||||
### 3.5 wg-quick unit state *(live, and it matters)*
|
|
||||||
|
|
||||||
| Host | Unit | enabled | active |
|
|
||||||
|---|---|---|---|
|
|
||||||
| rpi | `wg-quick@wg0` | **enabled** | **inactive** (interface was brought up manually) |
|
|
||||||
| rpi | `wg-quick@wg-remote` | enabled | active |
|
|
||||||
| rpi | `cloudflared` | enabled | active |
|
|
||||||
| siriussec | `wg-quick@wg0` | enabled | **inactive** (interface present, started manually) |
|
|
||||||
| linode | `wg-quick@wg0` | enabled | active |
|
|
||||||
|
|
||||||
`wg0` on both rpi and siriussec is up but its unit is inactive — expected, because the interfaces were started with `wg-quick up` directly. Do **not** "fix" this by cycling the systemd unit: `/etc/wireguard/wg0.conf` on the Pi is **wgportal-autogenerated** with `SaveConfig = true`, so `systemctl stop` rewrites the file from the live interface and can drop peers.
|
|
||||||
|
|
||||||
### 3.6 Health checks, hop by hop
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# On the Pi
|
|
||||||
sudo wg show # both interfaces, handshake ages
|
|
||||||
sudo wg show wg0 dump | wc -l # 4 = header + 3 peers
|
|
||||||
ip route get 10.10.0.2 # must say dev wg0
|
|
||||||
ip route get 10.10.0.5 # must say dev wg-remote
|
|
||||||
curl -sk https://10.10.0.2:6443/version # 200 = API reachable over the mesh
|
|
||||||
kubectl get nodes # 3/3 Ready
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3.7 Peer management — wgportal is **not** running
|
|
||||||
|
|
||||||
The skill describes `wgportal/wg-portal:v2` as the peer manager on the Pi. **Live: there is no `wg-portal` container and no systemd unit.** `/opt/wgportal/` still holds `docker-compose.yml`, `config/`, `data/` (sqlite) and `ADMIN.txt`, and `/etc/wireguard/wg0.conf` still carries the wgportal `AUTOGENERATED FILE - DO NOT EDIT` header — but nothing is running it. **Peer changes today are manual**, applied to `/etc/wireguard/wg0.conf` (and the live interface) by hand. This is a real operational gap, not a documentation detail: there is currently no UI or API to add a peer.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. Ingress path
|
|
||||||
|
|
||||||
```
|
|
||||||
Internet
|
|
||||||
│ Cloudflare TLS (DNS + edge)
|
|
||||||
▼
|
|
||||||
Cloudflare Tunnel "sirius home" (id 6d0702eb-99cc-4062-b57d-e70e2f1a7895, healthy, 4 connections)
|
|
||||||
│
|
|
||||||
▼
|
|
||||||
cloudflared (systemd on rpi, token-managed via /etc/systemd/system/cloudflared.service)
|
|
||||||
│ HTTP, origin override per hostname
|
|
||||||
▼
|
|
||||||
http://10.10.0.2:8080 ← siriussec
|
|
||||||
│
|
|
||||||
Cilium Gateway "public" (class cilium, listener http:8080)
|
|
||||||
│ hostNetwork Envoy (DaemonSet cilium-envoy, node-role.kubernetes.io/gateway=true)
|
|
||||||
▼
|
|
||||||
HTTPRoute (hostname match, path match) → Service → Pod
|
|
||||||
```
|
|
||||||
|
|
||||||
*(live: tunnel identity from the Cloudflare API, tunnel config from `curl -s http://127.0.0.1:20241/config` on the Pi, gateway/routes from the cluster)*
|
|
||||||
|
|
||||||
### 4.1 The origin is `10.10.0.2:8080` — and only that address serves
|
|
||||||
|
|
||||||
The tunnel's ingress list maps **every** public hostname to `http://10.10.0.2:8080`, with `originRequest.httpHostHeader` set to the hostname so HTTPRoute host matching works. Verified per node from the Pi with a `Host:` header *(live)*:
|
|
||||||
|
|
||||||
| Origin | `Host: siriusdevops.com` | Result |
|
|
||||||
|---|---|---|
|
|
||||||
| `10.10.0.2:8080` (siriussec) | **200** (and 200 for forgejo) | ✅ production origin |
|
|
||||||
| `10.10.0.1:8080` (rpi) | no listener (000 in <1 ms) **since 2026-10-27**; before that, **503 after exactly 5.0 s** | ✗ rpi is not a gateway node any more — no Envoy, no ports |
|
|
||||||
| `10.10.0.5:8080` (linode) | no listener (000) | ✗ no envoy there |
|
|
||||||
|
|
||||||
Note that the `Gateway` **status advertises all three addresses** (`10.10.0.1`, `10.10.0.2`, `10.10.0.5`) even though the label is now on siriussec alone: Cilium fills `status.addresses` with every node InternalIP and ignores `spec.addresses` (cilium#29060). **Do not treat `status.addresses` as a load-balanced VIP or a "try either IP" list** — it is not a list of bound ports either; it is just the node address set. Only `10.10.0.2` has a listener.
|
|
||||||
|
|
||||||
### 4.2 The co-location rule
|
|
||||||
|
|
||||||
Envoy runs `hostNetwork` on the gateway-labelled nodes. **Before 2026-10-27 rpi carried the label too**, so it had a listener on `0.0.0.0:8080` and every request for a mapped hostname **hung 5 s and returned 503** there: the Envoy on rpi forwards to backend pods that live on siriussec's pod CIDR, sources the connection as `reserved:ingress` (`10.244.1.x`), and the SYN-ACK never completes under Cilium native routing. The measurable signature is the exact **5.000 s** and `503`. Fixed by removing the label from rpi (one gateway node, one serving address); the same 5 s/503 signature was making `10.10.0.1:8081`/`:8084` flap for phone clients, and it answered the same way from rpi's own `127.0.0.1`.
|
|
||||||
|
|
||||||
Consequences:
|
|
||||||
|
|
||||||
- **The Envoy that serves traffic must be on the node that holds the backend pods.** All app pods are on siriussec ⇒ the usable origin is siriussec, which is what the tunnel already points at.
|
|
||||||
- Don't "fix" a 503 by rescheduling the site pods to rpi to match the gateway node — they are amd64 images and rpi is arm64.
|
|
||||||
- Don't add a second listener on rpi, don't `ip addr add` the ingress IP on `cilium_host`, don't iptables-SNAT Envoy. BPF bypasses netfilter; those edits look plausible and do nothing.
|
|
||||||
|
|
||||||
### 4.3 503 vs 404
|
|
||||||
|
|
||||||
- **404** = the Gateway has no HTTPRoute for that hostname (or a route's path prefix swallowed it). A Cloudflare-visible 404 on a hostname that *is* in the tunnel's ingress list means "tunnel fine, no route".
|
|
||||||
- **503** = a route exists but its backend Service has no ready endpoints.
|
|
||||||
- `paaas.siriusdevops.com` is currently mapped in the tunnel and returns **404 with 0 bytes** because no HTTPRoute claims it *(live)*.
|
|
||||||
|
|
||||||
### 4.4 Live public hostnames
|
|
||||||
|
|
||||||
*(read from the tunnel's own metrics port on rpi — `curl -s http://127.0.0.1:20241/config`)*
|
|
||||||
|
|
||||||
| Hostname | Origin | HTTPRoute | Status (live origin check) |
|
|
||||||
|---|---|---|---|
|
|
||||||
| `siriusdevops.com` | `http://10.10.0.2:8080` | `siriusdevops/siriusdevops` | 200, 31813 B |
|
|
||||||
| `www.siriusdevops.com` | `http://10.10.0.2:8080` | same | 200 |
|
|
||||||
| `forgejo.siriusdevops.com` | `http://10.10.0.2:8080` | `forgejo/forgejo` | 200, 15008 B |
|
|
||||||
| `paaas.siriusdevops.com` | `http://10.10.0.2:8080` | **none** | **404** (0 B) |
|
|
||||||
| `piedmonthomesvc.com` | `http://10.10.0.2:8080` | `piedmont/piedmont` | 200, 7067 B |
|
|
||||||
| `www.piedmonthomesvc.com` | `http://10.10.0.2:8080` | same | 200 |
|
|
||||||
| `siriusgrowthsolutions.com` | `http://10.10.0.2:8080` | `sirius-growth/sirius-growth` | 200, 72640 B |
|
|
||||||
| `www.siriusgrowthsolutions.com` | `http://10.10.0.2:8080` | same | 200 |
|
|
||||||
| *(catch-all)* | `http_status: 404` | — | must stay last |
|
|
||||||
|
|
||||||
A second, **inactive** tunnel named `piedmonthomesvc` (`bdcee200-7deb-4c8d-956b-2c030ebf7545`) still exists in the Cloudflare account, with zero connections. Only `sirius home` serves traffic; do not create another.
|
|
||||||
|
|
||||||
### 4.5 Routes as configured *(live, `kubectl get httproute -A -o json`)*
|
|
||||||
|
|
||||||
All four routes attach to `gateway-system/public`. First-match path ordering matters — the `/api/contact` rule comes **before** `/`:
|
|
||||||
|
|
||||||
| Route | Path → backend |
|
|
||||||
|---|---|
|
|
||||||
| `forgejo/forgejo` | `/` → `forgejo:3000` |
|
|
||||||
| `siriusdevops/siriusdevops` | `/api/contact` → `siriusdevops-contact:8090`; `/` → `siriusdevops-site:80` |
|
|
||||||
| `piedmont/piedmont` | `/api/contact` → `piedmont-contact:8090`; `/` → `piedmont-site:80` |
|
|
||||||
| `sirius-growth/sirius-growth` | `/api/contact` → `sirius-growth-contact:8090`; `/api/portal` → `sirius-growth-portal:8091`; `/` → `sirius-growth-site:80` |
|
|
||||||
|
|
||||||
A single `ReferenceGrant` exists (`gateway-system/forgejo`) for the cross-namespace route.
|
|
||||||
|
|
||||||
### 4.6 Second gateway: `internal`
|
|
||||||
|
|
||||||
`internal/internal` (namespace `internal`) and `internal/hubble-ui` are Cilium Gateways on **port 8081** and **8084**, `allowedRoutes: All`, with no tunnel mapping. It carries the WireGuard-only services. Both are reachable **by bare IP** (phones cannot edit `/etc/hosts`): **Grafana** `http://10.10.0.2:8081/` and **Hubble UI** `http://10.10.0.2:8084/`; the named URLs (`grafana.lab.internal`, `hubble.lab.internal`) are laptop conveniences only. Hubble UI has its own `Gateway internal/hubble-ui` because Cilium merges hostname-less routes that share a Gateway. The enforcement point is the *host* firewall on both gateway nodes (nft `table inet internal_gw` on siriussec, ufw rules above the LAN catch-all on rpi), not the Gateway: a listener port is reachable on every node address the moment it is Programmed. Full pattern, negative tests and the add-next-service recipe: `docs/internal-wireguard-services.md`.
|
|
||||||
|
|
||||||
Neither hostname is in the cloudflared ingress list, and `*.lab.internal` resolves nowhere public — `Host: <name>.lab.internal` on the public gateway (`10.10.0.2:8080`) answers **404**.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. Garage object storage
|
|
||||||
|
|
||||||
*(live — Docker container on the Pi, `garage status`, `garage bucket list`)*
|
|
||||||
|
|
||||||
**What it is:** the homelab's S3-compatible object store, used for photo and client-file buckets behind the public sites.
|
|
||||||
|
|
||||||
| Property | Value |
|
|
||||||
|---|---|
|
|
||||||
| Where | **Docker container on `rpi`**, not in Kubernetes — image `dxflrs/garage:v1.1.0`, container `garage` |
|
|
||||||
| Compose | **`infrastructure/garage/` in this repo** (installed to `/etc/garage/docker-compose.yml`); state stays at `/home/sirius/websites/garage/`. Flux does not apply it — see that directory's README |
|
|
||||||
| State | `data/` (bind → `/data/data`) and `meta/` (bind → `/data/meta`); config `/etc/garage/garage.toml`, RPC secret `/etc/garage/garage.env` (0600, not in git) |
|
|
||||||
| Ports | `10.10.0.1:3900` S3 API and `10.10.0.1:3903` metrics (WireGuard only), `127.0.0.1:3900` host-local. No `0.0.0.0` publish. 3901 (RPC) and 3902 (`[s3_web]`) are no longer published at all |
|
|
||||||
| Firewall | `host/garage-firewall.nft` — nftables PREROUTING priority -140 drop for 3900-3903 from anything but `lo`/`wg0`/`wg-remote`. Docker's DNAT bypasses ufw's INPUT chain, so ufw alone cannot stop a compose typo |
|
|
||||||
| Capacity | 100 GB configured; `354.3 GB (36.0%)` data available (single healthy node `d053db4dfc97bf78`) |
|
|
||||||
| Buckets | `sirius-growth-photos`, `piedmont-photos`, `siriusdevops-media`, `sirius-growth-blog-media`, `sirius-growth-client-files` |
|
|
||||||
| Keys | one per consumer — `ci-push` (W only) and `site-fetch` (R only) on `siriusdevops-media`; the shared `ci-key` was deleted 2026-11-19 |
|
|
||||||
| Backup | hourly `meta` snapshot + nightly `data` rsync to `[email protected]:/root/garage-backup` (systemd timers) |
|
|
||||||
| Metrics | Prometheus target `job="garage"` scraping `10.10.0.1:3903`, `monitoring/controllers/home/garage.yaml` |
|
|
||||||
|
|
||||||
**Exposure model:** every published port binds an explicit address, and the host firewall drops the rest before Docker can rewrite the packet. A pod on siriussec reaches the S3 API at `http://10.10.0.1:3900` over the mesh; the LAN and the internet see nothing (measured off-mesh from the Linode node: all of 3900-3903 filtered).
|
|
||||||
|
|
||||||
**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
|
|
||||||
|
|
||||||
*(live — `kubectl get pods -A -o wide` at 19:0x UTC. **31 Running**, 6 Completed. This table is the running set, 31 rows.)*
|
|
||||||
|
|
||||||
### 6.1 Running pods
|
|
||||||
|
|
||||||
| # | Namespace | Pod | Node | IP | Purpose | Exposure |
|
|
||||||
|---|---|---|---|---|---|---|
|
|
||||||
| 1 | cnpg-system | `cnpg-controller-manager-78484bd58d-m6rtk` | siriussec | 10.244.0.183 | CloudNativePG operator (1.30.0) | internal |
|
|
||||||
| 2 | flux-system | `helm-controller-5788b55f98-zzgmw` | siriussec | 10.244.0.210 | Flux HelmRelease reconciler | internal |
|
|
||||||
| 3 | flux-system | `kustomize-controller-645cdc4b67-r2gl6` | siriussec | 10.244.0.30 | Flux kustomize reconciler (applies all YAML) | internal |
|
|
||||||
| 4 | flux-system | `notification-controller-7cd6d4994b-drh8x` | siriussec | 10.244.0.125 | Flux alerts/webhooks | internal |
|
|
||||||
| 5 | flux-system | `source-controller-56549698b5-2lvmc` | siriussec | 10.244.0.44 | Flux git artifact fetcher | internal |
|
|
||||||
| 6 | forgejo | `forgejo-67847d596c-jpb7x` | siriussec | 10.244.0.197 | Forgejo **16.0.5** git/CI/registry UI | **public** `forgejo.siriusdevops.com` |
|
|
||||||
| 7 | forgejo | `forgejo-runner-amd64-65fdfdf884-bb88l` | siriussec | 10.244.0.17 | Actions runner (dind sidecar), labels `docker-amd64`, `amd64` | internal |
|
|
||||||
| 8 | forgejo | `forgejo-runner-arm64-7566647d9f-7q2wk` | rpi | 10.244.1.128 | Actions runner via Pi host Docker socket, labels `docker-arm64`, `arm64`, `docker` | internal |
|
|
||||||
| 9 | forgejo | `forgejo-runner-deploy-arm64-b748d7c6f-66r5j` | rpi | 10.244.1.167 | Actions runner, label **`deploy-arm64` only** (site deploys) | internal |
|
|
||||||
| 10 | forgejo | `pg-1` | siriussec | 10.244.0.159 | CNPG PostgreSQL for Forgejo (1 instance) | internal |
|
|
||||||
| 11 | kube-system | `cilium-cz7w6` | siriussec | 10.10.0.2 (host-net) | Cilium agent v1.20.1 | internal |
|
|
||||||
| 12 | kube-system | `cilium-dswfb` | rpi | 10.10.0.1 (host-net) | Cilium agent v1.20.1 | internal |
|
|
||||||
| 13 | kube-system | `cilium-lst6f` | linode | 10.10.0.5 (host-net) | Cilium agent v1.20.1 | internal |
|
|
||||||
| 14 | kube-system | ~~`cilium-envoy-kfd7w`~~ | ~~rpi~~ | — | **gone 2026-10-27** — rpi lost `gateway=true`; a gateway node that cannot reach the backends only served 5 s/503 (§4.2) | — |
|
|
||||||
| 15 | kube-system | `cilium-envoy-q2jn8` | siriussec | 10.10.0.2 (host-net) | Gateway data plane — **the one serving public traffic** | **public** (8080) |
|
|
||||||
| 16 | kube-system | `cilium-operator-6fc68c64d6-cw4rj` | siriussec | 10.244.0.2x | Cilium operator (leader election) | internal |
|
|
||||||
| 17 | kube-system | `coredns-589f44dc88-l28hh` | siriussec | 10.244.0.109 | cluster DNS (1 of 2) | internal |
|
|
||||||
| 18 | kube-system | `coredns-589f44dc88-xtzqq` | siriussec | 10.244.0.114 | cluster DNS (2 of 2) | internal |
|
|
||||||
| 19 | kube-system | `etcd-siriussec` | siriussec | 10.10.0.2 (host-net) | cluster datastore (static pod) | internal |
|
|
||||||
| 20 | kube-system | `kube-apiserver-siriussec` | siriussec | 10.10.0.2 (host-net) | API server `:6443` (static pod) | overlay + pod CIDR only |
|
|
||||||
| 21 | kube-system | `kube-controller-manager-siriussec` | siriussec | 10.10.0.2 (host-net) | controller manager (static pod) | internal |
|
|
||||||
| 22 | kube-system | `kube-scheduler-siriussec` | siriussec | 10.10.0.2 (host-net) | scheduler (static pod) | internal |
|
|
||||||
| 23 | local-path-storage | `local-path-provisioner-84f56599d-p9d6x` | siriussec | 10.244.0.63 | dynamic local PV provisioning | internal |
|
|
||||||
| 24 | piedmont | `piedmont-contact-7897cf4d4-z764g` | siriussec | 10.244.0.86 | PHS contact-form API (Telegram) | `/api/contact` on `piedmonthomesvc.com` |
|
|
||||||
| 25 | piedmont | `piedmont-site-66cbdd498d-tx2gc` | siriussec | 10.244.0.94 | PHS static site (nginx) | `piedmonthomesvc.com` |
|
|
||||||
| 26 | sirius-growth | `portal-1` | siriussec | 10.244.0.173 | CNPG PostgreSQL for SGS portal (1 instance) | internal |
|
|
||||||
| 27 | sirius-growth | `sirius-growth-contact-5448485967-n2flh` | siriussec | 10.244.0.219 | SGS contact API | `/api/contact` on `siriusgrowthsolutions.com` |
|
|
||||||
| 28 | sirius-growth | `sirius-growth-portal-89d598f55-pwf74` | siriussec | 10.244.0.146 | SGS customer portal (`:8091`) | `/api/portal` |
|
|
||||||
| 29 | sirius-growth | `sirius-growth-site-757d4f96b6-wcnpn` | siriussec | 10.244.0.170 | SGS marketing site (nginx) | `siriusgrowthsolutions.com` |
|
|
||||||
| 30 | siriusdevops | `siriusdevops-contact-b5df76cd4-b98sb` | siriussec | 10.244.0.244 | SiriusDevOps contact API | `/api/contact` on `siriusdevops.com` |
|
|
||||||
| 31 | siriusdevops | `siriusdevops-site-566968fffb-52z5n` | siriussec | 10.244.0.85 | SiriusDevOps site (nginx) | `siriusdevops.com` |
|
|
||||||
|
|
||||||
Nothing runs on `linode` except its Cilium agent. `rpi` runs only the two runners plus its Cilium/Envoy agents.
|
|
||||||
|
|
||||||
### 6.2 Completed / non-running pods (6)
|
|
||||||
|
|
||||||
`forgejo/forgejo-67847d596c-xn2br` (old ReplicaSet, `Completed`, 42 d — harmless residue), three `forgejo-runner-prune-*` Job pods (the nightly docker-prune CronJob), and `kube-system/{curl-test,test}` (41 d one-off probes).
|
|
||||||
|
|
||||||
### 6.3 Namespaces
|
|
||||||
|
|
||||||
| Namespace | Age | Contents |
|
|
||||||
|---|---|---|
|
|
||||||
| `kube-system` | 45 d | control plane, Cilium, Envoy, CoreDNS, hubble-relay + hubble-ui |
|
|
||||||
| `kube-public`, `kube-node-lease`, `default` | 45 d | kubeadm defaults |
|
|
||||||
| `forgejo` | 45 d | Forgejo, its CNPG cluster, 3 runners, prune CronJob |
|
|
||||||
| `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 |
|
|
||||||
| `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` |
|
|
||||||
| `internal` | 41 d | Gateways `internal` (8081) and `hubble-ui` (8084) |
|
|
||||||
| `local-path-storage` | 45 d | provisioner |
|
|
||||||
| `siriusdevops` | 43 d | site + contact |
|
|
||||||
| `piedmont` | 26 d | site + contact |
|
|
||||||
| `sirius-growth` | 8 d | site + contact + portal + CNPG cluster |
|
|
||||||
| `cilium-secrets` | 45 d | Gateway TLS/secret sync target |
|
|
||||||
|
|
||||||
### 6.4 Forgejo Actions runners
|
|
||||||
|
|
||||||
**Three** runners, all registered against `https://forgejo.siriusdevops.com` (never an in-cluster URL — the checkout URL must resolve from inside job containers).
|
|
||||||
|
|
||||||
| Deployment | Node | Docker access | `runs-on` labels | Config |
|
|
||||||
|---|---|---|---|---|
|
|
||||||
| `forgejo-runner-arm64` | rpi | Pi **host** socket `/var/run/docker.sock` + host `docker-static` binary + cli-plugins | `docker-arm64`, `arm64`, **`docker`** | CM `forgejo-runner-config` key `arm64.toml`; `capacity 1`; root + privileged; pod `supplementalGroups: [984]`; **no `docker_host`** (would duplicate the socket mount) |
|
|
||||||
| `forgejo-runner-amd64` | siriussec | privileged `docker:27-dind` sidecar, PVC `forgejo-runner-amd64` (20 Gi) | `docker-amd64`, `amd64` | key `amd64.toml`; `capacity 1`; `docker_host: unix:///var/run/docker.sock` |
|
|
||||||
| `forgejo-runner-deploy-arm64` | rpi | Pi host socket, same bind mounts | **`deploy-arm64` only** | key `deploy-arm64.toml`; `capacity 1`; `timeout 30m`; state on hostPath `/opt/siriusdevops/runner-deploy/data` |
|
|
||||||
|
|
||||||
Label discipline that must not be broken:
|
|
||||||
|
|
||||||
- `docker` lives **only** on the Pi arm64 runner, so legacy `runs-on: docker` jobs stay arm64. x86 builds must say `docker-amd64`.
|
|
||||||
- `deploy-arm64` is disjoint from the CI labels in both directions, so a 20–40 minute onionwire Rust build on the shared Pi runner (capacity 1) can no longer starve `deploy-site`. Residual coupling: `deploy-portal.yml` still uses `docker-amd64`, which a site build also uses.
|
|
||||||
- `capacity: 1` everywhere is load-bearing, not conservatism: the amd64 dind is one daemon (two concurrent builds starve and `apt` loops on `Ign:`), and the arm64 runner serialises writes into the shared `onionwire-target-ci` volume.
|
|
||||||
|
|
||||||
Workflow labels actually present in the local checkouts *(live grep of `.forgejo/workflows`)*: `docker` (×8) and `docker-amd64` (×3) in `onionwire`; `deploy-arm64`, `docker-amd64` in `sirius-growth`; `docker-amd64` in `siriusdevops-contact`.
|
|
||||||
|
|
||||||
### 6.5 Nightly disk reclamation (`forgejo/forgejo-runner-prune`)
|
|
||||||
|
|
||||||
`apps/base/forgejo/prune-cronjob.yaml`, `17 4 * * *` **UTC** (the repo's one CronJob timezone convention), `concurrencyPolicy: Forbid`, `startingDeadlineSeconds: 1800`, `backoffLimit: 1`, `activeDeadlineSeconds: 3600`.
|
|
||||||
|
|
||||||
**Two containers, because there are two kinds of daemon.** `host-daemon` (`docker:27-cli`) mounts the Pi's `/var/run/docker.sock`; `dind-daemons` (`alpine/k8s:1.36.4`) discovers in-cluster dind daemons — pods with label `app=forgejo-runner` **that have a container named `dind`** — and runs the same prune logic inside each over the exec API. The ServiceAccount `forgejo-prune` has only `pods get,list` and `pods/exec create` in namespace `forgejo`. No pod names are in the manifest, so the two arm64 dind daemons from the arm64 migration are picked up the first night they exist (proved by creating an unrelated `app=forgejo-runner` dind pod: the job reported `found=2 pruned=2`).
|
|
||||||
|
|
||||||
**Retention.** Exited containers > 48 h, unused **Pi-host** images > 168 h (a week of rollback for the sites). Build cache is capped at **20 GB** on the Pi host and **4 GB** per dind daemon; above the cap the script walks `--filter until=` down from 72 h to 0 s and stops as soon as the cache is under the cap, so the newest layers survive and a cold cache is the last resort. In-cluster images are **dangling-only** pruned: an `until` filter on a *pulled* image compares the upstream build date, so it would delete `node:20-bullseye` / `rust:*-bookworm` every night and make every job cold.
|
|
||||||
|
|
||||||
**Named volumes are never pruned** (`docker volume prune` is forbidden): `onionwire-target-ci` (95.8 GB on the Pi), the Android SDK/Gradle/cargo-registry volumes and the cargo registries are shared CI state. Every run prints `docker system df -v` per daemon so growth is recorded before it becomes an outage. The Pi host currently holds **33 volumes / 169.7 GB, 48.67 GB reclaimable**; capping any of them is a separate decision.
|
|
||||||
|
|
||||||
**Busy guard.** A daemon with a running container is skipped and the Job still exits 0: on the dind daemons *any* running container counts (they have none when idle), on the Pi host a running container younger than 180 min counts (the standing containers — `sirius-growth-site`, `handyman-site`, `garage`, `registry` — are days old, so no name whitelist is needed). A busy night is not a red job; a *missing* night is what alerts.
|
|
||||||
|
|
||||||
Force a run (safe any time; it self-skips when busy):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n forgejo create job --from=cronjob/forgejo-runner-prune prune-manual-$(date +%s)
|
|
||||||
kubectl -n forgejo logs job/prune-manual-<ts> -c host-daemon # Pi daemon
|
|
||||||
kubectl -n forgejo logs job/prune-manual-<ts> -c dind-daemons # every dind daemon
|
|
||||||
```
|
|
||||||
|
|
||||||
**Two premises worth writing down, because the code depends on them** (both verified 2026-10-27):
|
|
||||||
|
|
||||||
- The build-cache *capacity* flags are a no-op on this buildx (0.20.1). `--keep-storage`, `--max-storage` (rejected: unknown flag) and `--max-used-space` all report `Total: 0B` with a cache over the cap — a 21.44 GB cache with `--max-used-space 20GB`, and a 541 MB cache with `--max-used-space 100MB`. `--filter until=` *does* reclaim (541 MB → 0 with `until=0s`), which is why the cap is enforced by walking age windows.
|
|
||||||
- **Per-PVC usage is not measurable on this cluster, and no alert pretends otherwise.** `kubelet_volume_stats_*` was an ALPHA metric set served from kubelet's `/metrics/volumes` endpoint; on kubelet v1.36.4 that endpoint returns **404 on all three nodes** (`/metrics`, `/metrics/probes`, `/metrics/cadvisor`, `/metrics/resource` all return 200) and `/metrics` carries no volume-stats series — the upstream loss in kubelet 1.34 (kubernetes/kubernetes#133847, fix #133890), not a hostPath quirk. There is therefore no scrape config that can produce those series; re-deriving them would need a new exporter parsing kubelet's `/stats/summary` JSON (new Deployment + `nodes/stats` RBAC). The old `RunnerDindPvcHighWatermark` / `RunnerDindPvcCritical` rules were deleted for selecting a metric with no producer, and replaced by runner-scoped filesystem rules — see below. The chart's own per-PVC pair went the same way: kube-prometheus-stack's `kubernetes-storage` group (`KubePersistentVolumeFillingUp`, `KubePersistentVolumeInodesFillingUp`, both severities) used to select `kubelet_volume_stats_*` too, and its four rules are now suppressed with `defaultRules.disabled` in `monitoring/controllers/home/values.yaml` (`KubePersistentVolumeFillingUp: true`, `KubePersistentVolumeInodesFillingUp: true`) — one key disables both severities of a rule. `count(kubelet_volume_stats_used_bytes)` returns **0 series**, and a rule that registers `health=ok, state=inactive` on a missing metric reads as "no PVC is filling" when nothing can fire at all. The group's fifth rule, `KubePersistentVolumeErrors`, is *not* dead (kube-state-metrics `kube_persistentvolume_status_phase`, 40 series here), so it is deliberately left enabled — the group survives with one live rule instead of being dropped whole. Verify with `kubectl -n monitoring get prometheusrule kube-prometheus-stack-kubernetes-storage -o json` (one rule left) and `curl /api/v1/rules`.
|
|
||||||
|
|
||||||
**Alerts** (`PrometheusRule monitoring/forgejo-prune`, label `release: kube-prometheus-stack`): `ForgejoPruneCronJobStale` (last success > 26 h, or the series absent), `ForgejoPruneJobFailed` (`kube_job_status_failed` for `forgejo-runner-prune-*` > 0 — `kube_job_failed` no longer exists), `NodeFilesystemFillingUp` / `NodeFilesystemCritical` (root fs > 85 % / > 92 % per node, joined to the hostname via `node_uname_info`), plus the node-filesystem guards that replaced them: `RunnerDindDiskHighWatermark` / `RunnerDindDiskCritical` (root fs > 80 % / > 90 % on nodes that run a `forgejo-runner` pod — joined node → `node_uname_info.nodename` → `kube_pod_info.node`, rpi excluded), and `RpiDindDataRootFillingUp` (group `dind-disk-cap`, rpi root fs > 70 %, because it carries 240 GiB of dind PVCs on a 917 G disk). The dind data-root is a plain directory under `/opt/local-path-provisioner` on that filesystem, so filesystem fill is the only honest per-runner signal. Alertmanager is disabled in this stack, so they surface in Prometheus → Alerts and Grafana → Alerting, not as pages.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 7. CI/CD flow
|
|
||||||
|
|
||||||
**Application images**
|
|
||||||
|
|
||||||
```
|
|
||||||
git push → Forgejo Actions
|
|
||||||
├─ arm64 / docker jobs → forgejo-runner-arm64 (rpi, host docker)
|
|
||||||
├─ x86_64 jobs → forgejo-runner-amd64 (siriussec, dind)
|
|
||||||
└─ site deploys → forgejo-runner-deploy-arm64 (rpi)
|
|
||||||
→ image pushed to the Forgejo registry (forgejo.siriusdevops.com/sirius/<image>:latest)
|
|
||||||
→ Deployments use imagePullPolicy: Always, so the pod must be recreated
|
|
||||||
(rollout restart alone can keep the old digest — verify the pod's imageID)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Cluster manifests**
|
|
||||||
|
|
||||||
```
|
|
||||||
edit apps/base/<app>/* → push to sirius/homek8s master
|
|
||||||
→ Flux GitRepository polls (interval 1m) → artifact at new SHA
|
|
||||||
→ kustomization infrastructure (path ./infrastructure/home)
|
|
||||||
→ kustomization apps (path ./apps/home, dependsOn infrastructure)
|
|
||||||
```
|
|
||||||
|
|
||||||
New app = new `apps/base/<app>/` (namespace, Deployment, Service, HTTPRoute) **plus** one line in `apps/home/kustomization.yaml`. New public hostname = that HTTPRoute **plus** one ingress entry on the existing `sirius home` tunnel.
|
|
||||||
|
|
||||||
Force a recheck when Flux's status line is stale (a push is not applied until the GitRepository artifact is that SHA):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n flux-system annotate gitrepository flux-system \
|
|
||||||
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
kubectl -n flux-system annotate kustomization apps \
|
|
||||||
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
```
|
|
||||||
|
|
||||||
**Live Flux state:** GitRepository `flux-system` → `https://forgejo.siriusdevops.com/sirius/homek8s`, Ready, artifact `master@sha1:d5d1d28`; all five Kustomizations (`flux-system`, `gateway-api-crds`, `databases`, `infrastructure`, `apps`) `Ready=True` on the same revision. Cilium is managed as a HelmRelease **by Flux** — never `helm upgrade` it by hand.
|
|
||||||
|
|
||||||
Repository layout:
|
|
||||||
|
|
||||||
```
|
|
||||||
clusters/homek8s/ flux-system GitRepository + 5 Kustomizations
|
|
||||||
infrastructure/home/ entrypoint for infra (cilium, gateway, storage)
|
|
||||||
infrastructure/databases/base/ CloudNativePG 1.30.0 operator, vendored + patched
|
|
||||||
(own Flux Kustomization `databases`, prune: false — CRDs)
|
|
||||||
apps/home/ forgejo, siriusdevops, piedmont, sirius-growth
|
|
||||||
monitoring/controllers/home/ (present in repo, NOT deployed — no monitoring namespace exists)
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 8. Storage and data
|
|
||||||
|
|
||||||
*(live — `kubectl get pvc,pv -A`, `du` on siriussec)*
|
|
||||||
|
|
||||||
StorageClass `local-path` (default, `WaitForFirstConsumer`, no expansion), provisioner pinned to siriussec, root `/opt/local-path-provisioner`.
|
|
||||||
|
|
||||||
| PVC | NS | Size | On-disk dir | Used | Holds |
|
|
||||||
|---|---|---|---|---|---|
|
|
||||||
| `forgejo-data` | forgejo | 20 Gi | `pvc-75ba7bc3…_forgejo_forgejo-data` | **19 G** | Forgejo repos, LFS, avatars, attachments (13.6 G of that is package-registry blobs) — **backed up nightly** |
|
|
||||||
| `forgejo-runner-amd64` | forgejo | 20 Gi | `pvc-b867904c…_forgejo_forgejo-runner-amd64` | **22 G** (the dind `/docker` data-root) | CI scratch — **disposable**, but see the hazard below |
|
|
||||||
| `pg-1` | forgejo | 10 Gi | `pvc-3c0ba824…_forgejo_pg-1` | 653 M | Forgejo Postgres data — **backed up nightly (pg_dump)** |
|
|
||||||
| `portal-1` | sirius-growth | 5 Gi | `pvc-3348c52c…_sirius-growth_portal-1` | 595 M | SGS portal Postgres data — **backed up nightly (pg_dump)** |
|
|
||||||
| `osint-pgdata` / `osint-camera-snapshots` | osint | 15 Gi / 3 Gi | — | 289 M / 4 K | plain Postgres — **backed up nightly (pg_dump)**; the camera snapshot dir is 4 K of throwaway frames — **accepted gap** |
|
|
||||||
| `sgs-leadgen-data` | sirius-growth | 1 Gi | — | 4.9 M | lead-gen capture — **mirrored nightly** |
|
|
||||||
| `kube-prometheus-stack-grafana` | monitoring | 5 Gi | — | 55 M | Grafana sqlite: users/orgs/prefs/API keys/annotations (dashboards, datasources and alert rules are provisioned from git, so they are *not* in the db) — **snapshotted nightly** |
|
|
||||||
| `…prometheus-…-db-…prometheus-0` | monitoring | 10 Gi | — | 2.4 G | Prometheus TSDB — rebuildable metrics history, **not backed up** |
|
|
||||||
|
|
||||||
**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, 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
|
|
||||||
|
|
||||||
Five independent scheduled paths, all **off** the T480 and **off** the Pi:
|
|
||||||
|
|
||||||
1. **Cluster state → Linode VPS**, CronJob `forgejo/cluster-backup`
|
|
||||||
(`apps/base/forgejo/cluster-backup.yaml`; exec-only RBAC in
|
|
||||||
`apps/base/sirius-growth/backup-exec-rbac.yaml` and
|
|
||||||
`apps/base/osint/backup-exec-rbac.yaml`). Schedule `37 2 * * *`
|
|
||||||
UTC, `concurrencyPolicy: Forbid`. Destination is
|
|
||||||
`[email protected]:/root/cluster-backup` — **the mesh address, never the public
|
|
||||||
IP**. Everything is streamed: no dump is staged on siriussec.
|
|
||||||
2. **Two small PVC mirrors into the same tree**, because a PVC can only be
|
|
||||||
mounted by a pod in its own namespace: `monitoring/grafana-backup`
|
|
||||||
(`monitoring/controllers/home/grafana-backup.yaml`, `0 3 * * *`) and
|
|
||||||
`sirius-growth/leadgen-backup` (`apps/base/sirius-growth/leadgen-backup.yaml`,
|
|
||||||
`7 3 * * *`). Both mount the claim on siriussec and stream to
|
|
||||||
`[email protected]:/root/cluster-backup`, so retention and the manifest habit
|
|
||||||
are shared with path 1.
|
|
||||||
3. **Garage object store (Pi) → same Linode**, `infrastructure/garage/backup/`
|
|
||||||
`garage-meta-backup.timer` (hourly) + `garage-data-backup.timer` (nightly) →
|
|
||||||
`[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 fifth path covers the Pi's own hub state: `infrastructure/wireguard/backup/`
|
|
||||||
`wireguard-backup.timer` (nightly 04:13) → `[email protected]:/root/pihost-backup`.
|
|
||||||
|
|
||||||
| 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/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` | 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 |
|
|
||||||
| `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 |
|
|
||||||
| Pi `/etc/wireguard/` + wgportal `sqlite.db` | Pi-side systemd timer: tarball (`/etc/wireguard` verbatim incl. `.bak` history + a sqlite-API copy of the peer db), sha256 checked on both sides | `[email protected]:/root/pihost-backup/wireguard/wireguard-<stamp>.tar.gz` | 14 |
|
|
||||||
|
|
||||||
- The data mirror is a *snapshot* mirror, not a rolling one: each night writes a
|
|
||||||
new directory whose unchanged files are hardlinks to the previous night's, so
|
|
||||||
a corrupted file in the source cannot rewrite history.
|
|
||||||
- DB dumps are checksummed on **both** sides (`sha256sum` on the pod's copy of
|
|
||||||
the stream vs the remote file) before the `.part` file is renamed; a short
|
|
||||||
stream fails the Job instead of silently shipping a broken archive.
|
|
||||||
- Each run appends sizes + checksums to `/root/cluster-backup/manifests/<stamp>.txt`.
|
|
||||||
- The Job fails (a red Job, not a silent skip) if the Linode has less than
|
|
||||||
8 GiB free, so a growing registry cannot quietly eat the last snapshot's room.
|
|
||||||
- The only secret is the backup SSH key: `forgejo/cluster-backup-ssh` (created
|
|
||||||
out of band, **not in git**, so Flux never reverts it) holding an ed25519 key
|
|
||||||
that is `from="10.10.0.0/24,10.244.0.0/16,10.20.0.0/24"`-restricted,
|
|
||||||
`no-pty`, no forwarding in `root@linode:~/.ssh/authorized_keys`. Host key is
|
|
||||||
pinned (`known_hosts` for `10.10.0.5`), so a MITM on the mesh fails closed.
|
|
||||||
- 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.
|
|
||||||
|
|
||||||
- **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):**
|
|
||||||
|
|
||||||
- **Prometheus TSDB** (2.4 GiB) — deliberately excluded: regenerated metrics
|
|
||||||
history, and a volume loss only costs graphs, not state.
|
|
||||||
- **`osint/osint-camera-snapshots`** (4 K) — throwaway camera frames; the
|
|
||||||
camera re-captures on demand and nothing reads old frames.
|
|
||||||
- **Runner PVCs** (`forgejo-runner-amd64`, `*-dind`) — CI scratch, rebuildable
|
|
||||||
by design (the dind data-root only holds named build caches).
|
|
||||||
- **Grafana dashboards / datasources / alert rules are not in the backup and do
|
|
||||||
not need to be**: they are provisioned from `monitoring/controllers/home/`
|
|
||||||
in git. The sqlite db carries the parts git cannot rebuild — users, orgs,
|
|
||||||
preferences, annotations and API keys.
|
|
||||||
- **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.
|
|
||||||
|
|
||||||
**Closed 2026-11-19 — point-in-time recovery.** There is no longer a "restore to
|
|
||||||
02:37 or lose the day" gap: `sirius-growth/portal` can be recovered to any second
|
|
||||||
inside the 14-day window, and that restore has been rehearsed end to end (§8.3).
|
|
||||||
`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
|
|
||||||
|
|
||||||
Rehearsed on 2026-11-19 (see the completion note on task `t_dcad85f6`); the DB
|
|
||||||
restore below was exercised against a throwaway Postgres pod and produced the
|
|
||||||
live row count.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 1. Forgejo data: stop Forgejo, then mirror the newest snapshot back.
|
|
||||||
kubectl -n forgejo scale deploy/forgejo --replicas=0
|
|
||||||
# on the node holding the PVC (siriussec), or from any pod that mounts it:
|
|
||||||
# rsync -a --delete root@10.10.0.5:/root/cluster-backup/forgejo-data/latest/ /data/
|
|
||||||
kubectl -n forgejo scale deploy/forgejo --replicas=1
|
|
||||||
|
|
||||||
# 2. A CNPG database: pull the dump and restore it with pg_restore, e.g. into a
|
|
||||||
# scratch pod or a scratch database on the cluster:
|
|
||||||
ssh root@10.10.0.5 'cat /root/cluster-backup/db/forgejo-pg-<stamp>.dump' \
|
|
||||||
| kubectl -n forgejo exec -i <pod> -c postgres -- \
|
|
||||||
pg_restore -U postgres -d <target-db> --no-owner --no-privileges
|
|
||||||
```
|
|
||||||
|
|
||||||
`pg_restore` is **not** installed on the Linode — pull the dump and restore with
|
|
||||||
a Postgres client (the `ghcr.io/cloudnative-pg/postgresql:16` primary has one).
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 3. osint-db (plain Postgres **with TimescaleDB**): a naive pg_restore into a
|
|
||||||
# fresh database fails on hypertable catalog rows ("could not find hypertable
|
|
||||||
# with id N" / "ONLY option not supported on hypertable operations") and
|
|
||||||
# silently drops one hypertable's data. Pre/post-restore commands are
|
|
||||||
# mandatory, and the extensions must exist BEFORE them.
|
|
||||||
kubectl -n osint exec deploy/osint-db -- psql -U osint -d postgres \
|
|
||||||
-c 'create database osint_restore'
|
|
||||||
kubectl -n osint exec deploy/osint-db -- psql -U osint -d osint_restore \
|
|
||||||
-c 'create extension if not exists timescaledb' \
|
|
||||||
-c 'create extension if not exists postgis' \
|
|
||||||
-c 'select timescaledb_pre_restore()'
|
|
||||||
ssh root@10.10.0.5 'cat /root/cluster-backup/db/osint-osint-db-<stamp>.dump' \
|
|
||||||
| kubectl -n osint exec -i deploy/osint-db -- \
|
|
||||||
pg_restore -U osint -d osint_restore --no-owner --no-privileges
|
|
||||||
kubectl -n osint exec deploy/osint-db -- psql -U osint -d osint_restore \
|
|
||||||
-c 'select timescaledb_post_restore()'
|
|
||||||
|
|
||||||
# 4. Grafana: readable with the sqlite backup API and integrity_check=ok.
|
|
||||||
# Stop Grafana first (it also runs `strategy: Recreate`) so the restored file
|
|
||||||
# is not overwritten by the running instance's open handle.
|
|
||||||
kubectl -n monitoring scale deploy/kube-prometheus-stack-grafana --replicas=0
|
|
||||||
ssh root@10.10.0.5 'cat /root/cluster-backup/grafana/grafana-<stamp>.db' \
|
|
||||||
| kubectl -n monitoring exec -i <helper-pod-with-the-pvc-mounted> -- \
|
|
||||||
sh -c 'cat > /var/lib/grafana/grafana.db && chown 472:472 /var/lib/grafana/grafana.db'
|
|
||||||
kubectl -n monitoring scale deploy/kube-prometheus-stack-grafana --replicas=1
|
|
||||||
# Users come back from the db; dashboards/datasources re-provision from git.
|
|
||||||
|
|
||||||
# 5. Lead-gen capture: plain mirror — pull it back onto the claim with rsync.
|
|
||||||
rsync -a --delete root@10.10.0.5:/root/cluster-backup/leadgen-data/latest/ /leadgen/
|
|
||||||
|
|
||||||
# 6. Pi hub state (keys included — pull it to a root-only path, never a shared one).
|
|
||||||
ssh -i /home/sirius/.ssh/linode_admin root@10.20.0.1 \
|
|
||||||
'cat /root/pihost-backup/wireguard/wireguard-<stamp>.tar.gz' | sudo tar -tzf -
|
|
||||||
# stop wg-quick first: SaveConfig = true rewrites wg0.conf from the live iface
|
|
||||||
sudo wg-quick down wg0 || true
|
|
||||||
ssh -i /home/sirius/.ssh/linode_admin root@10.20.0.1 \
|
|
||||||
'cat /root/pihost-backup/wireguard/wireguard-<stamp>.tar.gz' | sudo tar -xzf - -C /
|
|
||||||
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.1 The four that actually bite
|
|
||||||
|
|
||||||
1. **A Pi reboot loses `wg0` and silently breaks the cluster.** `wg-quick@wg0` is *enabled now* (a past gap was fixed), but after any reboot re-check the route pins: `ip route get 10.10.0.2` must say `dev wg0`. The Pi's kubelet symptom is `node "rpi" not found`, while cloudflared and Forgejo look perfectly healthy — see `references/pi-reboot-recovery.md` in the `home-k8s` skill. Work outside-in: LAN SSH → power-event check → `wg-quick@wg0` → **route pins** → per-hop curls.
|
|
||||||
2. **DiskPressure on siriussec takes the whole ingress stack with it.** Forgejo 503 from Cloudflare with `no healthy upstream` is almost always node `DiskPressure` (dind growth, §8), not the tunnel. Check `curl http://127.0.0.1:20241/ready` on rpi first; `readyConnections ≥ 1` means the tunnel is fine.
|
|
||||||
3. **`10.10.0.0/24` claimed by two interfaces on the Pi** (§3.4). Any edit to `wg-remote` AllowedIPs or a peer change can reintroduce it. Re-check both `ip route get 10.10.0.2` and `ip route get 10.10.0.5` after touching WireGuard.
|
|
||||||
4. **The T480 must boot `linux-lts`.** Running `6.18.50-2-lts` now; `7.2.3-arch1-3` is installed on disk and Cilium's BPF probe fails on it. GRUB default must stay on LTS, and never reboot onto a kernel whose `/lib/modules/$(uname -r)` was already removed by a pacman upgrade.
|
|
||||||
|
|
||||||
### 9.2 Smaller, still real
|
|
||||||
|
|
||||||
- **Leader-election fatals are an I/O-contention problem, and the two GitOps operators are now fixed for it.** The root cause is *shared-NVMe contention from CI build I/O*, not a slow or failing disk: etcd `wal_fsync` on `/dev/nvme0n1p3` (the same device as the dind data-root and `forgejo-data`) records **158 samples >8.192 s and 2,518 >2.048 s out of 14,813,192**, while 99.6 % land ≤32 ms — i.e. tail stalls of 5–10.4 s, worst **10.39 s at `2026-10-23T02:48:44Z`**. Every one of the 8 hours containing a ≥2 s stall had CI build I/O running (7 of 8 the amd64 dind runner); light deploy-only hours with the runner present produced none. A single stall exceeds client-go's 5 s lease-renewal HTTP timeout, controller-runtime reports `leader election lost`, and the manager fatals by design (`exit 1`).
|
|
||||||
- `cnpg-controller-manager` — **223 restarts / 45 d, fixed in `d5d1d28`** with `--leader-lease-duration=60 --leader-renew-deadline=45` (integer **seconds**; CNPG has no `resource-lock-timeout` flag, unlike Cilium). The same commit vendors the pinned 1.30.0 operator manifest into `infrastructure/databases/base/` and gives it its own Flux Kustomization `databases` (`prune: false` — the bundle carries the 11 CNPG CRDs, and pruning those would delete both clusters), so the args are declared state instead of a hand patch. The patch also preserves the pre-existing live deltas upstream does not ship (overlay API env `10.10.0.2:6443`, 500m/512Mi limits, 3 min startup probe). Live lease `cnpg-system/db9c8771.cnpg.io` reports `leaseDurationSeconds: 60`.
|
|
||||||
- `cilium-operator` — widened earlier in `bd5057c` (`--leader-election-lease-duration=60s`, `renew-deadline=45s`, `resource-lock-timeout=20s`) in `infrastructure/networking/cilium/values.yaml`.
|
|
||||||
- `kube-controller-manager` (~227) and `kube-scheduler` (~230) restarts are the *same stall event*, but they are kubeadm static pods, not GitOps: they were **not** changed and need their own `--leader-elect` tuning pass.
|
|
||||||
- Honest gap: one stall hour (`2026-10-24 22`, 18 events, worst 5.95 s) had **no** amd64 runner job and began the same minute a Pi-side `onionwire` job started. Unexplained but observed — do not claim dind-on-siriussec is the sole source.
|
|
||||||
- 60 s is a tourniquet, comfortably above the 10.4 s worst case; widening further fixes nothing. The remedy now shipped is **`infrastructure/node-io`** (`etcd-io-guard`, a one-node DaemonSet on siriussec): `vm.dirty_bytes=64 MiB` / `dirty_background_bytes=16 MiB` bound the host writeback backlog, and `io.max wbps=40 MiB/s` caps the **dind container's own cgroup** (never a slice — etcd is in `kubepods-burstable.slice`). Both are re-applied on drift every 30 s and re-discovered after a runner pod recreation, so a new dind cgroup is capped within one tick.
|
|
||||||
- Why not `io.latency`/iocost: this kernel exposes **no** `/sys/block/nvme0n1/queue/io.cost.*`, and cgroup-v2 applies `io.latency` targets only between **peers of the same parent** — kubelet gives every pod its own slice, so an etcd target can never throttle the dind pod (measured: dind's `io.stat` stayed `depth=max`). `io.max` is the available lever.
|
|
||||||
- Measured 2026-10-26 (identical 150 s, 4×128 MiB `dd conv=fsync` load run **inside** the dind container): worst `slow fdatasync` **1.40 s** and **1** warning line vs 11, **0** fsyncs >8.192 s, **no** apiserver/KCM/scheduler restarts during the run, and exactly 6.0 GiB written in 157 s (41 MB/s — the cap binds). Unmitigated baseline on the same device: 68.9 s / 26.6 s / 17.6 s stalls with apiserver restart and lost KCM/scheduler leases.
|
|
||||||
- Cost and limits: the 40 MiB/s cap costs ~11 % of dind write bandwidth and the 64 MiB dirty bound is host-global (every writer on siriussec). Moving the dind data-root off `/dev/nvme0n1p3` is still the only change that lets both knobs go back to default. Verify per the `node-io/README.md` checklist; `fstrim.timer` should also be enabled (it was disabled while the device reports `DISC-MAX 2T`).
|
|
||||||
- Pi ufw allows `22/tcp` from anywhere, plus `10.10.0.0/24`, `10.244.0.0/16` and `51820/udp`; the WG forward rules between `wg0` and `wg-remote` are in place. The Linode hub also needs its own `FORWARD` accepts or spoke traffic dies past the hub.
|
|
||||||
- Two stale WireGuard peers exist: mesh `10.10.0.4` (6 days, Tailscale endpoint) and Linode-hub `10.20.0.4` (no handshake). Harmless but misleading in `wg show`.
|
|
||||||
- The Pi runs **Tailscale** (`tailscale0`, `100.71.235.119`) alongside WireGuard. Do not plan recovery around Tailscale-only paths; treat WireGuard/LAN as the primary.
|
|
||||||
- Pi still runs three leftover Docker services outside Kubernetes: `registry:2` on `127.0.0.1:5000`, and two containers of site images (`handyman-site` on `:8082`, `sirius-growth-site`). The in-cluster GitOps deployments supersede the site containers; the local registry is still what `deploy-handyman.yml`/`deploy-site.yml` push to.
|
|
||||||
|
|
||||||
### 9.3 Drift found: this document vs the `home-k8s` skill
|
|
||||||
|
|
||||||
| Skill says | Reality (live 2026-10-26) |
|
|
||||||
|---|---|
|
|
||||||
| Cilium **1.18.13** | Cilium **v1.20.1**, Envoy `v1.37.5` |
|
|
||||||
| `linode` worker retired / "not down, gone" (task spec) | `linode` is **back as a Ready worker**, joined ~60 min before this reading, pod CIDR `10.244.2.0/24` |
|
|
||||||
| `linode` tainted `dedicated=network:PreferNoSchedule` | label present, **no taint** (same for rpi) |
|
|
||||||
| Public origin `10.10.0.5:8080` in the older paragraph | origin is **`10.10.0.2:8080`** (the skill's newer paragraph is right; the older one is stale) |
|
|
||||||
| Gateway listener on `10.10.0.5` / one Gateway | Gateway `public` advertises **three** addresses (`.1/.2/.5`) but only `.2:8080` completes requests; a second Gateway `internal:8081` exists |
|
|
||||||
| Garage: systemd unit, loopback only | **Docker container** `dxflrs/garage:v1.1.0`; `10.10.0.1:3900` (S3) + `10.10.0.1:3903` (metrics) + `127.0.0.1:3900`, nothing on `0.0.0.0`; compose now committed at `infrastructure/garage/` |
|
|
||||||
| wgportal is the peer manager on the Pi | **wgportal is not running** — dir + compose remain, no container, no unit; peers are edited manually |
|
|
||||||
| "Only wgportal compose should stay on the Pi" | Pi also runs `registry`, `handyman-site`, `sirius-growth-site` containers |
|
|
||||||
| PHS/piedmont pods pinned to `linode` | pinned to **siriussec** (`nodeSelector: kubernetes.io/hostname`) |
|
|
||||||
| Two Actions runners | **Three** — `forgejo-runner-deploy-arm64` (`deploy-arm64` only) added |
|
|
||||||
| — | `metrics-server` absent, so `kubectl top` does not work |
|
|
||||||
| — | `paaas.siriusdevops.com` is in the tunnel with **no** HTTPRoute → 404 |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 10. Verification log
|
|
||||||
|
|
||||||
All times 2026-10-26 UTC. `kubeconfig` on the Legion admin laptop → `https://10.10.0.2:6443`; SSH `[email protected]` (rpi) and `[email protected]` (siriussec, capital L), key `~/.ssh/lancelot_priv`; Linode only via the Pi hop (`ssh -i ~/.ssh/linode_admin [email protected]`).
|
|
||||||
|
|
||||||
| # | Command | Key result |
|
|
||||||
|---|---|---|
|
|
||||||
| 1 | `kubectl get nodes -o wide` | 3 nodes, all Ready, v1.36.4, `linode` age 60 m |
|
|
||||||
| 2 | `kubectl get nodes -o json` (labels/taints/conditions) | no taints anywhere; `gateway=true` on rpi + siriussec; `dedicated=network` on rpi + linode |
|
|
||||||
| 3 | `kubectl get pods -A -o wide` | 37 rows = **31 Running** + 6 Completed |
|
|
||||||
| 4 | `kubectl get svc,ingress,httproute,gateway -A` | no Ingress objects; 4 HTTPRoutes; Gateways `public` (8080) and `internal` (8081) |
|
|
||||||
| 5 | `kubectl get pvc,pv -A`, `kubectl get sc` | 4 Bound PVs, all `local-path`, all on siriussec |
|
|
||||||
| 6 | `kubectl get cluster -A` | `forgejo/pg` and `sirius-growth/portal`, both `ClusterIsReady`, 1 instance each |
|
|
||||||
| 7 | `kubectl -n flux-system get gitrepository,kustomization -o wide` | all Ready, revision `master@sha1:bd5057c` |
|
|
||||||
| 8 | `kubectl -n kube-system get cm cilium-config -o jsonpath=…` | `routing-mode: native`, `ipv4-native-routing-cidr 10.244.0.0/16`, `kube-proxy-replacement true`, `bpf-lb-external-clusterip true` |
|
|
||||||
| 9 | `kubectl -n kube-system get ds,deploy` / image tags | cilium `v1.20.1`, envoy `v1.37.5` |
|
|
||||||
| 10 | `kubectl -n kube-system exec ds/cilium -- cilium-dbg status --brief` | `OK` |
|
|
||||||
| 11 | `kubectl top nodes` | `error: Metrics API not available` → no metrics-server |
|
|
||||||
| 12 | `kubectl -n forgejo get deploy -o json` | 3 runner Deployments + nodeSelectors; pod/container securityContext as documented |
|
|
||||||
| 13 | `kubectl -n forgejo get cm forgejo-runner-config -o jsonpath` | three TOMLs: `amd64.toml`, `arm64.toml`, `deploy-arm64.toml`, all `capacity: 1` |
|
|
||||||
| 14 | `kubectl -n forgejo exec deploy/forgejo -- forgejo --version` | `16.0.5` |
|
|
||||||
| 15 | rpi: `sudo wg show` | `wg0` 3 peers (handshakes 1 min / 48 min / 6 d); `wg-remote` 1 peer, 35 s |
|
|
||||||
| 16 | rpi: `sudo wg show wg0 dump \| wc -l` | `4` |
|
|
||||||
| 17 | rpi: `systemctl is-enabled/is-active wg-quick@{wg0,wg-remote} cloudflared` | enabled/enabled/enabled; active state: wg0 **inactive**, wg-remote **active** |
|
|
||||||
| 18 | rpi: `ip route get 10.10.0.2 / 10.10.0.5 / 10.10.0.3` | `dev wg0` / `dev wg-remote` / `dev wg0` — pins correct |
|
|
||||||
| 19 | rpi: `curl -s http://127.0.0.1:20241/ready` | `{"status":200,"readyConnections":4}` |
|
|
||||||
| 20 | rpi: `curl -s http://127.0.0.1:20241/config` | 8 hostnames + catch-all, **all** → `http://10.10.0.2:8080` |
|
|
||||||
| 21 | rpi: `curl -H 'Host: <h>' http://10.10.0.2:8080/` ×5 | 200/31813 / 200/15008 / 200/72640 / 200/7067 / **404 paaas** |
|
|
||||||
| 22 | rpi: same against `10.10.0.1:8080` and `10.10.0.5:8080` | rpi → **503 in 5.000 s**; linode → no listener (000) |
|
|
||||||
| 23 | Cloudflare API `GET /accounts/…/cfd_tunnel` | `sirius home` healthy, 4 connections; `piedmontomesvc` tunnel inactive, 0 |
|
|
||||||
| 24 | rpi: `docker ps -a` | garage, registry, handyman-site, sirius-growth-site up; **no wg-portal**; 5 exited `onionwire-ci-*` containers |
|
|
||||||
| 25 | rpi: `docker exec garage /garage status` and `bucket list` | node `d053db4dfc97bf78` healthy, 3 buckets |
|
|
||||||
| 26 | rpi: `ss -ltnp \| grep 390` | `127.0.0.1:3900` **and `10.10.0.1:3900`/`:3903`** — no `0.0.0.0`, no 3901/3902 |
|
|
||||||
| 27 | rpi: `df -h`, `free -h`, `vcgencmd get_throttled` | 58% used; 7.9 GiB RAM; `throttled=0x0` |
|
|
||||||
| 28 | siriussec: `wg show` | peer = Pi hub, `AllowedIPs 10.10.0.0/24, 10.244.0.0/16`, handshake 1 min |
|
|
||||||
| 29 | siriussec: `sudo nft list table inet k8s-api` | lo / wg0 / `10.244.0.0/16` accept, else drop |
|
|
||||||
| 30 | siriussec: `sudo du -sh /opt/local-path-provisioner/pvc-*` | 224 M / 643 M / 12 G / **18 G** (dind) |
|
|
||||||
| 31 | siriussec: `uname -r`, `pacman -Q linux-lts` | `6.18.50-2-lts`; `7.2.3-arch1-3` also installed |
|
|
||||||
| 32 | linode (via Pi hop): `hostname`, `ip -br addr`, `wg show wg0` | `dummy-k8s 10.10.0.5/32`, `wg0 10.20.0.1/24`, 4 peers, uptime 3 d 17 h |
|
|
||||||
|
|
||||||
**CNPG leader-election fix, re-verified 2026-10-26 19:37–19:45 UTC (commit `d5d1d28`):**
|
|
||||||
|
|
||||||
| # | Command | Key result |
|
|
||||||
|---|---|---|
|
|
||||||
| 33 | `kubectl -n cnpg-system get deploy cnpg-controller-manager` (`--show-managed-fields`) | args `--leader-lease-duration=60`, `--leader-renew-deadline=45`; preserved `KUBERNETES_SERVICE_HOST=10.10.0.2`, 500m/512Mi, startupProbe 36; managedFields owner `kustomize-controller` `Apply` → Flux owns it |
|
|
||||||
| 34 | `kubectl -n cnpg-system get lease db9c8771.cnpg.io -o jsonpath` | `leaseDurationSeconds: 60` (was 15), holder = new pod `78484bd58d-m6rtk`, `renewTime` advancing; `leader election lost` count in the new pod's log: **0**; restarts 223 → **0** on the new ReplicaSet |
|
|
||||||
| 35 | `kubectl -n flux-system get kustomization`; `kubectl get cluster -A` | new `databases` Kustomization `Ready=True` at `master@sha1:d5d1d28`; all 5 Ready; `forgejo/pg` + `sirius-growth/portal` both `Ready=True`; `forgejo.siriusdevops.com` **200** public and `Host:` curl to `10.10.0.2:8080` **200** |
|
|
||||||
| 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.
|
|
||||||
|
|
||||||
**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 |
|
|
||||||
|
|
@ -1,112 +0,0 @@
|
||||||
# Grafana persistence and the admin password
|
|
||||||
|
|
||||||
Grafana (`monitoring/kube-prometheus-stack-grafana`) used to run with **no
|
|
||||||
persistence at all**: `/var/lib/grafana` was an `emptyDir`, so its sqlite DB
|
|
||||||
(`grafana.db`) — the admin user row, sessions, API keys, alert state and any
|
|
||||||
UI-created dashboard — died with the pod. `GF_SECURITY_SECRET_KEY` was also
|
|
||||||
unset, so every restart generated a fresh session-signing key. The visible
|
|
||||||
symptom was a browser holding a session cookie that could never validate:
|
|
||||||
`logger=authn.service msg="Failed to authenticate request"
|
|
||||||
client=auth.client.session error="user token not found"` followed by
|
|
||||||
`path=/ status=302`, i.e. a client bouncing on `/` — which looks like
|
|
||||||
"Grafana is unreachable" but is not a network fault.
|
|
||||||
|
|
||||||
Both are fixed in `monitoring/controllers/home/values.yaml`:
|
|
||||||
|
|
||||||
| What | Where |
|
|
||||||
|------|-------|
|
|
||||||
| DB + plugins | PVC `monitoring/kube-prometheus-stack-grafana`, 5Gi `local-path`, mounted at `/var/lib/grafana` (Grafana's `GF_PATHS_DATA`) |
|
|
||||||
| `GF_SECURITY_SECRET_KEY` | Secret `monitoring/grafana-secret-key`, key `secret_key` (out of band — **not in git**), injected with `grafana.envValueFrom` |
|
|
||||||
| Deployment strategy | `Recreate` — a RWO `local-path` PVC cannot be mounted by an old and a new pod at once, so `RollingUpdate` deadlocks the rollout |
|
|
||||||
|
|
||||||
The PVC is `local-path`, so the data physically lives on **siriussec**
|
|
||||||
(`nodeSelector: kubernetes.io/hostname: siriussec` is unchanged) under
|
|
||||||
`/opt/local-path-provisioner/pvc-<uuid>_monitoring_kube-prometheus-stack-grafana/`.
|
|
||||||
That also means the data does **not** follow the pod to another node — if
|
|
||||||
siriussec is rebuilt, the admin state is gone with the rest of the local PVs.
|
|
||||||
|
|
||||||
## Provisioned dashboards still win
|
|
||||||
|
|
||||||
Dashboards and datasources are sidecar-loaded from ConfigMaps
|
|
||||||
(`grafana_dashboard` / `grafana_datasource` labels, provider
|
|
||||||
`allowUiUpdates: false`, `foldersFromFilesStructure` off). They are the source
|
|
||||||
of truth: editing a provisioned dashboard in the UI is **overwritten on the next
|
|
||||||
sidecar reload/restart**, and deleting the ConfigMap deletes the dashboard. That
|
|
||||||
is intended — persistence exists for credential/session state, not to turn
|
|
||||||
Grafana into a hand-edited dashboard store. A *new* dashboard created purely in
|
|
||||||
the UI has no ConfigMap and does persist in the DB, but nothing backs it up and
|
|
||||||
it will not exist after a node rebuild.
|
|
||||||
|
|
||||||
## Where the admin password lives
|
|
||||||
|
|
||||||
**Two owners, one rule: the Secret is only the *seed*.**
|
|
||||||
|
|
||||||
* `monitoring/grafana-admin` (`admin-user`, `admin-password`) is used through
|
|
||||||
`grafana.admin.existingSecret` → `GF_SECURITY_ADMIN_USER` /
|
|
||||||
`GF_SECURITY_ADMIN_PASSWORD`. Grafana creates the admin row from these values
|
|
||||||
**only when the DB has no admin user** (first boot on an empty PVC).
|
|
||||||
* After that the DB owns the password. An in-app change sticks across restarts,
|
|
||||||
and the Secret is **not** updated by Grafana — the two drift the moment
|
|
||||||
someone changes the password in the UI.
|
|
||||||
|
|
||||||
So: changing `grafana-admin` alone on a populated PVC does **nothing**. That is
|
|
||||||
by design (no silent password resets on redeploy), and it is exactly why the
|
|
||||||
recovery path below matters.
|
|
||||||
|
|
||||||
## Recovery: reset a lost admin password
|
|
||||||
|
|
||||||
The trap with a persistent DB is that re-applying the Secret no longer helps.
|
|
||||||
Reset it from inside the pod against the live DB:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n monitoring exec deploy/kube-prometheus-stack-grafana -c grafana -- \
|
|
||||||
grafana cli --homepath /usr/share/grafana admin reset-admin-password '<new-password>'
|
|
||||||
```
|
|
||||||
|
|
||||||
That rewrites the password in `grafana.db` (and clears the admin's sessions), so
|
|
||||||
it survives restarts. Then **also** update the Secret so the seed matches the
|
|
||||||
DB and nobody gets a surprise if the PVC is ever lost:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# keep the value out of shell history / the terminal: read it from a 0600 file
|
|
||||||
kubectl -n monitoring patch secret grafana-admin --type merge \
|
|
||||||
-p "{\"stringData\":{\"admin-password\":\"$(cat /root/gf-admin.pw)\"}}"
|
|
||||||
```
|
|
||||||
|
|
||||||
Full reset (last resort, **destroys every UI-created dashboard, API key and
|
|
||||||
alert rule**): scale the Deployment to 0, `rm -rf` the PV sub-directory on
|
|
||||||
siriussec (or delete the PVC), scale back to 1. Grafana re-seeds the admin user
|
|
||||||
from `grafana-admin` on the empty DB.
|
|
||||||
|
|
||||||
## Recreating the secret_key Secret
|
|
||||||
|
|
||||||
`grafana-secret-key` is out of band. If it is lost, Grafana will not start
|
|
||||||
(the `secretKeyRef` is not optional). Recreate it with a fresh random value —
|
|
||||||
this invalidates every existing session, which is the acceptable cost:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n monitoring create secret generic grafana-secret-key \
|
|
||||||
--from-literal=secret_key="$(head -c 48 /dev/urandom | base64 | tr -d '\n=/+' | head -c 63)"
|
|
||||||
kubectl -n monitoring rollout restart deploy/kube-prometheus-stack-grafana
|
|
||||||
```
|
|
||||||
|
|
||||||
(Or apply `stringData` from stdin so the value never touches a file. Never
|
|
||||||
commit it.)
|
|
||||||
|
|
||||||
## One-time transition note (2026-10-27)
|
|
||||||
|
|
||||||
Switching the existing Deployment to `strategy: Recreate` needed one manual step:
|
|
||||||
the live Deployment still owned `spec.strategy.rollingUpdate` from the previous
|
|
||||||
release, and server-side apply does not drop a field merely by omitting it, so
|
|
||||||
Helm failed with
|
|
||||||
|
|
||||||
```
|
|
||||||
Deployment.apps "kube-prometheus-stack-grafana" is invalid:
|
|
||||||
spec.strategy.rollingUpdate: Forbidden: may not be specified when strategy `type` is 'Recreate'
|
|
||||||
```
|
|
||||||
|
|
||||||
Putting `rollingUpdate: null` in the values does not help — Helm drops null keys
|
|
||||||
during values coalescing. The fix was a one-off
|
|
||||||
`kubectl -n monitoring patch deploy kube-prometheus-stack-grafana -p
|
|
||||||
'{"spec":{"strategy":{"type":"Recreate","rollingUpdate":null}}}'` followed by a
|
|
||||||
HelmRelease reconcile. A fresh install never needs it.
|
|
||||||
|
|
@ -1,804 +0,0 @@
|
||||||
---
|
|
||||||
title: Internal (WireGuard-only) services on the home cluster
|
|
||||||
created: 2026-10-27
|
|
||||||
updated: 2026-10-27
|
|
||||||
author: Lance Walters (written with Hermes devops agent)
|
|
||||||
tags: [homelab, kubernetes, wireguard, cilium, gateway-api, observability]
|
|
||||||
status: current
|
|
||||||
verified: 2026-10-27T05:20Z
|
|
||||||
---
|
|
||||||
|
|
||||||
# Internal (WireGuard-only) services
|
|
||||||
|
|
||||||
How a service in this cluster is exposed **to the WireGuard mesh and nothing
|
|
||||||
else** — not to the LAN, not to the internet — and how to add the next one.
|
|
||||||
First user: Grafana (`monitoring`). Second: Hubble UI (`kube-system`).
|
|
||||||
|
|
||||||
Related: [[Home-Lab-Kubernetes-Cluster]], `docs/cluster-overview.md`,
|
|
||||||
`infrastructure/networking/internal/`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. Why this is not just "an HTTPRoute without a hostname"
|
|
||||||
|
|
||||||
Cilium's Gateway implementation runs **one hostNetwork Envoy per gateway node**
|
|
||||||
(`cilium-envoy` DaemonSet, node selector `node-role.kubernetes.io/gateway=true`
|
|
||||||
— **`siriussec` 10.10.0.2 only**, since 2026-10-27) and binds **every**
|
|
||||||
listener port on `0.0.0.0`. There is no Gateway API field for "listen on wg0
|
|
||||||
only". Consequences:
|
|
||||||
|
|
||||||
- A listener on port 8081 is reachable on `192.168.1.179:8081` (siriussec's
|
|
||||||
LAN address) and on siriussec's WG address the moment it is Programmed.
|
|
||||||
Nothing binds `:8081` on rpi: it lost the `gateway=true` label on 2026-10-27,
|
|
||||||
so `10.10.0.1:8081` is a **closed port**, not a second origin.
|
|
||||||
- The Gateway object cannot enforce the network boundary. **The host firewall
|
|
||||||
is the enforcement point.** That is the whole trick.
|
|
||||||
- The service is reached as **`http://10.10.0.2:<port>/`** — no `/etc/hosts`
|
|
||||||
entry, no `Host` header. The HTTPRoute must therefore carry **no
|
|
||||||
`hostnames`**, or a phone (which cannot edit a hosts file) sends
|
|
||||||
`Host: 10.10.0.2:8081`, matches no `.lab.internal` route, and Envoy answers
|
|
||||||
**404**. A hostname-less route matches any `Host` on its listener, so the
|
|
||||||
named `http://<name>.lab.internal:8081` URL keeps working for laptops that
|
|
||||||
do have the hosts line.
|
|
||||||
- **One service per listener port AND per Gateway.** Two hostname-less routes
|
|
||||||
on one listener make precedence ambiguous — and worse, Cilium renders **one
|
|
||||||
RouteConfiguration per Gateway**, shared by all of that Gateway's listeners,
|
|
||||||
so two hostname-less routes merge into a single route with `weightedClusters`
|
|
||||||
weight 1/1: every request then hits a random backend, on *every* port of the
|
|
||||||
gateway. Splitting them onto different ports of the same Gateway does not
|
|
||||||
help. Each bare-IP service therefore gets its own **Gateway** (its own port,
|
|
||||||
its own RouteConfiguration) — see `gateway-hubble-ui.yaml` and §9.
|
|
||||||
|
|
||||||
Public traffic has no path here: the only public ingress is the cloudflared
|
|
||||||
tunnel, whose ingress list is an explicit allow-list of hostnames pointing at
|
|
||||||
`http://10.10.0.2:8080` (the `public` gateway). Nothing points at 8081, and
|
|
||||||
`*.lab.internal` resolves nowhere publicly.
|
|
||||||
|
|
||||||
## 2. The pieces
|
|
||||||
|
|
||||||
| Object / unit | Where | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `Gateway internal/internal` | `infrastructure/networking/internal/gateway.yaml` (Flux: `infrastructure`) | listener `http-internal`, **port 8081**, `allowedRoutes: All` so any namespace can attach. **One bare-IP service only** (Grafana) — see the merge gotcha above |
|
|
||||||
| `Gateway internal/hubble-ui` | `infrastructure/networking/internal/gateway-hubble-ui.yaml` | listener `http-internal`, **port 8084**, its own RouteConfiguration, so its hostname-less route cannot merge with Grafana's |
|
|
||||||
| `HTTPRoute <svc>` | the app's own tree (e.g. `monitoring/controllers/home/httproute.yaml`, `infrastructure/networking/cilium/hubble-ui-httproute.yaml`) | `parentRefs: <gateway>/internal#http-internal`, **no `hostnames`** |
|
|
||||||
| `table inet internal_gw` + `internal-gw-firewall.service` | siriussec host (`/etc/nftables.d/internal-gw.nft`) | drop `:8081`+`:8084` from everything but `10.10.0.0/24`, `10.244.0.0/16`, `lo`; the accept rules carry `counter`s so "traffic arrived and was allowed" is provable, not inferred from a 200 |
|
|
||||||
| ufw rules (inserted above the LAN catch-all) | rpi host | **inert since 2026-10-27** — left in place as a belt-and-braces guard in case the Pi is ever relabelled `gateway=true`, but nothing binds those ports on rpi any more, so they just make stale `10.10.0.1:8081` clients time out instead of being refused |
|
|
||||||
| `infrastructure/networking/internal/host-firewall/` | repo | the host artifacts + install/verify instructions |
|
|
||||||
|
|
||||||
Only siriussec runs `cilium-envoy`, so only its `internal_gw` table is load
|
|
||||||
bearing. **If a second node is ever given `gateway=true`**, it needs the same
|
|
||||||
firewall rules *and* its backends co-located, or it will serve 503s for
|
|
||||||
everything (see §7).
|
|
||||||
|
|
||||||
## 3. Current internal services
|
|
||||||
|
|
||||||
| Service | URL (over WireGuard) | Optional client `/etc/hosts` line | Route | Port |
|
|
||||||
|---|---|---|---|---|
|
|
||||||
| Grafana | **`http://10.10.0.2:8081/`** (also `http://grafana.lab.internal:8081/`) | `10.10.0.2 grafana.lab.internal` | `monitoring/grafana` | 8081 |
|
|
||||||
| Hubble UI | **`http://10.10.0.2:8084/`** (also `http://hubble.lab.internal:8084/`) | `10.10.0.2 hubble.lab.internal` | `kube-system/hubble-ui` | 8084 |
|
|
||||||
|
|
||||||
**The rule: every internal service must be reachable as
|
|
||||||
`http://10.10.0.2:<port>/` with no `Host` header and no hosts-file entry**,
|
|
||||||
because phones cannot edit `/etc/hosts`. The bare-IP URL is the one to hand
|
|
||||||
out; the named URL is a convenience for machines that already have the line.
|
|
||||||
|
|
||||||
**`10.10.0.2` is the only serving address.** The Gateways' `status.addresses`
|
|
||||||
lists *every* node InternalIP (`10.10.0.1`, `10.10.0.2`, `10.10.0.5`) regardless
|
|
||||||
of which nodes run `cilium-envoy`, and Cilium ignores `spec.addresses`
|
|
||||||
(cilium#29060), so the status list is **not** a load-balanced VIP and not a
|
|
||||||
"try either IP" guide. `10.10.0.1` and `10.10.0.5` have no listener;
|
|
||||||
`10.10.0.1` times out (ufw DROP), `10.10.0.5` is reachable only as a mesh
|
|
||||||
address. Hand out the bare-IP URL on 10.10.0.2 and nothing else.
|
|
||||||
|
|
||||||
Historical note (fixed 2026-10-27): while rpi carried `gateway=true` its Envoy
|
|
||||||
completed the TCP handshake but could never finish a request to a backend pod
|
|
||||||
on siriussec — every request to `10.10.0.1:8081`/`:8084` hung 5 s and returned
|
|
||||||
**503**, *including from the Pi's own `127.0.0.1`*. That is the co-location
|
|
||||||
fault (SYN-ACK back, no ACK on `reserved:ingress`), and it is why the label now
|
|
||||||
lives on siriussec alone.
|
|
||||||
|
|
||||||
## 4. Add the next internal service
|
|
||||||
|
|
||||||
1. **Confirm the port is firewalled.** `:8081` is closed to the LAN already; a
|
|
||||||
new listener port needs its own rules (see §5). **Do not reuse 8081** — one
|
|
||||||
listener port carries exactly one internal service, so a second
|
|
||||||
hostname-less route can never compete with Grafana's.
|
|
||||||
2. **Deploy the workload** in its own namespace, pinned with
|
|
||||||
`nodeSelector: {kubernetes.io/hostname: siriussec}` (amd64 + local-path; the
|
|
||||||
Pi is arm64 and its listener only serves pods scheduled on the Pi).
|
|
||||||
3. **Add the Gateway** (its own object, its own port, its own
|
|
||||||
RouteConfiguration) — copy `infrastructure/networking/internal/gateway-hubble-ui.yaml`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: gateway.networking.k8s.io/v1
|
|
||||||
kind: Gateway
|
|
||||||
metadata:
|
|
||||||
name: <svc>
|
|
||||||
namespace: internal
|
|
||||||
spec:
|
|
||||||
gatewayClassName: cilium
|
|
||||||
listeners:
|
|
||||||
- name: http-internal
|
|
||||||
protocol: HTTP
|
|
||||||
port: <port> # unique; firewalled first, see §5
|
|
||||||
allowedRoutes: {namespaces: {from: All}}
|
|
||||||
```
|
|
||||||
|
|
||||||
Then the route next to the workload — **without `hostnames`**:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
apiVersion: gateway.networking.k8s.io/v1
|
|
||||||
kind: HTTPRoute
|
|
||||||
metadata:
|
|
||||||
name: <svc>
|
|
||||||
namespace: <ns>
|
|
||||||
spec:
|
|
||||||
parentRefs:
|
|
||||||
- name: <svc> # the Gateway above, NOT `internal`
|
|
||||||
namespace: internal
|
|
||||||
sectionName: http-internal
|
|
||||||
rules:
|
|
||||||
- matches:
|
|
||||||
- path: {type: PathPrefix, value: /}
|
|
||||||
backendRefs:
|
|
||||||
- name: <service>
|
|
||||||
port: <port>
|
|
||||||
```
|
|
||||||
|
|
||||||
A `ReferenceGrant` is only needed for cross-namespace *backends*; the route
|
|
||||||
itself is allowed by `allowedRoutes: All` on the listener.
|
|
||||||
4. Commit, push, reconcile (repo → `gitrepository`, then the app's
|
|
||||||
`kustomization`), then **prove it from the mesh** — bare IP first, because
|
|
||||||
that is the phone path:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -sS -o /dev/null -w '%{http_code}\n' http://10.10.0.2:<port>/ # -> 200/302, never 404
|
|
||||||
curl -sSL -m 6 http://10.10.0.2:<port>/login | head -c 200 # -> HTML, no absolute redirect
|
|
||||||
```
|
|
||||||
5. Add the row to the table in §3.
|
|
||||||
|
|
||||||
## 5. Firewall changes for a new port
|
|
||||||
|
|
||||||
siriussec — add the same three lines with the new port to
|
|
||||||
`/etc/nftables.d/internal-gw.nft` and `systemctl reload-or-restart
|
|
||||||
internal-gw-firewall.service` (it is a oneshot `nft -f`, so re-running is safe):
|
|
||||||
|
|
||||||
```
|
|
||||||
tcp dport <port> iifname "lo" accept
|
|
||||||
tcp dport <port> ip saddr { 10.10.0.0/24, 10.244.0.0/16 } accept
|
|
||||||
tcp dport <port> counter drop
|
|
||||||
```
|
|
||||||
|
|
||||||
rpi — the ufw equivalents, inserted **above** the `allow from 192.168.1.0/24`
|
|
||||||
catch-all (`ufw insert`, never plain `ufw allow`, or the LAN allow matches
|
|
||||||
first):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ufw insert 1 deny to any port <port> proto tcp comment 'internal gateway: wg only'
|
|
||||||
ufw insert 1 allow from 10.10.0.0/24 to any port <port> proto tcp comment 'internal gateway (wg mesh)'
|
|
||||||
ufw insert 2 allow from 10.244.0.0/16 to any port <port> proto tcp comment 'internal gateway (pods)'
|
|
||||||
```
|
|
||||||
|
|
||||||
## 6. Negative tests (run these after every change)
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# 0. From a mesh host: the BARE-IP phone path, and the login page via it.
|
|
||||||
# Grafana must not hard-redirect to a .internal name (no root_url/domain set).
|
|
||||||
curl -sS -m 6 -o /dev/null -w '%{http_code}\n' http://10.10.0.2:8081/ # -> 302 (login), never 404
|
|
||||||
curl -sSL -m 6 -o /dev/null -w '%{http_code} redirects=%{num_redirects}\n' \
|
|
||||||
http://10.10.0.2:8081/login # -> 200, no absolute Location
|
|
||||||
curl -sS -m 6 -D- -o /dev/null http://10.10.0.2:8081/ | grep -i '^location:' # -> /login (relative)
|
|
||||||
|
|
||||||
# 1. From a LAN host (Legion on 192.168.1.0/24, or rpi toward siriussec):
|
|
||||||
# DROP = timeout, not connection-refused and never 200.
|
|
||||||
curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.179:8081/ # -> 000 (timed out)
|
|
||||||
curl -m 3 -sS -o /dev/null -w '%{http_code}\n' http://192.168.1.125:8081/ # -> 000 (timed out)
|
|
||||||
|
|
||||||
# 2. From a mesh host, the named URL must still work:
|
|
||||||
curl -sS -o /dev/null -w '%{http_code}\n' -H 'Host: grafana.lab.internal' http://10.10.0.2:8081/ # -> 302 (login)
|
|
||||||
|
|
||||||
# 3. Not in the public tunnel's ingress list (run on rpi):
|
|
||||||
curl -s http://127.0.0.1:20241/config | python3 -c \
|
|
||||||
"import json,sys; d=json.load(sys.stdin)['config']; print([i.get('hostname') for i in d['ingress']])"
|
|
||||||
|
|
||||||
# 4. The public gateway is untouched:
|
|
||||||
curl -sS -o /dev/null -w '%{http_code}\n' -H 'Host: forgejo.siriusdevops.com' http://10.10.0.2:8080/
|
|
||||||
```
|
|
||||||
|
|
||||||
## 7. Gotchas
|
|
||||||
|
|
||||||
- **A `cluster.local`-style name will not resolve.** Use the bare-IP URL (no
|
|
||||||
DNS at all); an `/etc/hosts` entry plus `http://<name>.lab.internal:<port>/`
|
|
||||||
is a laptop-only convenience. There is no internal DNS zone yet.
|
|
||||||
- **Cilium merges hostname-less routes across listeners of the same Gateway.**
|
|
||||||
Giving the second bare-IP service its own *listener port* is not enough:
|
|
||||||
Cilium compiled both hostname-less `PathPrefix /` routes into one route
|
|
||||||
table, so `10.10.0.2:8081` and `:8082` each answered for **either** backend
|
|
||||||
(measured 9/11 split over 20 requests pre-fix). Each bare-IP service needs
|
|
||||||
its **own Gateway object** (`internal`/8081 → Grafana, `internal/hubble-ui`
|
|
||||||
on 8082 → Hubble), not just its own listener.
|
|
||||||
- **After adding/moving a listener, restart `cilium-envoy`** — the stale route
|
|
||||||
stayed programmed on the old port until
|
|
||||||
`kubectl -n kube-system delete pod -l k8s-app=cilium-envoy` (the pods were
|
|
||||||
6 days old). Verify per port with a repeated-request loop, not a single curl:
|
|
||||||
a 50/50 mix of two backends looks like a flaky service, not a config bug.
|
|
||||||
- **Do not add these hostnames to the cloudflared tunnel** "to make them easier
|
|
||||||
to reach". That is a public exposure of a service that has no authentication
|
|
||||||
story beyond Grafana's own. The tunnel ingress list is the public allow-list.
|
|
||||||
- **`sudo nft -f` is not persistent by itself** — it must go through
|
|
||||||
`internal-gw-firewall.service` (enabled at boot), same as
|
|
||||||
`k8s-api-firewall.service`.
|
|
||||||
- Changing the `internal` Gateway's `allowedRoutes` does not need an Envoy
|
|
||||||
restart; Cilium reconciles the route table. Changing the **listener** (port,
|
|
||||||
protocol) does need the `cilium-envoy` pods restarted
|
|
||||||
(`kubectl -n kube-system delete pod -l k8s-app=cilium-envoy`).
|
|
||||||
- **Only `siriussec` carries `node-role.kubernetes.io/gateway=true`.** Keep it
|
|
||||||
that way: `kubectl get nodes -l node-role.kubernetes.io/gateway=true` must
|
|
||||||
return exactly one node. A 503-after-exactly-5.0 s on a node's own IP (even
|
|
||||||
`127.0.0.1`) means Envoy is running there but the backend pod is not on that
|
|
||||||
node — remove the label rather than firewalling around it. Removing the label
|
|
||||||
deletes the `cilium-envoy` DaemonSet pod on that node within seconds and the
|
|
||||||
ports go with it; no restart of the remaining pod is needed (the Gateway
|
|
||||||
object is unchanged).
|
|
||||||
- **The probe in `monitoring/controllers/home/gateway-probe.yaml` is the flap
|
|
||||||
detector**: blackbox-exporter + a `Probe` for `http://10.10.0.2:8081/` and
|
|
||||||
`:8084/` every 30 s, alerting `InternalGatewayUnreachable`
|
|
||||||
(`probe_success == 0` for 3 min) and `InternalGatewayProbeMissing`
|
|
||||||
(`absent()`) as a `PrometheusRule`. Watch it in Prometheus `/alerts` or
|
|
||||||
Grafana → Alerting. There is no Alertmanager in the stack yet, so nothing is
|
|
||||||
*paged*; the alert is visible, not pushed.
|
|
||||||
|
|
||||||
## 8. Verification log — 2026-10-27 (Grafana)
|
|
||||||
|
|
||||||
Commit `d3741df` on `master`, reconciled by Flux (`gitrepository` first, then
|
|
||||||
`kustomization flux-system`, which created `kustomization monitoring`).
|
|
||||||
|
|
||||||
```
|
|
||||||
# flux
|
|
||||||
NAME READY STATUS
|
|
||||||
monitoring True Applied revision: master@sha1:d3741df...
|
|
||||||
# helm + workloads
|
|
||||||
kube-prometheus-stack True Helm install succeeded for release monitoring/kube-prometheus-stack.v1 with chart kube-prometheus-stack@92.14.0
|
|
||||||
prometheus-kube-prometheus-stack-prometheus-db-... Bound 10Gi RWO local-path
|
|
||||||
pods: grafana 3/3, kube-state-metrics 1/1, operator 1/1, node-exporter 1/1, prometheus 2/2 (all on siriussec)
|
|
||||||
Prometheus CR: retention 7d / retentionSize 8GB, replicas 1, remoteWrite none, PVC 10Gi local-path
|
|
||||||
active scrape targets: 18 up / 0 down
|
|
||||||
|
|
||||||
# positive — from Legion over WireGuard
|
|
||||||
$ curl -sS -o /dev/null -w '%{http_code}' -L http://grafana.lab.internal:8081/
|
|
||||||
200 (POST /login with the secret creds -> 200 "Logged in"; /api/user -> admin)
|
|
||||||
$ curl -sS -o /dev/null -w '%{http_code}' http://10.10.0.2:8081/ # no Host match
|
|
||||||
404 (SUPERSEDED 2026-10-27 04:35Z by §9 — the route now has no
|
|
||||||
hostnames, so this same request is a 302 to /login)
|
|
||||||
|
|
||||||
# negative 1 — LAN (from Legion, 192.168.1.0/24)
|
|
||||||
$ curl -m 3 http://192.168.1.179:8081/ -> timed out (curl 28), http_code 000
|
|
||||||
$ curl -m 3 http://192.168.1.125:8081/ -> timed out (curl 28), http_code 000
|
|
||||||
(nft table inet internal_gw counts the drops on siriussec; ufw rules at
|
|
||||||
positions 1-3 on rpi sit above `allow from 192.168.1.0/24`)
|
|
||||||
|
|
||||||
# negative 2 — internet
|
|
||||||
cloudflared ingress (9 entries): siriusdevops.com, www., forgejo., paaas.,
|
|
||||||
piedmonthomesvc.com, www., siriusgrowthsolutions.com, www., 404-catch-all
|
|
||||||
-> no grafana/lab.internal entry; and `curl -H 'Host: grafana.lab.internal'
|
|
||||||
http://10.10.0.2:8080/` returns 404 (the public gateway has no such route).
|
|
||||||
|
|
||||||
# regression — public ingress intact (from rpi)
|
|
||||||
$ curl -H 'Host: forgejo.siriusdevops.com' http://10.10.0.2:8080/ -> 200
|
|
||||||
|
|
||||||
# grafana provisioning
|
|
||||||
24 dashboards in Grafana (includes Node Exporter / Nodes, Kubernetes /
|
|
||||||
Compute Resources / Pod, ... / Cluster, ... / Namespace); datasource
|
|
||||||
`kube-prometheus-stack-grafana-datasource` -> Prometheus; anonymous disabled,
|
|
||||||
allow_sign_up false; admin creds from Secret monitoring/grafana-admin
|
|
||||||
(admin-user / admin-password).
|
|
||||||
```
|
|
||||||
|
|
||||||
## 9. Verification log — 2026-10-27 (bare-IP fix: Grafana on `http://10.10.0.2:8081/`)
|
|
||||||
|
|
||||||
Commits `8939cbd` (Grafana: drop `hostnames` from the route) and, from the
|
|
||||||
concurrent Hubble card, `dcb708d` (Hubble moved to its own Gateway object —
|
|
||||||
required, see §7). Flux `monitoring` applied `master@sha1:dcb708d…`, which
|
|
||||||
contains `8939cbd`.
|
|
||||||
|
|
||||||
```
|
|
||||||
# the change
|
|
||||||
$ kubectl -n monitoring get httproute grafana -o yaml | sed -n '/^spec:/,/^status:/p'
|
|
||||||
spec:
|
|
||||||
parentRefs:
|
|
||||||
- {group: gateway.networking.k8s.io, kind: Gateway, name: internal, namespace: internal, sectionName: http-internal}
|
|
||||||
rules:
|
|
||||||
- backendRefs: [{group: "", kind: Service, name: kube-prometheus-stack-grafana, port: 80, weight: 1}]
|
|
||||||
matches: [{path: {type: PathPrefix, value: /}}]
|
|
||||||
# no `hostnames:` — any Host on the listener matches
|
|
||||||
|
|
||||||
$ kubectl -n flux-system get kustomizations | grep monitoring
|
|
||||||
monitoring True Applied revision: master@sha1:dcb708dff4cd3952436f4d5887e071dbde703945
|
|
||||||
|
|
||||||
# PHONE PATH — bare IP, no hosts entry, no Host header. From Legion (mesh):
|
|
||||||
$ curl -sS -D- -o /dev/null http://10.10.0.2:8081/
|
|
||||||
HTTP/1.1 302 Found
|
|
||||||
location: /login # relative — no absolute .internal redirect
|
|
||||||
server: envoy
|
|
||||||
$ curl -sSL -o /dev/null -w '%{http_code} final=%{url_effective} redirects=%{num_redirects}\n' \
|
|
||||||
http://10.10.0.2:8081/login
|
|
||||||
200 final=http://10.10.0.2:8081/login redirects=0
|
|
||||||
<title>Grafana # real login HTML, 0 redirects
|
|
||||||
|
|
||||||
# same request from rpi (source 10.10.0.1) and from a pod in the cluster:
|
|
||||||
$ ssh sirius@192.168.1.125 'curl -sS -o /dev/null -w "%{http_code}" http://10.10.0.2:8081/' -> 302
|
|
||||||
$ kubectl -n monitoring run gw-probe --rm -i --image=curlimages/curl:8.10.1 -- \
|
|
||||||
curl -sS -o /dev/null -w 'pod_bare=%{http_code}' http://10.10.0.2:8081/
|
|
||||||
pod_bare=302
|
|
||||||
|
|
||||||
# named URL still works
|
|
||||||
$ curl -sS -o /dev/null -w '%{http_code}' -H 'Host: grafana.lab.internal' http://10.10.0.2:8081/ -> 302
|
|
||||||
|
|
||||||
# port ownership — 8081 is Grafana's alone (15 consecutive requests, no hubble)
|
|
||||||
8081: grafana=15 hubble=0 other=0
|
|
||||||
$ kubectl -n internal get gateway internal -o jsonpath='{range .status.listeners[*]}{.name} attached={.attachedRoutes}{"\n"}{end}'
|
|
||||||
http-internal attached=1
|
|
||||||
|
|
||||||
# negative 1 — LAN (echoed from Legion, 192.168.1.126 on the LAN, while on WG too)
|
|
||||||
$ curl -m 4 http://192.168.1.179:8081/ -> curl: (28) timed out, http_code 000
|
|
||||||
$ curl -m 4 http://192.168.1.125:8081/ -> curl: (28) timed out, http_code 000
|
|
||||||
|
|
||||||
# negative 2 — internet (cloudflared ingress on rpi: still 8 hostnames + 404 catch-all)
|
|
||||||
siriusdevops.com, www., forgejo., paaas., piedmonthomesvc.com, www.,
|
|
||||||
siriusgrowthsolutions.com, www., -> http_status:404
|
|
||||||
-> no grafana/lab.internal entry
|
|
||||||
$ curl -H 'Host: grafana.lab.internal' http://10.10.0.2:8080/ -> 404 (public gateway has no such route)
|
|
||||||
|
|
||||||
# regression — public ingress intact (from rpi)
|
|
||||||
$ curl -H 'Host: forgejo.siriusdevops.com' http://10.10.0.2:8080/ -> 200
|
|
||||||
|
|
||||||
# phone peer at the time of the fix (Pi hub): still offline, reconnect required
|
|
||||||
$ sudo wg show wg0 latest-handshakes
|
|
||||||
A1NSWT7K9Dz…("Peer SiriusMobile", 10.10.0.4) age=570919s (~6.6 days)
|
|
||||||
```
|
|
||||||
|
|
||||||
**The URL to use on the phone: `http://10.10.0.2:8081/`** — tunnel connected,
|
|
||||||
client `AllowedIPs` covering `10.10.0.0/24`.
|
|
||||||
|
|
||||||
## 10. Verification log — 2026-10-27 (Hubble UI on `http://10.10.0.2:8084/`)
|
|
||||||
|
|
||||||
Hubble relay + UI are chart values in `infrastructure/networking/cilium/values.yaml`
|
|
||||||
(`hubble.relay.enabled`, `hubble.ui.enabled`, both pinned to siriussec); the UI
|
|
||||||
is exposed by `internal/hubble-ui` (port **8084**, own Gateway, no `hostnames`).
|
|
||||||
|
|
||||||
**Port choice cost a cycle.** The first attempt used 8082, which is free on
|
|
||||||
siriussec but held on **rpi** by the leftover `handyman-site` Docker container
|
|
||||||
(`127.0.0.1:8082`; its nginx holds `127.0.0.1:8083`). Cilium binds the listener
|
|
||||||
`0.0.0.0:8082` on *both* gateway nodes, so rpi's Envoy rejected the config
|
|
||||||
(`cannot bind '0.0.0.0:8082': Address already in use`, ~640 lines/s) and
|
|
||||||
restart-looped the node that fronts the public ingress. 8084 was verified free
|
|
||||||
on both nodes before the move. **Check `ss -lntH "sport = :<port>" | wc -l` = 0
|
|
||||||
on every node with `k8s-app=cilium-envoy`, not just the control-plane.**
|
|
||||||
|
|
||||||
```
|
|
||||||
# values -> rendered config (not a guess)
|
|
||||||
$ kubectl -n kube-system get hr cilium -o jsonpath='{.status.conditions[?(@.type=="Ready")].status} {.status.lastAttemptedRevision}'
|
|
||||||
True 1.20.1 # Ready=True
|
|
||||||
$ kubectl -n kube-system get cm cilium-values-* -o jsonpath='{.data.values\.yaml}' | grep -A2 ' relay:'
|
|
||||||
relay: {enabled: true, replicas: 1, nodeSelector: {kubernetes.io/hostname: siriussec}}
|
|
||||||
$ kubectl -n kube-system get cm cilium-config -o jsonpath='{.data.hubble-metrics}'
|
|
||||||
flow drop tcp port-distribution icmp httpV2 dns # + hubble-metrics-server :9965
|
|
||||||
|
|
||||||
$ kubectl -n kube-system get pods | grep -E 'hubble'
|
|
||||||
hubble-relay-6f87554656-wznnw 1/1 Running
|
|
||||||
hubble-ui-567ccf4fbd-skkwm 2/2 Running
|
|
||||||
$ kubectl -n kube-system logs deploy/hubble-relay --tail=3
|
|
||||||
msg=Connecting address=10.10.0.1:4244 tls=true peer=rpi
|
|
||||||
msg=Connected address=10.10.0.2:4244 tls=true peer=siriussec
|
|
||||||
msg=Connected address=10.10.0.5:4244 tls=true peer=linode
|
|
||||||
|
|
||||||
# scrape targets (Prometheus CR selects label release=kube-prometheus-stack)
|
|
||||||
serviceMonitor/kube-system/hubble/0 up 10.10.0.1:9965 / 10.10.0.2:9965 / 10.10.0.5:9965
|
|
||||||
serviceMonitor/kube-system/hubble-relay/0 up 10.244.0.75:9966
|
|
||||||
serviceMonitor/kube-system/cilium-operator/0 up 10.10.0.2:9963
|
|
||||||
23 active targets, 23 up / 0 down (was 18/18 before this card)
|
|
||||||
|
|
||||||
# flows are real (Prometheus)
|
|
||||||
hubble_flows_processed_total = 4586 hubble_drop_total = 8
|
|
||||||
hubble_tcp_flags_total = 1471 hubble_icmp_total = 36
|
|
||||||
hubble_flows_processed_total{type="PolicyVerdict"} = 178 # policy-verdict data
|
|
||||||
hubble_http_requests_total = 281
|
|
||||||
# relay's own view: hubble_relay_pool_peer_connection_status{status="READY"} = 3
|
|
||||||
|
|
||||||
# PHONE PATH — bare IP, no hosts entry, no Host header (from Legion)
|
|
||||||
$ curl -sS -o /dev/null -w '%{http_code}' http://10.10.0.2:8084/ -> 200
|
|
||||||
$ curl -sS http://10.10.0.2:8084/ | grep -o '<title>.*</title>' -> <title>Hubble UI</title>
|
|
||||||
$ curl -sS -o /dev/null -w '%{http_code}' http://10.10.0.2:8081/ -> 302 (Grafana, unbroken)
|
|
||||||
|
|
||||||
# the UI actually works, not just its shell: headless Chromium against the bare IP
|
|
||||||
# /?namespace=kube-system -> service map rendered, status dot green,
|
|
||||||
# "64.7 flows/s", "3/3 nodes", flow table populated
|
|
||||||
# backend log: GetEventsRequest parsed (ServiceMapStream) + watcher is running
|
|
||||||
# (ControlStream) -> hubble-relay:80, FlowStream streaming
|
|
||||||
$ kubectl -n kube-system logs deploy/hubble-ui -c backend --tail=2 | grep -c Stream
|
|
||||||
2
|
|
||||||
|
|
||||||
# negative 1 — LAN (from Legion, 192.168.1.0/24)
|
|
||||||
$ curl -m 3 http://192.168.1.179:8084/ -> 000 (timeout) # siriussec nft
|
|
||||||
$ curl -m 3 http://192.168.1.125:8084/ -> 000 (timeout) # rpi ufw
|
|
||||||
# negative 2 — internet: no hubble/lab.internal entry in the cloudflared ingress
|
|
||||||
# (9 hostnames, all public sites), and no tunnel points at 8084.
|
|
||||||
# regression: forgejo.siriusdevops.com -> 200 through the tunnel; Grafana 302.
|
|
||||||
|
|
||||||
# envoy health after the move
|
|
||||||
kubectl -n kube-system get pods -l k8s-app=cilium-envoy # both 1/1, RESTARTS 0
|
|
||||||
logs <rpi pod> --since=60s | grep -c 'cannot bind' # 0
|
|
||||||
```
|
|
||||||
|
|
||||||
**Only `10.10.0.2` answers.** As of 2026-10-27 that is true structurally, not
|
|
||||||
just in practice: `10.10.0.1:8081/:8084` have **no listener** (rpi lost
|
|
||||||
`gateway=true` — see §12); before the fix they returned **503 after exactly
|
|
||||||
5 s, even from rpi's own `127.0.0.1`**, because Envoy on a node that does not
|
|
||||||
run the backend completes the TCP handshake and never ACKs. The Gateway status
|
|
||||||
still lists all three node addresses (Cilium ignores `spec.addresses`); the
|
|
||||||
serving address is the one the backends are pinned to, `10.10.0.2`.
|
|
||||||
|
|
||||||
## 11. Internal DNS: the `lab.internal` zone
|
|
||||||
|
|
||||||
Facts: zone `lab.internal`, resolver `10.10.0.1` (and `10.20.0.2`), records
|
|
||||||
`grafana.lab.internal` and `hubble.lab.internal` → `10.10.0.2`, configured by
|
|
||||||
`infrastructure/networking/internal/dns/`. The record does **not** carry a
|
|
||||||
port: Grafana stays on `:8081`, Hubble UI on `:8084`, so the URLs are
|
|
||||||
`http://grafana.lab.internal:8081/` and `http://hubble.lab.internal:8084/`.
|
|
||||||
|
|
||||||
### 11.1 What "split DNS" can and cannot mean here
|
|
||||||
|
|
||||||
The WireGuard clients in use (Android, iOS, and the desktop clients) hand the
|
|
||||||
tunnel's DNS server to the OS as **the device resolver for everything while
|
|
||||||
the tunnel is up**. There is no client-side per-domain split, and nothing on
|
|
||||||
the server side can create one. So:
|
|
||||||
|
|
||||||
- the resolver on the hub **answers `lab.internal` itself** (authoritative,
|
|
||||||
`local=/lab.internal/`, never forwarded), and
|
|
||||||
- **forwards every other query** to the upstreams in the Pi's
|
|
||||||
`/etc/resolv.conf` (today `100.100.100.100` = Tailscale MagicDNS, which
|
|
||||||
forwards to the ISP resolvers `137.118.204.9` / `137.118.1.32`).
|
|
||||||
|
|
||||||
Public resolution therefore keeps working *through* the tunnel resolver — it
|
|
||||||
is not "split on the client", it is "one resolver that knows one private zone
|
|
||||||
and forwards the rest". Public names stay on public DNS; there are no
|
|
||||||
split-horizon records for `siriusdevops.com`, `piedmonthomesvc.com` or
|
|
||||||
`siriusgrowthsolutions.com` and there must not be.
|
|
||||||
|
|
||||||
**The risk this creates:** while the tunnel is up, a dead resolver is a dead
|
|
||||||
internet connection for that device. Rollback is in §11.6.
|
|
||||||
|
|
||||||
### 11.2 Where it runs, and why not in the cluster
|
|
||||||
|
|
||||||
`dnsmasq` **on rpi** — the WireGuard hub, `10.10.0.1` on `wg0` and `10.20.0.2`
|
|
||||||
on `wg-remote`. It is a host service, deliberately **not** behind Cilium's
|
|
||||||
internal Gateway: those listeners have their own failure mode (`t_e9564aa3`,
|
|
||||||
Envoy on the wrong node answers 503 after 5 s) and DNS must not inherit it.
|
|
||||||
Host ports on the Pi over WireGuard work (SSH on `10.10.0.1:22` is proof).
|
|
||||||
|
|
||||||
dnsmasq was already the Pi's resolver (it also answers `.rpi.local`), so this
|
|
||||||
extends it instead of adding a second resolver on port 53. Artifacts:
|
|
||||||
|
|
||||||
| File | Installed to | Purpose |
|
|
||||||
|---|---|---|
|
|
||||||
| `dns/lab-internal.conf` | `/etc/dnsmasq.d/lab-internal.conf` | zone authority, `addn-hosts`, bind list |
|
|
||||||
| `dns/lab-internal.hosts` | `/etc/dnsmasq-lab-internal.hosts` | the records (hosts(5) syntax) |
|
|
||||||
| `dns/rpi-ufw-dns.sh` | — | ufw allow/deny for `:53` |
|
|
||||||
| `dns/install-rpi-dns.sh` | — | installs all of the above, restarts, prints bind view |
|
|
||||||
|
|
||||||
The hosts file lives **outside** `/etc/dnsmasq.d` on purpose: the unit passes
|
|
||||||
`-7 /etc/dnsmasq.d`, so every file in that directory is parsed as config, and a
|
|
||||||
hosts file there fails the start with `bad option at line 9`.
|
|
||||||
|
|
||||||
Install / re-install (host artifacts — a Pi reinstall has to re-run this):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bash infrastructure/networking/internal/dns/install-rpi-dns.sh # as root on rpi
|
|
||||||
```
|
|
||||||
|
|
||||||
### 11.3 Listen addresses and the firewall boundary
|
|
||||||
|
|
||||||
`bind-dynamic` + `interface=lo`, `interface=wg0`, `interface=wg-remote`:
|
|
||||||
53 is bound on `127.0.0.1`, `10.10.0.1`, `10.20.0.2` (and `::1`) and **nowhere
|
|
||||||
else** — not on `192.168.1.125`, not on the tailscale address. `bind-dynamic`
|
|
||||||
also means a WireGuard interface that is down at boot is picked up when it
|
|
||||||
appears, with no restart and no hard `Requires=` on a `wg-quick@` template unit.
|
|
||||||
|
|
||||||
ufw is the second layer (and the one that produces the DROP evidence), inserted
|
|
||||||
above the `allow from 192.168.1.0/24` catch-all:
|
|
||||||
|
|
||||||
```
|
|
||||||
53/udp,tcp ALLOW IN 10.10.0.0/24 # mesh (siriussec, Pi-hub peers)
|
|
||||||
53/udp,tcp ALLOW IN 10.20.0.0/24 # remote hub + its spokes (the phone, Legion)
|
|
||||||
53/udp,tcp ALLOW IN 10.244.0.0/16 # pods
|
|
||||||
53/udp,tcp DENY IN Anywhere # LAN, tailscale, internet
|
|
||||||
```
|
|
||||||
|
|
||||||
`10.20.0.0/24` is not optional: the phone and Legion are spokes of the
|
|
||||||
**linode** hub (`10.20.0.1`), so their DNS packets reach the Pi on `wg-remote`
|
|
||||||
with source `10.20.0.3` / `10.20.0.5`. With only the mesh subnet allowed, the
|
|
||||||
hub-spoke clients time out (§11.7 negative 3).
|
|
||||||
|
|
||||||
No Cloudflare change: the tunnel's ingress list is an allow-list of HTTP
|
|
||||||
hostnames pointing at `:8080`; UDP/TCP 53 is not proxied by it and there is no
|
|
||||||
port-forward on the LAN edge. `*.lab.internal` has no public record.
|
|
||||||
|
|
||||||
### 11.4 Adding a record
|
|
||||||
|
|
||||||
1. Add one line to `dns/lab-internal.hosts` — `<address>\t<name>` — commit it.
|
|
||||||
2. On rpi: `sudo install -m 0644 dns/lab-internal.hosts /etc/dnsmasq-lab-internal.hosts
|
|
||||||
&& sudo systemctl reload dnsmasq` (a reload re-reads `addn-hosts`; no restart,
|
|
||||||
no dropped queries).
|
|
||||||
3. Verify: `dig +short <name> @10.10.0.1`.
|
|
||||||
|
|
||||||
Only `lab.internal` is authoritative. A query for anything else, *including*
|
|
||||||
`siriusdevops.com`, is forwarded — do not add public names here.
|
|
||||||
|
|
||||||
Which address to record: **`10.10.0.2`** today, because siriussec is the only
|
|
||||||
node carrying `node-role.kubernetes.io/gateway=true` and therefore the only one
|
|
||||||
with a listener that can complete a request to the backends. If that changes
|
|
||||||
(the label moving back to rpi once the arm64/Envoy co-location issue is solved),
|
|
||||||
it is a one-line change in `dns/lab-internal.hosts` + reload.
|
|
||||||
|
|
||||||
### 11.5 Client configuration
|
|
||||||
|
|
||||||
The phone is **`Pixel 9 Pro`**, WireGuard peer `10.20.0.3` on the **linode**
|
|
||||||
hub (`10.20.0.1:51820`) — not a `wg0` peer of the Pi: its handshake is
|
|
||||||
seconds old on the linode hub, while the Pi's `wg0` peer `10.10.0.4`
|
|
||||||
(`Peer SiriusMobile`) has been stale for days. Its DNS therefore has to be set
|
|
||||||
in the phone's own WireGuard profile. The Pi's `wg0.conf` peers (and the
|
|
||||||
`wgportal` DB) are *not* where the phone's DNS lives, and wgportal is not even
|
|
||||||
running on the Pi today (`docker ps` has no wgportal container) — so nothing on
|
|
||||||
the server side can push this; do not go looking for a portal toggle.
|
|
||||||
|
|
||||||
**Android (WireGuard app) — 3 steps:**
|
|
||||||
|
|
||||||
1. Open the WireGuard app → tap the tunnel → pencil (Edit) → **Interface**
|
|
||||||
section → **DNS servers** → enter `10.10.0.1` (leave "Excluded applications"
|
|
||||||
alone).
|
|
||||||
2. Save, then toggle the tunnel **off and on** (Android keeps the old
|
|
||||||
`resolver1` until the tunnel restarts).
|
|
||||||
3. Check: browser to `http://grafana.lab.internal:8081/` → login page; and any
|
|
||||||
public site still loads (proof forwarding works).
|
|
||||||
|
|
||||||
If that profile's `AllowedIPs` does not cover `10.10.0.0/24`, use **`10.20.0.2`**
|
|
||||||
(the Pi's address on the hub subnet) instead — both answer, both are the same
|
|
||||||
resolver.
|
|
||||||
|
|
||||||
**iOS:** WireGuard app → tunnel → Edit → *DNS Servers* → `10.10.0.1` → Save →
|
|
||||||
toggle off/on.
|
|
||||||
|
|
||||||
**Desktop (wg-quick):** in the tunnel's `[Interface]` add `DNS = 10.10.0.1`
|
|
||||||
and, because this is a non-systemd-resolved-specific option,
|
|
||||||
`resolvconf`/`openresolv` must be present (`wg-quick` uses it to point the
|
|
||||||
system resolver at the tunnel); then `wg-quick down <if> && wg-quick up <if>`.
|
|
||||||
There is no per-domain split — the whole machine uses it while the tunnel is
|
|
||||||
up.
|
|
||||||
|
|
||||||
Do not point a **cluster node** at this resolver: nodes and pods must keep
|
|
||||||
their own DNS (`CoreDNS` / `/etc/resolv.conf`) or kubelet and pod lookups will
|
|
||||||
break. This is for client devices only.
|
|
||||||
|
|
||||||
### 11.6 Rollback (do this first when DNS "breaks the internet")
|
|
||||||
|
|
||||||
On the device: WireGuard app → tunnel → Edit → clear the **DNS servers** field
|
|
||||||
→ Save → toggle the tunnel off/on. That restores the OS resolver immediately.
|
|
||||||
On the server: `sudo systemctl disable --now dnsmasq` stops the Pi's resolver
|
|
||||||
(don't — it also serves `.rpi.local`); to remove only the zone, delete
|
|
||||||
`/etc/dnsmasq.d/lab-internal.conf` and `/etc/dnsmasq-lab-internal.hosts` and
|
|
||||||
`systemctl restart dnsmasq`. To close the port again, remove the six `wg-dns`
|
|
||||||
ufw rules (`ufw status numbered`, then `ufw delete <n>`).
|
|
||||||
|
|
||||||
### 11.7 Verification log — 2026-10-27
|
|
||||||
|
|
||||||
Resolver: `dnsmasq` 2.91 on rpi, enabled at boot (`systemctl is-enabled dnsmasq`
|
|
||||||
= `enabled`), ufw `enabled`. Listeners (no `0.0.0.0`, no LAN address):
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo ss -lntuH 'sport = :53'
|
|
||||||
udp 127.0.0.1:53 udp 10.10.0.1:53 udp 10.20.0.2:53 udp [::1]:53
|
|
||||||
tcp 127.0.0.1:53 tcp 10.10.0.1:53 tcp 10.20.0.2:53 tcp [::1]:53
|
|
||||||
$ sudo journalctl -u dnsmasq -n 4
|
|
||||||
using nameserver 100.100.100.100#53 # forwarded upstreams (tailscale MagicDNS)
|
|
||||||
using only locally-known addresses for lab.internal
|
|
||||||
read /etc/dnsmasq-lab-internal.hosts - 2 names
|
|
||||||
```
|
|
||||||
|
|
||||||
`10.10.0.1:8081`/`:8084` flap. `:53` does not: it is a host socket, not Envoy.
|
|
||||||
|
|
||||||
**Positive — from a WireGuard client (Legion, `10.20.0.5`, via the linode hub):**
|
|
||||||
|
|
||||||
```
|
|
||||||
$ dig +short grafana.lab.internal @10.10.0.1 -> 10.10.0.2
|
|
||||||
$ dig +short hubble.lab.internal @10.10.0.1 -> 10.10.0.2
|
|
||||||
$ dig +short grafana.lab.internal @10.20.0.2 -> 10.10.0.2
|
|
||||||
$ dig +tcp +short grafana.lab.internal @10.10.0.1 -> 10.10.0.2
|
|
||||||
$ dig +short example.com @10.10.0.1 -> 104.20.23.154 / 172.66.147.243 # forwarding
|
|
||||||
$ dig nosuch.lab.internal @10.10.0.1 -> status: NXDOMAIN # authoritative, not forwarded
|
|
||||||
```
|
|
||||||
|
|
||||||
From a mesh peer (`siriussec`, `10.10.0.2`): all three names `rcode 0`
|
|
||||||
(`grafana.lab.internal`, `hubble.lab.internal`, `example.com`). From the Pi's
|
|
||||||
own loopback: same, plus `nope.lab.internal` → `NXDOMAIN`.
|
|
||||||
|
|
||||||
**Negative — LAN and counters** (from Legion on `192.168.1.126`, same host that
|
|
||||||
resolved fine over the tunnel a second earlier):
|
|
||||||
|
|
||||||
```
|
|
||||||
$ dig +time=3 grafana.lab.internal @192.168.1.125 -> timed out, no servers could be reached
|
|
||||||
$ dig +tcp +time=3 grafana.lab.internal @192.168.1.125 -> timed out
|
|
||||||
$ sudo iptables -L ufw-user-input -n -v | grep dpt:53
|
|
||||||
2 120 ACCEPT tcp 10.20.0.0/24 dpt:53 # hub spokes (the phone's path)
|
|
||||||
3 188 ACCEPT udp 10.10.0.0/24 dpt:53 # mesh
|
|
||||||
7 602 ACCEPT udp 10.20.0.0/24 dpt:53
|
|
||||||
3 180 DROP tcp 0.0.0.0/0 dpt:53 # LAN / internet
|
|
||||||
1 89 DROP udp 0.0.0.0/0 dpt:53
|
|
||||||
```
|
|
||||||
|
|
||||||
**Regression:** `http://10.10.0.2:8081/` → 302 (Grafana login), `:8084/` → 200
|
|
||||||
(Hubble UI), public sites through the tunnel unchanged (no Cloudflare object
|
|
||||||
touched).
|
|
||||||
|
|
||||||
**Reboot survival:** `systemctl is-enabled dnsmasq` = `enabled`; the unit
|
|
||||||
`Requires=network-online.target` and has **no** `Requires=`/`After=` on any
|
|
||||||
`wg-quick@` template (which is `enabled` but currently `inactive` because `wg0`
|
|
||||||
was brought up by hand — a hard dependency would fail the boot). `bind-dynamic`
|
|
||||||
picks up `wg0`/`wg-remote` whenever they appear. Records and the bind list live
|
|
||||||
in `/etc/dnsmasq*`, not in `/run`; ufw rules are persistent.
|
|
||||||
|
|
||||||
## 12. Verification log — 2026-10-27 (the flap: rpi was a second, broken gateway node)
|
|
||||||
|
|
||||||
Symptom Lance saw: the internal dashboards "work / don't work" from his phone,
|
|
||||||
while they were rock-steady from a laptop. Nothing was flapping at 10.10.0.2 —
|
|
||||||
the flapping address was **10.10.0.1**.
|
|
||||||
|
|
||||||
**Root cause.** rpi carried `node-role.kubernetes.io/gateway=true` alongside
|
|
||||||
siriussec, so `cilium-envoy` ran there and bound `0.0.0.0:8080/8081/8084`. Its
|
|
||||||
Envoy completes TCP to a backend pod on siriussec but never finishes the
|
|
||||||
request (SYN-ACK back, no ACK on `reserved:ingress`), so every request on the Pi
|
|
||||||
hung and then failed. Fixed by removing the label: **one gateway node, one
|
|
||||||
serving address.**
|
|
||||||
|
|
||||||
**Premise corrected — the Pi's listener was not "bound but unresponsive".** A
|
|
||||||
4 s `curl` timeout made it look like a dead socket; the socket is fine and
|
|
||||||
answers. The exact shape of the failure is a **503 after 5.000 s**, which is the
|
|
||||||
upstream-connect timeout, not a stuck accept loop (`ss -lnt` Recv-Q 0, backlog
|
|
||||||
never filled):
|
|
||||||
|
|
||||||
```
|
|
||||||
# on rpi, before the fix
|
|
||||||
$ curl -s -o /dev/null -m 15 -w '%{http_code} %{time_total}\n' http://127.0.0.1:8081/
|
|
||||||
503 5.003515
|
|
||||||
$ curl -s -o /dev/null -m 15 -w '%{http_code} %{time_total}\n' http://127.0.0.1:8084/
|
|
||||||
503 5.003963
|
|
||||||
$ curl -s -o /dev/null -m 15 -w '%{http_code} %{time_total}\n' http://10.10.0.1:8081/
|
|
||||||
503 5.000658
|
|
||||||
```
|
|
||||||
|
|
||||||
**Envoy's own config (admin unix socket), pre-fix** — all three listeners are
|
|
||||||
identical in shape, which rules out a per-listener config fault:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ sudo curl -s --unix-socket /var/run/cilium/envoy/sockets/admin.sock \
|
|
||||||
http://localhost/config_dump
|
|
||||||
LISTENER internal/cilium-gateway-hubble-ui/listener addr={'address': '0.0.0.0', 'port_value': 8084}
|
|
||||||
LISTENER gateway-system/cilium-gateway-public/listener addr={'address': '0.0.0.0', 'port_value': 8080}
|
|
||||||
LISTENER internal/cilium-gateway-internal/listener addr={'address': '0.0.0.0', 'port_value': 8081}
|
|
||||||
transparent=None use_original_dst=None
|
|
||||||
listener_filters=['envoy.filters.listener.tls_inspector', 'cilium.bpf_metadata']
|
|
||||||
FC match: {"transport_protocol": "raw_buffer"} # no per-address filter chains
|
|
||||||
```
|
|
||||||
|
|
||||||
Killed hypotheses: no `original_dst` / address-scoped filter chains (so the
|
|
||||||
destination IP is irrelevant — that is why `127.0.0.1` failed the same way), no
|
|
||||||
missing bind, no firewall. What differed was **which node the Envoy pod ran on**.
|
|
||||||
|
|
||||||
```
|
|
||||||
# the fix: exactly one node carries the label
|
|
||||||
$ kubectl label node rpi node-role.kubernetes.io/gateway-
|
|
||||||
node/rpi unlabeled
|
|
||||||
$ kubectl get nodes -l node-role.kubernetes.io/gateway=true -o name
|
|
||||||
node/siriussec
|
|
||||||
$ kubectl -n kube-system get pods -l k8s-app=cilium-envoy -o wide
|
|
||||||
cilium-envoy-xfkfq 1/1 Running 0 10.10.0.2 siriussec # the rpi pod is gone
|
|
||||||
```
|
|
||||||
|
|
||||||
`Gateway.status.addresses` still lists `10.10.0.1 10.10.0.2 10.10.0.5` (every
|
|
||||||
node InternalIP) and Cilium ignores `spec.addresses` (cilium#29060), so that
|
|
||||||
field is not a VIP and not a "try either IP" list. Also note the Pi's ufw accept
|
|
||||||
rules never showed a packet counter while requests to `10.10.0.1:8081` *were*
|
|
||||||
reaching Envoy (proved by the 503 body) — `ufw status` does not expose counters,
|
|
||||||
and "0 packets" there is not evidence the packet never arrived.
|
|
||||||
|
|
||||||
**Matrix after the fix** (`curl -m 6`, code + seconds):
|
|
||||||
|
|
||||||
| Vantage point | 10.10.0.1:8081 | 10.10.0.1:8084 | 10.10.0.2:8081 | 10.10.0.2:8084 |
|
|
||||||
|---|---|---|---|---|
|
|
||||||
| Legion over WG (10.20.0.5 → mesh) | 000 (6.00, ufw DROP) | 000 (6.00) | **302** (0.11) | **200** (0.11) |
|
|
||||||
| rpi itself, `10.10.0.1` | 000 (0.0002, no listener) | 000 (0.0002) | **302** (0.003) | **200** (0.002) |
|
|
||||||
| rpi itself, `127.0.0.1` | 000 (0.0002, no listener) | 000 (0.0002) | — | — |
|
|
||||||
| pod on siriussec (10.244.0.118) | 000 (0.0006) | 000 (0.0007) | **302** (0.001) | **200** (0.001) |
|
|
||||||
|
|
||||||
`sudo ss -lntH` on rpi: **0** sockets on 8081/8084 (was 4 + 4, reuseport).
|
|
||||||
|
|
||||||
**Firewall counters — the working path is provably accepted, not just "no
|
|
||||||
error"** (the accept rules now carry `counter`):
|
|
||||||
|
|
||||||
```
|
|
||||||
$ curl http://10.10.0.2:8081/ ; curl http://10.10.0.2:8084/ # from Legion, a pod, and locally on siriussec
|
|
||||||
$ sudo nft list table inet internal_gw # on siriussec
|
|
||||||
tcp dport { 8081, 8084 } iifname "lo" counter packets 48 bytes 3200 accept
|
|
||||||
tcp dport { 8081, 8084 } ip saddr { 10.10.0.0/24, 10.244.0.0/16 } counter packets 948 bytes 164449 accept
|
|
||||||
tcp dport { 8081, 8084 } counter packets 17 bytes 1020 drop # LAN attempts
|
|
||||||
```
|
|
||||||
|
|
||||||
**Flap detection** — `monitoring/controllers/home/gateway-probe.yaml`
|
|
||||||
(blackbox-exporter on siriussec + a `Probe` every 30 s + `PrometheusRule`
|
|
||||||
`InternalGatewayUnreachable` / `InternalGatewayProbeMissing`):
|
|
||||||
|
|
||||||
```
|
|
||||||
$ kubectl -n flux-system get kustomization monitoring -o jsonpath='{.status.lastAppliedRevision}'
|
|
||||||
master@sha1:48b2b6a...
|
|
||||||
$ kubectl -n monitoring get pods | grep blackbox
|
|
||||||
blackbox-exporter-78b95b789c-b4gl8 1/1 Running
|
|
||||||
$ # /api/v1/targets (Prometheus, port-forward)
|
|
||||||
probe/monitoring/internal-gateway http://10.10.0.2:8081/ up
|
|
||||||
probe/monitoring/internal-gateway http://10.10.0.2:8084/ up
|
|
||||||
probe_success{job="internal-gateway"} 1, 1
|
|
||||||
# it also caught a real flap while this card was being verified: the concurrent
|
|
||||||
# Grafana-persistence card recreated the pod and 8081 answered 503 for ~25 s.
|
|
||||||
# Negative proof of the detector: a third target pointed at the (dead)
|
|
||||||
# 10.10.0.1:8081 produced probe_success 0 and
|
|
||||||
# ALERTS{alertname="InternalGatewayUnreachable",alertstate="pending",
|
|
||||||
# instance="http://10.10.0.1:8081/"} = 1
|
|
||||||
# (state cleared when Flux re-applied the Probe from git before `for: 3m`
|
|
||||||
# elapsed, so `firing` was not observed end-to-end).
|
|
||||||
```
|
|
||||||
|
|
||||||
There is **no Alertmanager** in the stack, so this is visible in Prometheus
|
|
||||||
`/alerts` and Grafana → Alerting, not paged. Next step if a page is wanted: add
|
|
||||||
a contact point/receiver, not another probe.
|
|
||||||
|
|
||||||
The probe catches the **symptom**; `GatewayNodeCountNotOne`
|
|
||||||
(`count(kube_node_role{role="gateway"}) != 1`, 5 m) catches the **cause** —
|
|
||||||
kube-state-metrics exposes role labels as `kube_node_role`, so relabelling a
|
|
||||||
node is visible without a second scrape target. Both were proved by putting the
|
|
||||||
bug back on purpose:
|
|
||||||
|
|
||||||
```
|
|
||||||
$ kubectl label node rpi node-role.kubernetes.io/gateway=true --overwrite
|
|
||||||
node/rpi labeled
|
|
||||||
$ kubectl -n kube-system get pods -l k8s-app=cilium-envoy --no-headers
|
|
||||||
cilium-envoy-fwcqm Running rpi # the second Envoy is back
|
|
||||||
cilium-envoy-xfkfq Running siriussec
|
|
||||||
# the original fault, reproduced exactly, from rpi itself:
|
|
||||||
$ curl -m 15 -w '%{http_code} %{time_total}\n' http://10.10.0.1:8081/ -> 503 4.999340
|
|
||||||
$ curl -m 15 -w '%{http_code} %{time_total}\n' http://127.0.0.1:8081/ -> 503 5.001838
|
|
||||||
$ curl -m 6 -w '%{http_code} %{time_total}\n' http://10.10.0.2:8081/ -> 302 0.005733
|
|
||||||
# ~5 min later, the label alert fires (nothing paged, no user impact):
|
|
||||||
ALERTS{alertname="GatewayNodeCountNotOne",alertstate="firing"} = 1
|
|
||||||
$ kubectl label node rpi node-role.kubernetes.io/gateway-
|
|
||||||
node/rpi unlabeled
|
|
||||||
$ kubectl get nodes -l node-role.kubernetes.io/gateway=true -o name
|
|
||||||
node/siriussec
|
|
||||||
# and 10.10.0.1 is a closed port again (000 in 0.2 ms), 10.10.0.2 still 302/200
|
|
||||||
```
|
|
||||||
|
|
||||||
**Negatives re-proved after the change**
|
|
||||||
|
|
||||||
```
|
|
||||||
# LAN (from Legion, 192.168.1.0/24) — DROP on both nodes, both ports
|
|
||||||
192.168.1.179:8081 -> 000 (curl 28, 4.0 s) 192.168.1.179:8084 -> 000
|
|
||||||
192.168.1.125:8081 -> 000 (curl 28, 4.0 s) 192.168.1.125:8084 -> 000
|
|
||||||
# public: internal hostnames have no route on the public listener
|
|
||||||
curl -H 'Host: grafana.lab.internal' http://10.10.0.2:8080/ -> 404
|
|
||||||
curl -H 'Host: hubble.lab.internal' http://10.10.0.2:8080/ -> 404
|
|
||||||
# tunnel ingress = 9 entries, every service http://10.10.0.2:8080, no lab.internal
|
|
||||||
# public sites through the tunnel still 200 (from rpi):
|
|
||||||
# siriusdevops.com 200 forgejo.siriusdevops.com 200 piedmonthomesvc.com 200
|
|
||||||
# siriusgrowthsolutions.com 200
|
|
||||||
```
|
|
||||||
|
|
||||||
Commit `48b2b6a` (label removal is host state — `kubectl label node rpi
|
|
||||||
node-role.kubernetes.io/gateway-`; the manifests, the counter-augmented nft file
|
|
||||||
and this document are in git).
|
|
||||||
|
|
@ -1,246 +0,0 @@
|
||||||
# Monitoring dashboards
|
|
||||||
|
|
||||||
Three custom Grafana dashboards, all provisioned from this repo. Nothing on these
|
|
||||||
boards is created in the UI: the `kube-prometheus-stack` Grafana sidecar watches
|
|
||||||
for ConfigMaps labelled `grafana_dashboard=1` in **every** namespace
|
|
||||||
(`NAMESPACE=ALL`, `LABEL_VALUE=1`, `FOLDER=/tmp/dashboards`) and reloads them, so
|
|
||||||
a UI edit is overwritten on the next sidecar poll.
|
|
||||||
|
|
||||||
| Dashboard | UID | Answers |
|
|
||||||
|---|---|---|
|
|
||||||
| Forgejo Runners | `forgejo-runners` | Are the runners alive and polling, is CI queueing, how do runs end, and how full is the disk CI fills? |
|
|
||||||
| CNPG Postgres | `cnpg-postgres` | Are both Postgres clusters up, how busy, how big, how much WAL, is anything erroring? |
|
|
||||||
| Home lab workloads | `home-lab-workloads` | Which namespace is burning CPU/memory, what is Pending or restarting, are the nodes healthy, do the internal services answer? |
|
|
||||||
|
|
||||||
Open them (WireGuard only, no public hostname — see
|
|
||||||
`docs/internal-wireguard-services.md`):
|
|
||||||
|
|
||||||
```
|
|
||||||
http://10.10.0.2:8081/d/forgejo-runners/
|
|
||||||
http://10.10.0.2:8081/d/cnpg-postgres/
|
|
||||||
http://10.10.0.2:8081/d/home-lab-workloads/
|
|
||||||
```
|
|
||||||
|
|
||||||
They land in the default **General** folder, next to the chart's own dashboards —
|
|
||||||
not in a custom folder. That is a consequence of *how* they get imported: the
|
|
||||||
sidecar's API-backed import POSTs to `/api/admin/provisioning/dashboards/reload`
|
|
||||||
with `GF_SECURITY_ADMIN_USER/PASSWORD`, and on this Grafana that returns **401**
|
|
||||||
because the live admin password is the out-of-band one set in the UI
|
|
||||||
(`docs/grafana-persistence.md`) while `monitoring/grafana-admin` is only the
|
|
||||||
first-boot seed. Grafana's own **file** provider then imports `/tmp/dashboards`
|
|
||||||
on its 10 s rescan anyway — that is what actually registers these boards — and
|
|
||||||
the file provider has no per-dashboard folder option. Hence no `grafana_folder`
|
|
||||||
annotation: it would only describe a path the boards do not take.
|
|
||||||
|
|
||||||
## Where the files live
|
|
||||||
|
|
||||||
```
|
|
||||||
monitoring/controllers/home/dashboards/
|
|
||||||
├── build.py # source of truth: panel definitions + PromQL
|
|
||||||
├── kustomization.yaml
|
|
||||||
├── forgejo-runners.yaml # GENERATED ConfigMap (JSON inside)
|
|
||||||
├── cnpg-postgres.yaml # GENERATED
|
|
||||||
└── home-lab-workloads.yaml # GENERATED
|
|
||||||
```
|
|
||||||
|
|
||||||
**Edit `build.py`, then regenerate.** The generated YAML is committed so Flux
|
|
||||||
applies exactly what was reviewed, but a hand edit to the YAML fights the next
|
|
||||||
regeneration.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd ~/Projects/homek8s
|
|
||||||
python3 monitoring/controllers/home/dashboards/build.py monitoring/controllers/home/dashboards
|
|
||||||
```
|
|
||||||
|
|
||||||
## Getting Postgres metrics at all
|
|
||||||
|
|
||||||
Neither CNPG cluster was scraped before this work. Two pieces, both in git:
|
|
||||||
|
|
||||||
1. **A PodMonitor per cluster** — `apps/base/forgejo/podmonitor.yaml`,
|
|
||||||
`apps/base/sirius-growth/podmonitor.yaml`. They carry
|
|
||||||
`release: kube-prometheus-stack`, which is mandatory: Prometheus here keeps
|
|
||||||
the chart default `podMonitorSelectorNilUsesHelmValues: true`, so its selector
|
|
||||||
is literally `release=kube-prometheus-stack` (same reason the Cilium
|
|
||||||
ServiceMonitors in `kube-system` land). A PodMonitor without that label exists
|
|
||||||
happily and is never scraped — the failure mode is silence, not an error.
|
|
||||||
2. **`spec.monitoring.customQueriesConfigMap` on each `Cluster`** — the
|
|
||||||
operator's own `cnpg-default-monitoring` query set, plus, for `forgejo/pg`,
|
|
||||||
`forgejo-actions-queries`.
|
|
||||||
|
|
||||||
`spec.monitoring.enablePodMonitor` is deliberately **false**. It still works on
|
|
||||||
operator 1.30, but CNPG deprecated it in 1.27 ("we strongly recommend you remove
|
|
||||||
or set `enablePodMonitor` to `false` and manually create a PodMonitor") and the
|
|
||||||
operator-generated object gives no control over labels — which is precisely the
|
|
||||||
knob this stack needs. Owning the PodMonitor in git is both the upstream
|
|
||||||
recommendation and the only way to make the selector contract explicit.
|
|
||||||
|
|
||||||
### The Forgejo Actions metrics and their GRANT
|
|
||||||
|
|
||||||
`apps/base/forgejo/pg-actions-queries.yaml` adds four queries against the
|
|
||||||
`forgejo` database (CNPG runs custom queries on the cluster's *main* database —
|
|
||||||
`initdb.database`, i.e. `forgejo` here):
|
|
||||||
|
|
||||||
| Metric | Meaning |
|
|
||||||
|---|---|
|
|
||||||
| `cnpg_actions_queue_depth` | jobs handed to a runner that have not started (`started=0, stopped=0, status<>4`) |
|
|
||||||
| `cnpg_actions_queue_oldest_pending_seconds` | age of the oldest of those |
|
|
||||||
| `cnpg_actions_running_total` | jobs executing right now |
|
|
||||||
| `cnpg_actions_jobs_window_total{window,status}` | jobs finished in a rolling 1h/24h window, by status |
|
|
||||||
| `cnpg_actions_runners_last_online_seconds{runner}` | seconds since each runner polled Forgejo |
|
|
||||||
|
|
||||||
**Custom queries run as `cnpg_metrics_exporter`, not as `postgres`.** That role
|
|
||||||
has `pg_monitor` but no rights on Forgejo's tables, and a query that cannot read
|
|
||||||
its table yields **no metric at all** — silently. So once per database (not once
|
|
||||||
per deploy; it survives as long as the data directory does):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n forgejo exec pg-1 -c postgres -- psql -U postgres -d forgejo -c \
|
|
||||||
'GRANT USAGE ON SCHEMA public TO cnpg_metrics_exporter;
|
|
||||||
GRANT SELECT ON action_run_job, action_task, action_runner TO cnpg_metrics_exporter;'
|
|
||||||
```
|
|
||||||
|
|
||||||
Re-apply it after a restore into a fresh cluster (a fresh `initdb` has no grants).
|
|
||||||
|
|
||||||
### Status codes
|
|
||||||
|
|
||||||
`action_run_job.status` / `action_run.status` are **1 = success, 2 = failure,
|
|
||||||
3 = cancelled, 4 = skipped**. This was verified on this instance, not assumed:
|
|
||||||
DB run 1189 (status 1) reports `conclusion: success` on
|
|
||||||
`/api/v1/repos/sirius/onionwire/actions/runs`, run 1191 (status 2) `failure`.
|
|
||||||
Queue depth excludes status 4 because skipped jobs never start, never stop, and
|
|
||||||
are never pruned — including them would pin the queue at "3" forever.
|
|
||||||
|
|
||||||
## The tricky panels, and the PromQL behind them
|
|
||||||
|
|
||||||
**Queue while a job is running (contention).** The single-slot runners are
|
|
||||||
deliberate (`capacity = 1`), so the useful signal is "queued *and* running":
|
|
||||||
`(queue > bool 0) * (running > bool 0)` — the `bool` modifier turns each
|
|
||||||
comparison into 0/1 so the product is always a number (a bare `and` would render
|
|
||||||
"No data" instead of a green 0).
|
|
||||||
|
|
||||||
```promql
|
|
||||||
max((cnpg_actions_queue_depth{namespace="forgejo"} > bool 0)
|
|
||||||
* (cnpg_actions_running_total{namespace="forgejo"} > bool 0))
|
|
||||||
```
|
|
||||||
|
|
||||||
**Days to full.** Linear fit of free space, floored and capped:
|
|
||||||
|
|
||||||
```promql
|
|
||||||
clamp_max(node_filesystem_avail_bytes{instance="10.10.0.2:9100",mountpoint="/"}
|
|
||||||
/ clamp_min(-deriv(node_filesystem_avail_bytes{instance="10.10.0.2:9100",mountpoint="/"}[1h]), 0.0000001)
|
|
||||||
/ 86400, 365)
|
|
||||||
```
|
|
||||||
|
|
||||||
`clamp_min` on the *denominator* keeps a growing-filesystem division from going
|
|
||||||
negative or infinite; `clamp_max 365` renders "not filling" as a flat year rather
|
|
||||||
than a huge number. It needs a few hours of history to be meaningful.
|
|
||||||
|
|
||||||
**Commit share / cache hit ratio.** Both are `a / (a + b)` and both would render
|
|
||||||
`NaN` on an idle database, so the denominator is floored:
|
|
||||||
|
|
||||||
```promql
|
|
||||||
sum(rate(cnpg_pg_stat_database_xact_commit[5m]))
|
|
||||||
/ clamp_min(sum(rate(cnpg_pg_stat_database_xact_commit[5m]))
|
|
||||||
+ sum(rate(cnpg_pg_stat_database_xact_rollback[5m])), 0.0000001)
|
|
||||||
```
|
|
||||||
|
|
||||||
**Quiet-database error counters.** `increase()` over a counter that exists
|
|
||||||
(e.g. `cnpg_pg_stat_database_deadlocks`) returns a hard `0`, so deadlocks read 0
|
|
||||||
instead of "No data". Never use a `> 0` filter for these — it deletes the panel's
|
|
||||||
only series.
|
|
||||||
|
|
||||||
**Rolling job counts instead of `rate()`.** Forgejo prunes old `action_run_job`
|
|
||||||
rows. `rate()` over a row count would show a fake drop at every prune, so the
|
|
||||||
throughput panels query "how many rows stopped inside the last hour" directly
|
|
||||||
(`cnpg_actions_jobs_window_total{window="1h"}`).
|
|
||||||
|
|
||||||
## Adding a panel
|
|
||||||
|
|
||||||
1. Edit `monitoring/controllers/home/dashboards/build.py` — `ts()` for a
|
|
||||||
timeseries, `stat()` for a single number, `note()` for markdown.
|
|
||||||
2. Regenerate (command above).
|
|
||||||
3. **Validate the PromQL, not just the YAML.** `validate_panels.py` (next to
|
|
||||||
`build.py`) reads the dashboard JSON *out of the provisioned ConfigMap*,
|
|
||||||
extracts every target expression, substitutes the `$namespace` "All" case and
|
|
||||||
queries Prometheus. Anything that returns no series is a failed panel. It
|
|
||||||
needs a Prometheus port-forward (`kubectl -n monitoring port-forward
|
|
||||||
svc/kube-prometheus-stack-prometheus 9090:9090`).
|
|
||||||
```bash
|
|
||||||
python3 monitoring/controllers/home/dashboards/validate_panels.py \
|
|
||||||
monitoring/controllers/home/dashboards http://127.0.0.1:9090
|
|
||||||
```
|
|
||||||
4. Commit + push to `master`, then force the reconcile:
|
|
||||||
```bash
|
|
||||||
kubectl -n flux-system annotate gitrepository flux-system \
|
|
||||||
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
kubectl -n flux-system annotate kustomization monitoring \
|
|
||||||
reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
```
|
|
||||||
(`kustomization monitoring` will sit on `dependency 'flux-system/infrastructure'
|
|
||||||
is not ready` until you also annotate `kustomization infrastructure` — its
|
|
||||||
Ready condition is stale, not broken.)
|
|
||||||
5. Confirm the board registered. Grafana 13 stores dashboards in **unified
|
|
||||||
storage**, so `dashboard` table is empty and the UID lives in `resource`:
|
|
||||||
```bash
|
|
||||||
ssh Lancelot@10.10.0.2 "sudo sqlite3 /opt/local-path-provisioner/pvc-*_monitoring_kube-prometheus-stack-grafana/grafana.db \
|
|
||||||
\"select name, json_extract(value,'\$.spec.title') from resource where resource='dashboards' and name='<uid>';\""
|
|
||||||
```
|
|
||||||
|
|
||||||
Dashboards are data sources for humans: if a new panel needs a metric that does
|
|
||||||
not exist yet, add it to `pg-actions-queries.yaml` (Postgres) rather than
|
|
||||||
deploying another exporter.
|
|
||||||
|
|
||||||
### Panel-query patterns worth copying
|
|
||||||
|
|
||||||
- **A stat that can legitimately have no series needs `or vector(0)`.** A bare
|
|
||||||
`sum(x == 1)` over zero matching series is an *empty vector*, and Grafana
|
|
||||||
renders that as "No data" — which looks identical to a broken query. Every
|
|
||||||
count-style stat here that can hit zero ends in `or vector(0)`.
|
|
||||||
- **Beware broad pod regexes.** `pod=~"forgejo-runner-.*"` also matches the
|
|
||||||
`forgejo-runner-prune-*` CronJob pods, which are `Completed` and therefore
|
|
||||||
permanently "not Ready" — that turned a not-Ready stat from 0 into 3 until the
|
|
||||||
selector was narrowed to the three Deployment pod prefixes.
|
|
||||||
- **CNPG custom-query metrics carry `namespace`/`pod` from the scrape, not the
|
|
||||||
exporter's `cluster` label.** `cnpg_collector_*` has `cluster`; the
|
|
||||||
`cnpg_actions_*` and `cnpg_pg_stat_*` families do not. Filter those by
|
|
||||||
`namespace="forgejo"`.
|
|
||||||
|
|
||||||
## Known unknowns (deliberate, documented on the boards themselves)
|
|
||||||
|
|
||||||
- **Arm64 runner jobs are invisible to kube metrics.** `forgejo-runner-arm64`
|
|
||||||
and `forgejo-runner-deploy-arm64` drive the Pi's **host** Docker socket, so
|
|
||||||
their jobs are host containers with no pod identity. cAdvisor and
|
|
||||||
kube-state-metrics see only the runner pod. Per-job CPU/mem/disk on rpi is
|
|
||||||
therefore unavailable — the board shows rpi's root filesystem instead, because
|
|
||||||
that is where those containers write.
|
|
||||||
- **No per-PV usage.** kubelet 1.34+ no longer exports the alpha
|
|
||||||
`kubelet_volume_stats_*` metrics: its `/metrics/volumes` endpoint 404s on every
|
|
||||||
node here (kubelet v1.36.4, upstream kubernetes/kubernetes#133847), so there is
|
|
||||||
nothing to chart per PV and no scrape config would change that. The dind PVC's
|
|
||||||
20Gi is shown as *requested capacity* next to siriussec's root-filesystem usage,
|
|
||||||
which is the number that actually produced the DiskPressure evictions — and the
|
|
||||||
same filesystem is what `RunnerDindDiskHighWatermark` / `RunnerDindDiskCritical`
|
|
||||||
alert on, scoped to nodes that run a runner. The chart's own
|
|
||||||
`KubePersistentVolumeFillingUp` / `KubePersistentVolumeInodesFillingUp` rules
|
|
||||||
had the same defect and are suppressed too — both are listed under
|
|
||||||
`defaultRules.disabled` in `monitoring/controllers/home/values.yaml`, so the
|
|
||||||
`kubernetes-storage` group keeps only its live rule,
|
|
||||||
`KubePersistentVolumeErrors` (kube-state-metrics). No loaded rule in this
|
|
||||||
stack selects `kubelet_volume_stats_*`.
|
|
||||||
- **Single-instance Postgres.** Both clusters run `instances: 1`, so replication
|
|
||||||
lag, streaming replicas and in-recovery are structurally zero. The panels show
|
|
||||||
the zero and say why instead of being hidden.
|
|
||||||
- **No CNPG backups exist** (`kubectl get backups.postgresql.cnpg.io -A` is
|
|
||||||
empty), so "Last available backup" reads 0 = never. That is the state, not a
|
|
||||||
broken panel.
|
|
||||||
- **No Alertmanager.** `PrometheusRule` objects (e.g. `InternalGatewayUnreachable`)
|
|
||||||
surface on Prometheus `/alerts` and in Grafana → Alerting; nothing pages.
|
|
||||||
|
|
||||||
## Cardinality / retention
|
|
||||||
|
|
||||||
`retention: 7d` and `retentionSize: 8GB` are unchanged. The additions are small:
|
|
||||||
two Postgres instances add a few hundred series each (the CNPG default query set
|
|
||||||
plus the four Forgejo queries), and `prometheus-node-exporter` now runs on every
|
|
||||||
node instead of only siriussec (~700 series per node) — that is what makes the
|
|
||||||
Pi's disk visible at all, and it costs far less than one day of cAdvisor for a
|
|
||||||
build pod.
|
|
||||||
|
|
@ -1,118 +0,0 @@
|
||||||
# Site images: immutable sha tags pinned in git
|
|
||||||
|
|
||||||
Every first-party site image runs from a **tag pinned in this repo** and is rolled
|
|
||||||
by Flux. CI builds and pushes `:<commit-sha>` and prints the exact ref; the
|
|
||||||
operator copies that ref into the Deployment manifest. There are **no cluster
|
|
||||||
credentials in any site repo** — CI cannot roll a Deployment and cannot read a
|
|
||||||
kubeconfig.
|
|
||||||
|
|
||||||
This replaces the old model (`:latest` + `imagePullPolicy: Always` + CI patching
|
|
||||||
`kubectl.kubernetes.io/restartedAt` through a `site-deployer` ServiceAccount
|
|
||||||
token). That path is gone: the SA/Role/RoleBinding were removed and the
|
|
||||||
`KUBE_CONFIG` action secrets deleted.
|
|
||||||
|
|
||||||
## Operator flow
|
|
||||||
|
|
||||||
1. Push to a site repo (or `workflow_dispatch` it). The workflow builds the
|
|
||||||
amd64 image, pushes `<registry>/<image>:<sha>`, and ends with a
|
|
||||||
`### Pin this in sirius/homek8s …` step that prints the ref. It also pushes
|
|
||||||
`:latest`, but **nothing in the cluster reads `:latest`** — it is a
|
|
||||||
convenience pointer for humans only.
|
|
||||||
2. Edit the Deployment in `apps/base/<app>/deployment*.yaml`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
image: forgejo.siriusdevops.com/sirius/<image>:<sha>
|
|
||||||
imagePullPolicy: IfNotPresent
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Commit + push `master`, then force the Flux recheck (gitrepository **first**,
|
|
||||||
kustomization **second** — an `apps` annotate that still reports the previous
|
|
||||||
sha has not fetched the commit):
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n flux-system annotate gitrepository flux-system reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
kubectl -n flux-system annotate kustomization apps reconcile.fluxcd.io/requestedAt="$(date +%s)" --overwrite
|
|
||||||
```
|
|
||||||
|
|
||||||
4. Verify: the pod template changed, so the Deployment rolls within ~1m and the
|
|
||||||
pod reports the pinned ref.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
kubectl -n <ns> get pods -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.containerStatuses[0].imageID}{"\n"}{end}'
|
|
||||||
```
|
|
||||||
|
|
||||||
`imageID` must name `:<sha>` and carry the digest the registry returns for
|
|
||||||
that tag (`Docker-Content-Digest`, below).
|
|
||||||
|
|
||||||
Rollback is `git revert` of the pin commit — Flux reconciles back in ~1m.
|
|
||||||
|
|
||||||
## Why the site repos are not Flux sources
|
|
||||||
|
|
||||||
The only `GitRepository` cluster-wide is `flux-system` → `sirius/homek8s`. Flux
|
|
||||||
owns the *manifests*; the site repos own only their image builds. The content
|
|
||||||
revision a visitor sees is therefore chosen by the tag committed here, not by
|
|
||||||
whatever CI pushed last. A site repo push alone changes nothing in the cluster.
|
|
||||||
|
|
||||||
## Current pins
|
|
||||||
|
|
||||||
| Namespace | Deployment | Image ref |
|
|
||||||
|---|---|---|
|
|
||||||
| siriusdevops | siriusdevops-site | `siriusdevops-site:f0dde2f48c8224fb80d801ecb0d155c93332dc13` |
|
|
||||||
| siriusdevops | siriusdevops-contact | `siriusdevops-contact:f0dde2f48c8224fb80d801ecb0d155c93332dc13` |
|
|
||||||
| sirius-growth | sirius-growth-site | `sirius-growth-site:ea306b73b0d7c9ae8c33393a420e6d1d452b802b` |
|
|
||||||
| sirius-growth | sirius-growth-portal | `sirius-growth-portal:d9e558c4e0922d3ecd28214f7698ec0994170481` |
|
|
||||||
| sirius-growth | sirius-growth-contact | `sirius-growth-contact:c9c9379ebceca6879d3bbeff1c2601b6484e87b0` |
|
|
||||||
| piedmont | piedmont-site | `phs-site:5b590cddab6d7889fdd3c272255f28c4560e752e` |
|
|
||||||
| piedmont | piedmont-contact | `phs-contact:5035443abb62913362e416ab7030a64726886886` |
|
|
||||||
|
|
||||||
Each pin is the tag CI printed for the commit that was deployed. (The first six
|
|
||||||
pins were chosen as the tag whose manifest was **the image already running**, so
|
|
||||||
pinning was a no-op for visitors; the two contact APIs were re-pinned after
|
|
||||||
their pipelines first ran — same source, freshly built.)
|
|
||||||
|
|
||||||
### Contact APIs
|
|
||||||
|
|
||||||
Both contact APIs now build in CI, on `docker-amd64`, tagging `:$sha` and
|
|
||||||
promoting `:latest` as a pointer only:
|
|
||||||
|
|
||||||
| Repo | Workflow | `paths:` | Source | Image |
|
|
||||||
|---|---|---|---|---|
|
|
||||||
| `sirius-growth` (`master`) | `.forgejo/workflows/deploy-contact.yml` | `contact-api/**` | `contact-api/` | `sirius/sirius-growth-contact` |
|
|
||||||
| `sirius/websites` (`main`) | `.forgejo/workflows/deploy-phs-contact.yml` | `phs-contact-api/**` | `phs-contact-api/` | `sirius/phs-contact` |
|
|
||||||
|
|
||||||
They used to be hand-built (`:latest` only) and therefore pinned by `@sha256:`.
|
|
||||||
A change to either API is now a push → printed `:<sha>` ref → bump the pin here.
|
|
||||||
|
|
||||||
## Registry facts
|
|
||||||
|
|
||||||
- Registry: `forgejo.siriusdevops.com` (Forgejo packages, `[packages] ENABLED = true`).
|
|
||||||
- Reads/writes need a `read:package` / `write:package` scoped token; the stored
|
|
||||||
`~/.git-credentials` oauth2 token is git-scoped and is rejected by `/v2/`.
|
|
||||||
- **Tags do not expire.** `package_cleanup_rule` has zero rows and `app.ini` has
|
|
||||||
no cleanup cron, so a pinned `:<sha>` stays resolvable.
|
|
||||||
- Prove a pin `T` for image `I` without pulling anything:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
curl -s -u "sirius:$TOK" -H 'Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json' \
|
|
||||||
-D - -o /dev/null "https://forgejo.siriusdevops.com/v2/sirius/$I/manifests/$T" | grep -i docker-content-digest
|
|
||||||
```
|
|
||||||
|
|
||||||
## Pitfalls
|
|
||||||
|
|
||||||
- **`docker buildx imagetools create` (the `:latest` promote step) wraps a
|
|
||||||
single-arch image in an index**, so the `:latest` digest differs from the
|
|
||||||
`:<sha>` digest even though the content is identical. Compare the *config*
|
|
||||||
digest, or compare the running pod's digest to the `:<sha>` tag, never
|
|
||||||
`:latest` vs the sha tag.
|
|
||||||
- The amd64 runner's job image (`node:20-bullseye`) has no docker CLI, so the
|
|
||||||
site workflows fetch the binaries each run — and both hosts have been observed
|
|
||||||
to stall for the full 300s (`curl: (28) … 0 out of 0 bytes`). The static docker
|
|
||||||
client tries `download.docker.com` then `mirrors.aliyun.com`; **buildx is copied
|
|
||||||
out of the `docker:27-dind` image the runner already holds**
|
|
||||||
(`docker create docker:27-dind` → `docker cp …/cli-plugins/docker-buildx`),
|
|
||||||
with the GitHub release URL only as a fallback. Before that change a
|
|
||||||
three-attempt retry of the GitHub CDN failed all three times inside a job
|
|
||||||
container while the same URL fetched fine outside one.
|
|
||||||
- `runs-on` matters: site images are `linux/amd64` and only siriussec serves
|
|
||||||
them. Build them on `docker-amd64` / `deploy-arm64`, never on the arm64
|
|
||||||
`docker` runner.
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
||||||
kind: Kustomization
|
|
||||||
namespace: cert-manager
|
|
||||||
resources:
|
|
||||||
- namespace.yaml
|
|
||||||
- repository.yaml
|
|
||||||
- release.yaml
|
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
apiVersion: v1
|
|
||||||
kind: Namespace
|
|
||||||
metadata:
|
|
||||||
name: cert-manager
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
apiVersion: source.toolkit.fluxcd.io/v1
|
|
||||||
kind: HelmRepository
|
|
||||||
metadata:
|
|
||||||
name: jetstack
|
|
||||||
namespace: cert-manager
|
|
||||||
spec:
|
|
||||||
interval: 24h
|
|
||||||
url: https://charts.jetstack.io/
|
|
||||||
|
|
@ -1,27 +1,3 @@
|
||||||
# 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
|
|
||||||
# a kubectl patch was lost on every reinstall. The upstream release manifest is
|
|
||||||
# vendored verbatim (sha256 f8bede43fe4ee0d478c2355b204a36876b2ae4faac60f2a9452280b293da3b88,
|
|
||||||
# https://github.com/cloudnative-pg/cloudnative-pg/releases/download/v1.30.0/cnpg-1.30.0.yaml)
|
|
||||||
# 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
|
|
||||||
# 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/plugin-barman-cloud-0.16.0.yaml
|
|
||||||
patches:
|
|
||||||
- path: patch-controller-manager.yaml
|
|
||||||
- path: patch-barman-cloud.yaml
|
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
# Live-state delta for the CloudNativePG operator, kept deliberate.
|
|
||||||
#
|
|
||||||
# Everything below is a hand-applied change that exists on the running
|
|
||||||
# cnpg-controller-manager but is NOT in the upstream 1.30.0 release manifest.
|
|
||||||
# Adopting upstream raw would silently revert them, so they are declared here
|
|
||||||
# as the operator's real configuration.
|
|
||||||
#
|
|
||||||
# Leader election: single-node etcd on the T480's PM991 NVMe stalls WAL fsync
|
|
||||||
# for multiple seconds during heavy Forgejo dind builds. The apiserver stops
|
|
||||||
# answering, client-go's 5s lease-renewal HTTP timeout expires, and
|
|
||||||
# controller-runtime fatals with "leader election lost" (223 restarts / 45d).
|
|
||||||
# Lease 60s / renew 45s rides out a stall instead of restarting the operator.
|
|
||||||
# Safe with replicas: 1 -- there is no second holder to split-brain against.
|
|
||||||
# NOTE: these flags are integer SECONDS, not Go durations.
|
|
||||||
apiVersion: apps/v1
|
|
||||||
kind: Deployment
|
|
||||||
metadata:
|
|
||||||
name: cnpg-controller-manager
|
|
||||||
namespace: cnpg-system
|
|
||||||
spec:
|
|
||||||
template:
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: manager
|
|
||||||
args:
|
|
||||||
- controller
|
|
||||||
- --leader-elect
|
|
||||||
- --leader-lease-duration=60
|
|
||||||
- --leader-renew-deadline=45
|
|
||||||
- --max-concurrent-reconciles=10
|
|
||||||
- --config-map-name=cnpg-controller-manager-config
|
|
||||||
- --secret-name=cnpg-controller-manager-config
|
|
||||||
- --webhook-port=9443
|
|
||||||
# The pod talks to the API over the WireGuard overlay address
|
|
||||||
# (10.10.0.2:6443); the in-cluster 10.96.0.1 Service VIP is not
|
|
||||||
# reachable from this namespace (see k8s-api firewall on the T480).
|
|
||||||
env:
|
|
||||||
- name: KUBERNETES_SERVICE_HOST
|
|
||||||
value: "10.10.0.2"
|
|
||||||
- name: KUBERNETES_SERVICE_PORT
|
|
||||||
value: "6443"
|
|
||||||
# Upstream ships 100m/200Mi, which is tight enough that the operator
|
|
||||||
# was starved on this box. Raised by hand; keep it.
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpu: 500m
|
|
||||||
memory: 512Mi
|
|
||||||
# Upstream gives the manager 6*5s = 30s to answer /readyz, which is
|
|
||||||
# shorter than a real NVMe fsync stall. 36*5s = 3min.
|
|
||||||
startupProbe:
|
|
||||||
failureThreshold: 36
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue