homek8s/monitoring/controllers/home/garage.yaml

163 lines
5.3 KiB
YAML
Raw Normal View History

infrastructure(garage): commit the config, prove WG-only, split keys, back it up, scrape it Garage was the only piece of the platform in no git repository and reachable from more than WireGuard. This is a hardening/ownership pass, not a migration — the container stays on the Pi. - infrastructure/garage/: docker-compose.yml (pinned dxflrs/garage:v1.1.0, every publish on an explicit 10.10.0.1 / 127.0.0.1 address, no 0.0.0.0), garage.toml (rpc_secret moved to /etc/garage/garage.env, [s3_web]/3902 removed, admin API on 3903 for metrics), README (apply, state, restore, keys, backup, metrics) and an explicit note that Flux does not apply it. - host/garage-firewall.nft: PREROUTING priority -140 drop of 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 from publishing S3 on the LAN. Measured: a 0.0.0.0:3902 publish stayed unreachable from the LAN and the drop counter incremented. - backup/: garage-backup.sh meta|data + systemd timers (meta hourly, data nightly) rsyncing to [email protected]:/root/garage-backup over wg-remote. Nothing else backs up Forgejo or the PG PVCs; that stays uncovered. - monitoring/controllers/home/garage.yaml: Service + EndpointSlice + ServiceMonitor for 10.10.0.1:3903 and five alerts. Target is UP. - apps/base/siriusdevops/networkpolicy-site-egress.yaml: first policy in the namespace. CiliumNetworkPolicy, not a k8s NetworkPolicy: 10.10.0.1 is a cluster node (reserved:remote-node), so ipBlock 10.10.0.1/32 is inert. Egress whitelist = TCP 3900 to a node + cluster DNS; measured 403 on 3900, timeouts on 3900-adjacent 5000/3903, on 10.10.0.2:8080 and on the internet. Keys: ci-push (W only, siriusdevops-media) and site-fetch (R only, same bucket) replace the shared ci-key, which is deleted. The k8s Secret and the two Forgejo repo secrets were repointed. No key material is in this commit.
2026-11-19 16:32:58 -05:00
# Garage (Pi, WireGuard-only object store) -> Prometheus
#
# Garage runs OUTSIDE the cluster (Docker on rpi, see infrastructure/garage/),
# so it has no pod to scrape. Its admin API serves /metrics on the Pi's
# WireGuard hub address 10.10.0.1:3903, which the cluster reaches over the mesh
# by native routing — the same path the site's media initContainer already uses
# for 10.10.0.1:3900.
#
# Service + EndpointSlice with no selector is the supported way to scrape a
# fixed external address with ServiceMonitor: the operator resolves endpoints
# from the Service's EndpointSlices, so there is nothing for the cluster to
# schedule and no node affinity problem.
#
# Before 2026-11-19 the admin port was published on loopback only, so /metrics
# returned "connection refused" from inside the cluster and Garage was invisible
# to Prometheus. The listener is now published on 10.10.0.1 only (never
# 0.0.0.0), with no metrics_token because the port does not leave the mesh.
#
# No Alertmanager is deployed in this stack: these rules show up under
# Prometheus -> /alerts and Grafana -> Alerting, they do not page anyone.
---
apiVersion: v1
kind: Service
metadata:
name: garage
namespace: monitoring
labels:
app: garage
spec:
type: ClusterIP
# No selector on purpose — the endpoints are static, not pods.
ports:
- name: metrics
port: 3903
targetPort: 3903
protocol: TCP
---
apiVersion: discovery.k8s.io/v1
kind: EndpointSlice
metadata:
name: garage
namespace: monitoring
labels:
app: garage
kubernetes.io/service-name: garage
addressType: IPv4
ports:
- name: metrics
port: 3903
protocol: TCP
endpoints:
- addresses:
- 10.10.0.1
conditions:
ready: true
---
apiVersion: v1
kind: Endpoints
metadata:
# Kept for older tooling that still reads the Endpoints API; the EndpointSlice
# above is what the operator actually consumes on this cluster.
name: garage
namespace: monitoring
labels:
app: garage
subsets:
- addresses:
- ip: 10.10.0.1
ports:
- name: metrics
port: 3903
protocol: TCP
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: garage
namespace: monitoring
labels:
release: kube-prometheus-stack
spec:
jobLabel: app
namespaceSelector:
matchNames:
- monitoring
selector:
matchLabels:
app: garage
endpoints:
- port: metrics
path: /metrics
interval: 30s
scrapeTimeout: 10s
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: garage
namespace: monitoring
labels:
release: kube-prometheus-stack
spec:
groups:
- name: garage
rules:
- alert: GarageDown
expr: up{job="garage"} == 0
for: 5m
labels:
severity: critical
annotations:
summary: "Garage metrics endpoint is down (10.10.0.1:3903)"
description: >-
Prometheus cannot scrape Garage. Either the container is stopped
(docker compose on the Pi), the 3903 publish was lost, or the
WireGuard mesh is broken. The site's media initContainer degrades
gracefully when this happens, so nothing else will report it.
- alert: GarageClusterUnhealthy
expr: cluster_healthy{job="garage"} == 0
for: 5m
labels:
severity: critical
annotations:
summary: "Garage reports an unhealthy cluster"
description: >-
Single storage node d053db4dfc97bf78 was not able to reach a
healthy state. S3 requests will fail until this clears.
- alert: GarageDiskFillingUp
# Same 80% threshold as this stack's other disk alerts.
expr: >-
(1 - (garage_local_disk_avail{job="garage"} / garage_local_disk_total{job="garage"})) > 0.8
for: 15m
labels:
severity: warning
annotations:
summary: "Garage storage node is more than 80% full"
description: >-
The Pi's Garage data directory is filling up. Uploads start failing
hard at 100%; free space or raise the node capacity in Garage,
do not delete the meta/ directory.
- alert: GarageMetadataGcBacklog
expr: table_gc_todo_queue_length{job="garage"} > 1000
for: 30m
labels:
severity: warning
annotations:
summary: "Garage metadata GC queue is backed up"
description: >-
The metadata engine has more than 1000 pending GC operations. This
is the early signal for a metadata problem, which is the failure
mode that orphans data/ — check `garage meta snapshot` and backups
are running before it becomes a restore.
- alert: GarageResyncErroredBlocks
expr: block_resync_errored_blocks{job="garage"} > 0
for: 15m
labels:
severity: warning
annotations:
summary: "Garage has blocks that failed to resync"
description: >-
At least one data block could not be resynchronised on the storage
node. With replication_factor 1 there is no other copy, so this is
data at risk — verify the object is readable and check backups.