Compare commits
4
Commits
d49485ef21
...
5e8e2b8c0a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e8e2b8c0a | ||
|
|
8519546269 | ||
|
|
3f9a4b880a | ||
|
|
ef87951061 |
No files matched your search
+41
-1
@@ -1,6 +1,6 @@
|
||||
# hAPI
|
||||
|
||||
hAPI ("home API") is a personal, cloud-hosted API serving one household and its automations: finance, fitness, home maintenance, and smart home. Access is restricted to a small, known set of Principals.
|
||||
hAPI ("home API") is a personal, cloud-hosted API serving one household and its automations: finance, fitness, maintenance, and smart home. Access is restricted to a small, known set of Principals.
|
||||
|
||||
## Language
|
||||
|
||||
@@ -62,6 +62,8 @@ _Avoid_: Author, owner, creator
|
||||
|
||||
### Smart home
|
||||
|
||||
Smart home is hAPI's side of the house: queuing Jobs for Home Assistant, which remains the source of truth for the house's state.
|
||||
|
||||
**Job**:
|
||||
A request, queued in hAPI, for Home Assistant to carry out an action in the house. Jobs are Household data. Domain code, Persons, and Bots can all create them.
|
||||
_Avoid_: Task, command, message
|
||||
@@ -103,3 +105,41 @@ _Avoid_: Sinking fund, rollover, savings
|
||||
**Payee mapping**:
|
||||
An owner's remembered link from a payee to a Category, learned from manual categorization and applied to newly ingested Transactions.
|
||||
_Avoid_: Rule, auto-categorization
|
||||
|
||||
### Maintenance
|
||||
|
||||
Maintenance is the upkeep of the Household's physical property: the home, its land, its equipment, and its vehicles.
|
||||
|
||||
**Asset**:
|
||||
A physical thing the Household keeps up, such as the roof, the furnace, a fridge, or a car. It may have a meter whose Readings track its use.
|
||||
_Avoid_: Equipment, item, entity (a Home Assistant term); in Finance, use another word
|
||||
|
||||
**Task**:
|
||||
A recurring piece of upkeep, due either a fixed interval after it was last done or on a calendar rhythm, and optionally also after a set amount of use. Tasks always recur; one-off work is recorded only as a Service.
|
||||
_Avoid_: Chore, reminder, to-do (and never a Job)
|
||||
|
||||
**Service**:
|
||||
One piece of maintenance work done on a date. It may fulfill a Task, and may concern an Asset.
|
||||
_Avoid_: Completion, repair, log entry
|
||||
|
||||
**Reading**:
|
||||
An Asset's meter value (an odometer's distance or a runtime counter) taken on a date, used to decide when usage-based Tasks come due.
|
||||
_Avoid_: Measurement (a Fitness term), metric
|
||||
|
||||
### Fitness
|
||||
|
||||
**Workout**:
|
||||
One session of exercise by one Person: an ordered list of Exercises performed, with what was done in each. A run is a Workout with a single cardio Exercise.
|
||||
_Avoid_: Session, activity, training
|
||||
|
||||
**Exercise**:
|
||||
A named movement that Workouts record, of kind strength, bodyweight, timed, or cardio; the kind decides what is recorded for it. Household Exercises can be used by every Household member; Personal Exercises only by their Person.
|
||||
_Avoid_: Movement, lift, activity
|
||||
|
||||
**Set**:
|
||||
One bout of a strength, bodyweight, or timed Exercise within a Workout: reps and load, or a duration. A warmup Set doesn't count toward records.
|
||||
_Avoid_: Rep, round
|
||||
|
||||
**Measurement**:
|
||||
One reading of a Person's body (weight, body fat, or a circumference) at a point in time.
|
||||
_Avoid_: Metric, stat, body stat
|
||||
@@ -0,0 +1,37 @@
|
||||
# Envoy Gateway at the edge, DNS-01 through a delegated challenge zone, CAA pinned to our account
|
||||
|
||||
Public traffic reaches hAPI on one hostname, **`hapi.bobbypalko.com`**, over IPv4 only. OpenTofu reserves the IPv4 address. A Linode NodeBalancer created by the CCM listens on that address in **TCP mode** and sends **Proxy Protocol v2** to an **Envoy Gateway**. Envoy Gateway terminates TLS and forwards plain HTTP to hAPI `:8000`; Cilium's WireGuard encrypts traffic between nodes. There's no CDN (ADR-0002), so the Gateway is the only shield and enforces the edge limits. Envoy Gateway was chosen over Cilium's built-in Gateway because Cilium's Gateway has none of the limits we need as typed policy. Certificates come from **cert-manager** and Let's Encrypt over DNS-01, because `:80` is closed. The DNS-01 credential can only edit a separate, delegated **`acme.bobbypalko.com`** zone, not `bobbypalko.com` itself. A **CAA record pinned to our ACME account** means that even a leaked DNS token can't get a certificate for us.
|
||||
|
||||
## Considered Options
|
||||
|
||||
- **Cilium's built-in Gateway** (it's already the CNI, ADR-0003). It has one component fewer, but as of v1.20 it offers only global switches (Proxy Protocol, ALPN, trusted XFF hops). It has no rate limiting, connection limits, body or header limits, client timeouts or minimum-TLS policy. The only workaround is hand-written CiliumEnvoyConfig, which doesn't cleanly patch the listeners Cilium generates. Rejected.
|
||||
- **Traefik with built-in ACME.** It renews certificates just as cert-manager does, but Traefik OSS keeps ACME state in a local file, so it can't run more than one replica. It would also still need the same DNS credential. Rejected.
|
||||
- **A DNS-01 token on the whole `bobbypalko.com` zone** (an IAM restricted user with `domain_admin` on it). Simpler, but a leaked token could repoint `git.` or any other record. Rejected under ADR-0008's narrow-token rule.
|
||||
- **Moving DNS to Cloudflare** for per-zone tokens. Rejected: it moves the whole zone to buy a token scope we can get with a delegated subzone.
|
||||
- **Self-hosted acme-dns.** It has the narrowest credential, but it means running a public DNS server. Kept as the fallback if the delegated-zone setup doesn't hold up (see Consequences).
|
||||
- **TLS terminated at the NodeBalancer (HTTPS mode).** Rejected: cert-manager can't rotate a certificate uploaded to Linode, and traffic from the NodeBalancer to the nodes would cross the unencrypted VPC in plaintext.
|
||||
- **A backup ACME CA (GTS, ZeroSSL).** Deferred: each needs EAB credentials, which is one more secret to manage, plus its own CAA entry.
|
||||
|
||||
## Consequences
|
||||
|
||||
- **Tofu owns the stable parts:** the reserved IPv4, the NodeBalancer's Cloud Firewall (inbound TCP 443 only), the `A` record, the `_acme-challenge.hapi` CNAME, the `acme.` delegation and the CAA record. The Gateway's Service references the IP and the firewall through the CCM's `reserved-ipv4` and `firewall-id` annotations. The CCM creates and recreates the NodeBalancer without changing the address. There's no external-dns.
|
||||
- **No `AAAA`.** The NodeBalancer's IPv6 frontend address can't be reserved, so recreating the NodeBalancer would silently break the record.
|
||||
- **NodeBalancer:** `default-protocol: tcp`, `default-proxy-protocol: v2`, `throttle: 20` (new connections per second per client IP; the Household shares one CGNAT IP), and VPC backends.
|
||||
- **Envoy Gateway:** 2 Envoy replicas spread across both workers, with a PDB and memory requests tuned down from the chart's 512Mi. The Gateway accepts Proxy Protocol only.
|
||||
- `ClientTrafficPolicy`: TLS 1.3 only; ALPN h2 and http/1.1 (no HTTP/3); headers up to 16 KiB; about 50 connections per IP; request timeout 30 s, idle 60 s; client IP taken from Proxy Protocol.
|
||||
- `BackendTrafficPolicy`: per-IP local rate limit of about 20 req/s, burst 100 (per replica, no Redis), and bodies up to 1 MiB (413). The app caps `transactions/ingest` batches on its own.
|
||||
- HSTS is set at the edge. There's no per-Principal rate limiting (ADR-0005).
|
||||
- **uvicorn trusts `X-Forwarded-For` only from the Gateway's pod range.** That way, logs and limits see the real client.
|
||||
- **Layout:** one `Gateway` in a `gateway` namespace with a single HTTPS listener for `hapi.bobbypalko.com` and `allowedRoutes` limited to the `hapi` namespace. One `HTTPRoute` sends traffic to `:8000`; `:8081` is never routed (ADR-0009). Any other SNI or Host gets no certificate and no route.
|
||||
- **Certificates:**
|
||||
- cert-manager uses an ACME ClusterIssuer for Let's Encrypt on the default profile, plus a staging issuer for bring-up. `renewBefore` stays at its default, which is a proportion of the lifetime, so lifetimes can shrink (64 days from Feb 2027, 45 from 2028) without changes on our side. The DNS-01 solver is `linode/cert-manager-webhook-linode` with `cnameStrategy: Follow`.
|
||||
- The webhook's token belongs to a **restricted Linode user** with `domain_admin` on `acme.bobbypalko.com` only. It's delivered through SOPS (ADR-0008).
|
||||
- **CAA on `hapi.bobbypalko.com`** (not the apex, so other hostnames are unaffected): `0 issue "letsencrypt.org; validationmethods=dns-01; accounturi=<our account>"`.
|
||||
- **The ACME account key is generated offline and committed SOPS-encrypted.** A cluster rebuilt from code (ADR-0003) reuses the same account. Otherwise the CAA pin would block our own issuance.
|
||||
- **Verify during the build:**
|
||||
1. That a restricted user's token really is capped by the user's grants: it must fail to edit `bobbypalko.com`.
|
||||
2. That Linode serves the delegated `acme.` subzone.
|
||||
3. That the CCM copies Gateway `spec.infrastructure` / `EnvoyProxy` Service annotations onto the NodeBalancer.
|
||||
If either of the first two fails, switch to acme-dns before going live.
|
||||
- **Delivery (ADR-0007):** cert-manager with the webhook, and Envoy Gateway with the **Standard-channel** Gateway API CRDs, arrive as Flux `HelmRelease`s in `deploy/infrastructure`. Cilium runs with `gatewayAPI.enabled=false`, so two controllers never compete for the CRDs. Renovate opens PRs for these charts, but they aren't auto-merged.
|
||||
- **Observability (ADR-0009):** Envoy writes JSON access logs to stdout (client IP, status, bytes, duration, rate-limit verdict), without `Authorization` or query strings. Vector ships them to VictoriaLogs with the standard 30-day retention. Kuma's TLS-expiry notification on the `/v1/health` monitor alerts at 14 days. A vmalert rule on `certmanager_certificate_expiration_timestamp_seconds` is the in-cluster backstop.
|
||||
Reference in new issue
Block a user