homek8s/monitoring/controllers/home/gateway-probe.yaml

181 lines
6.2 KiB
YAML
Raw Permalink Normal View History

# Internal-gateway liveness probe (WireGuard-only services).
#
# Why this exists: the internal listeners (8081 Grafana, 8084 Hubble UI) are
# served by the Cilium hostNetwork Envoy on the node(s) carrying
# `node-role.kubernetes.io/gateway=true`. Before 2026-10-27 that label was on
# both rpi and siriussec, and the Pi's Envoy could complete TCP to a backend
# pod on siriussec but never finish the request: every request to
# 10.10.0.1:8081/8084 hung for 5 s and then returned 503, even from the Pi's
# own 127.0.0.1. Clients that tried "either IP" therefore saw the dashboards
# flap. The label now lives on siriussec only, and this probe makes a
# regression (label re-added, listener gone, Envoy wedged, firewall rule
# dropped) visible in Prometheus/Grafana instead of on Lance's phone.
#
# Prober: blackbox-exporter, pinned to siriussec (same node as the Gateway, so
# the probe crosses the pod network over the WireGuard mesh rather than
# loopback). Nothing here is public: the prober talks to the node IP over the
# mesh and the host firewall in `infrastructure/networking/internal` is what
# restricts the listeners themselves.
---
apiVersion: v1
kind: ConfigMap
metadata:
name: blackbox-exporter
namespace: monitoring
data:
blackbox.yml: |
modules:
# Grafana answers / with a 302 to /login, Hubble UI answers 200.
http_2xx_or_3xx:
prober: http
timeout: 5s
http:
valid_status_codes: [200, 301, 302, 303, 307, 308]
preferred_ip_protocol: ip4
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: blackbox-exporter
namespace: monitoring
labels:
app.kubernetes.io/name: blackbox-exporter
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: blackbox-exporter
template:
metadata:
labels:
app.kubernetes.io/name: blackbox-exporter
spec:
nodeSelector:
kubernetes.io/hostname: siriussec
containers:
- name: blackbox-exporter
image: prom/blackbox-exporter:v0.25.0
args:
- --config.file=/etc/blackbox_exporter/blackbox.yml
ports:
- name: http
containerPort: 9115
readinessProbe:
httpGet:
path: /-/healthy
port: http
initialDelaySeconds: 5
resources:
requests:
cpu: 10m
memory: 32Mi
limits:
cpu: 100m
memory: 64Mi
volumeMounts:
- name: config
mountPath: /etc/blackbox_exporter
volumes:
- name: config
configMap:
name: blackbox-exporter
---
apiVersion: v1
kind: Service
metadata:
name: blackbox-exporter
namespace: monitoring
labels:
app.kubernetes.io/name: blackbox-exporter
spec:
selector:
app.kubernetes.io/name: blackbox-exporter
ports:
- name: http
port: 9115
targetPort: http
---
# Only 10.10.0.2 is a serving internal-gateway 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`, so the status list is NOT a "try either IP" guide.
apiVersion: monitoring.coreos.com/v1
kind: Probe
metadata:
name: internal-gateway
namespace: monitoring
labels:
release: kube-prometheus-stack
spec:
jobName: internal-gateway
interval: 30s
module: http_2xx_or_3xx
prober:
url: blackbox-exporter.monitoring.svc:9115
path: /probe
targets:
staticConfig:
static:
- http://10.10.0.2:8081/
- http://10.10.0.2:8084/
labels:
exposure: wireguard-internal
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: internal-gateway
namespace: monitoring
labels:
release: kube-prometheus-stack
spec:
groups:
- name: internal-gateway
rules:
- alert: InternalGatewayUnreachable
expr: probe_success{job="internal-gateway"} == 0
for: 3m
labels:
severity: warning
annotations:
summary: >-
Internal gateway listener {{ $labels.instance }} is not answering
(probe_success 0 for 3m)
description: >-
Grafana (8081) / Hubble UI (8084) are served by cilium-envoy on
siriussec only. Check that rpi has NOT re-acquired
node-role.kubernetes.io/gateway=true, that cilium-envoy is Running
on siriussec, that the internal_gw nft table accepts 10.10.0.0/24
and 10.244.0.0/16, and that the route/service behind the listener
exists.
# The exact regression this card fixed: rpi re-acquiring the gateway
# label adds a second Envoy that answers 5 s/503s for everything it is
# asked. kube-state-metrics exposes role labels as kube_node_role, so
# this needs no extra probe target (`kube_node_labels` is not exposed
# with the stack's default metric allowlist).
- alert: GatewayNodeCountNotOne
expr: count(kube_node_role{role="gateway"}) != 1
for: 5m
labels:
severity: warning
annotations:
summary: >-
{{ $value }} nodes carry node-role.kubernetes.io/gateway=true
(expected exactly 1 — siriussec)
description: >-
Every gateway-labelled node runs cilium-envoy and binds 8080/8081/
8084. A node that does not also run the backend pods answers 503
after exactly 5 s for everything (that is how 10.10.0.1 made the
internal dashboards flap). Remove the label:
kubectl label node <node> node-role.kubernetes.io/gateway-
- alert: InternalGatewayProbeMissing
expr: absent(probe_success{job="internal-gateway"})
for: 10m
labels:
severity: warning
annotations:
summary: The internal-gateway blackbox probe has disappeared from Prometheus
description: >-
Either the Probe object / blackbox-exporter pod is gone or the
operator is not selecting it (label release=kube-prometheus-stack).
The dashboards are then unmonitored, not necessarily broken.