infra(logging): Loki single-binary + Alloy DaemonSet with 192h bounded retention (F4) #52

Merged
sirius merged 1 commit from wt/t_34ddaa83 into master 2026-11-27 05:37:13 +00:00
Owner

Summary

Finding F4 of the 2026-11-27 cluster-netsec audit: there was no log storage anywhere. Pod logs existed only as kubelet files under /var/log/pods and died with the pod — ~8 h of history for the pods that matter, nothing to scan for abnormalities.

This adds a bounded log store:

  • Loki 3.7.1 single-binary — 1 Deployment, 8Gi local-path PVC pinned to siriussec, retention_period: 192h with the compactor deleting on filesystem, ingest rate limits.
  • Alloy 1.13.0 DaemonSet on all three nodes, no RBAC and no Kubernetes API access (filesystem only). Ships /var/log/pods, /var/log/journal and the Pi's docker json logs (registry + Garage, which are not pods).
  • Backfill: file sources read from byte 0 and stamp each line with the timestamp in the line, so the history the nodes already held landed on day one (18 d cilium-agent on linode, 31 d registry log on rpi) instead of starting the 7-day clock at deploy time.
  • Grafana datasource Loki (uid loki) through the existing sidecar, a ServiceMonitor, and an ingest-rate guard rule.
  • docs/logging.md — design, the measured bytes/day, the 8-day projection, runbook.

Acceptance

  1. Collector runs, ≥7 days, required namespaces — Loki Ready, Alloy 3/3 Ready; forgejo, siriusdevops, sirius-growth, piedmont, osint, kube-system all have series. Retention is 192 h.
  2. A query returns a line from 7 days ago (see the evidence block in docs/logging.md): {namespace="kube-system", pod="cilium-bvqsg"} at 2026-11-20T05:16:26Z; journals return 2026-11-20T05:15:48Z (siriussec) and 05:15:45Z (linode).
  3. Bounded and measured — ~360–502 MB/day raw, ~5.6x compression → ~90 MB/day on disk, 192 h → ≤0.8 GiB against an 8 GiB PVC; node free went 103 → 101 GiB of 214 GiB, house floor 32 GiB untouched. (I measured with a second-high-rate bound; details in the doc.)
  4. Resources on every pod — loki 50m/256Mi → 1 CPU/1Gi; alloy 30m/128Mi → 500m/512Mi.
  5. Restart does not lose history — deleted the Loki pod; the 7-day query still returns the same lines from the PVC.
  6. Flux — infrastructure/logging/ + clusters/homek8s/logging.yaml (dependsOn infrastructure, monitoring).

Nothing touches ELK/OpenSearch/Wazuh, no SIEM, and containerLogMaxSize is left alone.

Notes

The logging namespace is enforce: privileged for one reason: baseline rejects hostPath volumes, which a node log collector cannot do without. All containers still drop ALL caps, run read-only-rootfs with allowPrivilegeEscalation: false.

## Summary Finding **F4** of the 2026-11-27 cluster-netsec audit: there was no log storage anywhere. Pod logs existed only as kubelet files under `/var/log/pods` and died with the pod — ~8 h of history for the pods that matter, nothing to scan for abnormalities. This adds a bounded log store: * **Loki 3.7.1 single-binary** — 1 Deployment, 8Gi `local-path` PVC pinned to `siriussec`, `retention_period: 192h` with the compactor deleting on filesystem, ingest rate limits. * **Alloy 1.13.0 DaemonSet** on all three nodes, **no RBAC and no Kubernetes API access** (filesystem only). Ships `/var/log/pods`, `/var/log/journal` and the Pi's docker json logs (registry + Garage, which are not pods). * **Backfill**: file sources read from byte 0 and stamp each line with the timestamp in the line, so the history the nodes already held landed on day one (18 d `cilium-agent` on linode, 31 d registry log on rpi) instead of starting the 7-day clock at deploy time. * Grafana datasource `Loki` (uid `loki`) through the existing sidecar, a ServiceMonitor, and an ingest-rate guard rule. * `docs/logging.md` — design, the measured bytes/day, the 8-day projection, runbook. ## Acceptance 1. **Collector runs, ≥7 days, required namespaces** — Loki Ready, Alloy 3/3 Ready; `forgejo`, `siriusdevops`, `sirius-growth`, `piedmont`, `osint`, `kube-system` all have series. Retention is 192 h. 2. **A query returns a line from 7 days ago** (see the evidence block in `docs/logging.md`): `{namespace="kube-system", pod="cilium-bvqsg"}` at `2026-11-20T05:16:26Z`; journals return `2026-11-20T05:15:48Z` (siriussec) and `05:15:45Z` (linode). 3. **Bounded and measured** — ~360–502 MB/day raw, ~5.6x compression → ~90 MB/day on disk, 192 h → **≤0.8 GiB** against an 8 GiB PVC; node free went 103 → 101 GiB of 214 GiB, house floor 32 GiB untouched. (I measured with a second-high-rate bound; details in the doc.) 4. **Resources on every pod** — loki 50m/256Mi → 1 CPU/1Gi; alloy 30m/128Mi → 500m/512Mi. 5. **Restart does not lose history** — deleted the Loki pod; the 7-day query still returns the same lines from the PVC. 6. **Flux** — `infrastructure/logging/` + `clusters/homek8s/logging.yaml` (dependsOn infrastructure, monitoring). Nothing touches ELK/OpenSearch/Wazuh, no SIEM, and `containerLogMaxSize` is left alone. ## Notes The `logging` namespace is `enforce: privileged` for one reason: `baseline` rejects hostPath volumes, which a node log collector cannot do without. All containers still drop ALL caps, run read-only-rootfs with `allowPrivilegeEscalation: false`.
No log store existed: pod logs were kubelet files on the node and died with the
pod (~8h deepest history for a busy workload). Adds:

- Loki 3.7.1 single-binary (1 Deployment + 8Gi local-path PVC on siriussec),
  retention_period 192h with the compactor deleting on filesystem, ingest rate
  limits, so the store is time- and rate-bounded.
- Alloy 1.13.0 DaemonSet (all nodes, no RBAC, no API access) shipping
  /var/log/pods, /var/log/journal and the Pi's docker json logs. File sources
  read from byte 0 and stamp the timestamp from the line, so the history the
  nodes already held (18d cilium on linode, 31d registry on rpi) landed on day
  one instead of starting the 7-day clock at deploy time.
- Grafana datasource (uid loki) via the existing sidecar, ServiceMonitor,
  ingest-rate guard rule.
- docs/logging.md with the measured bytes/day, the 8-day projection and the
  runbook.

Measured: ~360-502 MB/day raw -> ~90 MB/day compressed, 192h -> <=0.8GiB, on a
node with 103GiB free (house floor 32GiB). Verified 7-day-old lines return for
kube-system cilium-agent and for the siriussec/linode journals, and survive a
Loki pod restart (PVC).
sirius merged commit 8619a8f07d into master 2026-11-27 05:37:13 +00:00
sirius deleted branch wt/t_34ddaa83 2026-11-27 05:37:13 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
sirius/homek8s!52
No description provided.