my-homelab-configs/infra/monitoring-debian/README.md

6.2 KiB

Debian monitoring

Prometheus, Alertmanager, Grafana and Loki run in the homelab-prometheus Compose project on Debian's local NVMe. The Prometheus Operator, kube-state-metrics, node exporters and ServiceMonitor/PrometheusRule resources remain in K3s. Promtail and Tempo remain in the cluster.

Run on Debian:

./jeannie monitoring plan
./jeannie monitoring migrate
./jeannie monitoring status

migrate verifies the pinned cluster, validates exported configuration using promtool/amtool, stops the retained backends using their existing Helm releases, then copies their offline volumes. Loki uses its own staged configuration check. It preserves the original PVCs and stores compressed archives, PVC identities and original Helm values under /data/homelab-monitoring/backup. Grafana's existing SQLite database is copied using SQLite's backup API, preserving users, saved dashboards and Dex account links. Existing seven-day Prometheus retention still applies; backup archives remain independent of TSDB retention.

The chart keeps the backend controllers intentionally at zero replicas. A post-renderer retains their Service names and supplies Debian Endpoints, preserving in-cluster URLs and ServiceMonitor discovery. It supports Helm 3 executables and an isolated Helm 4 postrenderer plugin. OpenTofu uses the same desired configuration, so a subsequent ./jeannie platform monitoring keeps the backends on Debian.

The OCI edge forwards the three public hostnames directly to Debian through Tailscale. Migration uses an Nginx-only validated reload, without pulling or recreating the other containers on the small edge VM. ACME challenge paths are retained for certificate renewal. Grafana retains its public URL, Dex client ID/secret and datasource UIDs. The cluster Grafana OAuth secret remains the source consumed by the existing SOPS/Dex deployment pipeline; this migration does not rotate it.

./jeannie monitoring apply is idempotent after migration. refresh updates Operator-generated discovery, alert rules, datasources and dashboard files. The installed homelab-monitoring-refresh.timer runs every five minutes under the Debian operator account, using a durable installed script rather than the checkout used for migration. It refreshes an hour-lived token for the existing Prometheus service account; containers do not receive the administrator kubeconfig. Existing configuration remains running if the cluster API is down. Dashboard files reload automatically; changes to Grafana OAuth configuration or datasources restart Grafana. grafana-dashboards apply also refreshes the external instance.

Only routes for the declared cluster service CIDR and discovered Calico pools are installed through the Orange Pi. Configuration and backups live in a private installation directory. Docker memory caps are 1536 MiB for Prometheus, 512 MiB for Grafana and 256 MiB for Alertmanager. Coordinate LLM benchmarks with the remaining Debian memory; moving monitoring does not reserve host RAM.

The migration does not repair the Orange Pi SSD. Original PVCs and backups should be retained until recovery requirements are reviewed.

./jeannie monitoring apply, migrate and refresh automatically check and repair the Debian and OCI email node-exporter targets. The five-minute refresh timer uses the same installed code, independent of the source checkout. ./jeannie platform monitoring also invokes this reconciliation. ./jeannie monitoring exporters remains an optional focused retry. On Debian it removes only retired CNI TCP/9100 hostPort rules when all Kubernetes services and runtime processes are absent; shared HTTP/HTTPS rules and other firewall policy remain intact. Rule backups are saved under ~/.local/share/homelab/exporter-backups.

For email it learns Debian's current public IPv4 and updates only the two state-identified email NSG rules (SSH and exporter) to that /32, then adds the matching UFW exporter permission through SSH. A managed systemd oneshot keeps a source-restricted TCP/9100 INPUT allowance before the Oracle image's default REJECT rule, including after reboot. It saves email-specific CIDR overrides in the canonical OCI configuration so subsequent foundation applies retain the new source. Existing UFW permissions are not reset or removed, and edge access rules remain unchanged. Scheduled refresh detects public-IP changes and repairs access automatically. When targets are already UP and the recorded source matches, it avoids SSH, OCI updates and service changes. A disabled email VM is skipped. Status and validation commands remain read-only. Reconciliation finishes only after Prometheus observes the expected jobs UP; exporter failures fail the monitoring run and are visible in the timer journal. It needs the existing managed email rules, OCI CLI credentials, SSH key and passwordless sudo; it does not recreate either host.

Loki uses the same ./jeannie monitoring apply migration/repair path. Its existing PVC is retained, and readable files are archived before being restored under /data/homelab-monitoring/data/loki. The backup/loki directory contains the original Helm values, PVC identity, compressed source data, copy warnings and file/byte counts. Read failures are reported rather than represented as a complete backup. Original archives are never rewritten on a successful retry.

The existing filesystem schema, chunk/index/WAL directories and seven-day retention policy remain in use. Archives preserve older source files even if normal Loki retention later removes them from the active store. The Helm post-renderer keeps the loki.monitoring.svc:3100 address and redirects HTTP and gRPC to Debian; Promtail continues collecting in K3s. Grafana retains its Loki datasource UID, with a local backend URL on Debian. Native Loki config validation precedes rollout; refresh synchronizes configuration and labeled ConfigMap ruler rules, restarting Loki when its configuration changes.

Loki runs on ports 13100/19095 with a 768 MiB memory cap and half a CPU. The pinned Loki image is extended only with a static BusyBox HTTP health probe. Migration verifies readiness, a labels query, and a push through the cluster Service followed by querying that exact log record on Debian. The normal refresh timer checks Loki readiness too. No additional public endpoint is added.