Files
home-network-k3s-impl/runbooks/serving/nginx-config.yaml
jakman85andClaude Opus 5 44983095e1 feat(runbooks): make the 42 alert runbook_url annotations resolve
Every platform-health alert rule carries
`runbook_url: "https://${BASE_DOMAIN}/runbooks/<name>"` — 42 annotations over 34
distinct names, across platform/monitoring/alerts.yaml,
platform/monitoring/pvc-capacity-alerts.yaml, platform/cnpg/alerts.yaml and
platform/kubevirt/alerts.yaml. There was no runbooks/ directory and no HTTPRoute
serving that path: an in-cluster probe of
https://home.keithjackson.dev/runbooks/node-down returned HTTP 404. Every alert that
reached a human handed them a dead link at the exact moment the documentation is read,
and the annotation made it look solved — the same green-surface-over-absent-mechanism
class as the import Job that reported success while storing placeholder secrets.

No alerts.yaml is touched and no runbook_url value changes. The existing URL scheme is
made to resolve instead.

WHAT LANDS
- runbooks/<34>.md — one per name, each grounded in this cluster's real topology and,
  where one exists, its real incident history: the 2026-09-07 k3s-prod-1 etcd I/O
  starvation (measured PSI 11.36 vs 0.75/1.29, the exact journal lines, the four
  mechanisms proven inert), the Longhorn reboot tax and the freeze/thaw of
  concurrent-replica-rebuild-per-node-limit, Cilium's once-resolved egress interface
  cache (Ifindex 3 against a live 1780) and the absence of OSS failover, the CNPG
  38-hour ContinuousArchiving=False with its measured 6.8 MiB/h disk-full clock and the
  2026-09-12 aggregation-scope fix, the 2026-09-06 Keycloak lockout in which all 12
  clients held literal placeholder secrets behind an entirely green cluster, the Velero
  R2 x-amz-tagging NotImplemented incompatibility and its v1.14.3-rc.2 pin, and swap
  re-enabling itself across reboots via systemd-gpt-auto-generator.
  Each page states what the alert means HERE, the first diagnostic commands, likely
  causes ordered by probability with a remediation each, and when to escalate or stop.
- Every page uses FULLY-QUALIFIED resource names and says why: three CRDs register the
  kind `Backup` here, the bare short name resolves to Longhorn's (zero objects), so
  `kubectl get backup -A` prints "No resources found" on a cluster holding 6 Velero and
  27 CNPG backups. Acting on that false negative is how a CLI quirk becomes data loss.
- Every page states that kubectl only works via
  `infra/devcontainer/dev.sh run bash -c '...'` with an explicit `--context k3s-prod`,
  because dev.sh defaults its current-context to k3s-dev.
- Pages also record which alert groups are INERT today (measured 2026-09-13: no
  Longhorn, cert-manager, Flux-controller or Hubble scrape job exists, so 13 rules
  evaluate against nothing) so nobody reads their silence as health.

SERVING — runbooks/serving/ plus clusters/base/runbooks.yaml
A two-replica nginx-unprivileged serving a ConfigMap generated from runbooks/*.md, at
the apex `/runbooks` prefix, in its own non-gating post-platform Flux tier
(dependsOn platform-config, wait:false) — the platform/homepage pattern, file for file.
- The service catalog cannot express this route: ingressRoutes[].host is pattern-bound
  to a single DNS label plus the apex, so the bare apex is unrepresentable, and there is
  no path field.
- Rejected: redirecting to the Gitea web UI. A runbook is read when the platform is
  broken, and Gitea is an app-tier workload whose own dependencies several of these
  runbooks document; Gateway API's RequestRedirect also has no "append .md" modifier,
  so it would need 34 hand-maintained ReplaceFullPath rules.
- configMapGenerator maps each file to an EXTENSIONLESS key (node-down=node-down.md),
  so /runbooks/node-down is a plain static lookup with no rewrite rule. Served as
  text/plain: the namespace has DNS-only egress, so a CDN markdown renderer could not
  load anyway.
- The tier declares NO postBuild.substituteFrom, deliberately: envsubst would run over
  the prose and silently empty every ${...} shell example (it fails open — the 2026-09-01
  emptied Cilium k8sServiceHost). The HTTPRoute omits `hostnames:` and inherits the
  https-apex listener's, so nothing needs substituting.

AUTH — PUBLIC, deliberately
auth-mode=none. Gating these pages behind oauth2-proxy/Keycloak would make
runbooks/keycloak-down unreadable when Keycloak is down and
runbooks/keycloak-client-secrets unreadable during the exact 2026-09-06 failure mode.
An operator who cannot log in is this route's primary reader. Content is operational
procedure only, no secrets. The rationale is recorded in an annotation on the HTTPRoute
so the route is left OUT of the Gateway ext-authz attachment when forward-auth
enforcement lands.

PROVEN — in-cluster probe through the Gateway on prod
  /runbooks/node-down        HTTP 200   8613 bytes  text/plain; charset=utf-8
  /runbooks/keycloak-down    HTTP 200   9378 bytes  text/plain; charset=utf-8
  /runbooks/cnpg-archiving   HTTP 200  11729 bytes  text/plain; charset=utf-8
  /runbooks/longhorn-faulted HTTP 200   9135 bytes  text/plain; charset=utf-8
  /runbooks/vpn-down         HTTP 200  11092 bytes  text/plain; charset=utf-8
  /runbooks/backup-failure   HTTP 200   9604 bytes  text/plain; charset=utf-8
HTTPRoute Accepted by io.cilium/gateway-controller on sectionName https-apex; the
`/runbooks` prefix wins over homepage's apex `/` by Gateway API longest-path precedence.

GUARD — conformance/tests/l0-static/alert-runbooks-resolvable (R-OBS-04)
363 offline assertions. It checks BOTH halves, because the regression is silent in both
directions: an alert with a new runbook_url and no runbook links to a 404, AND a runbook
committed without its configMapGenerator entry is in git, reviewed, merged, and still
404s in the cluster. Also asserts a quality floor so a stub cannot make the link look
fixed, and that route/listener/nginx prefix agree with the annotations.
Proven to fail, then reverted: a bogus runbook_url (2 FAIL), a runbook removed from the
generator (1 FAIL), and a 31-byte stub (7 FAIL).

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-12 23:49:58 -05:00

82 lines
3.9 KiB
YAML

---
# nginx server config for the runbook static server. Hand-authored ConfigMap (same plain-manifest style
# as platform/homepage), mounted over /etc/nginx/conf.d/default.conf.
#
# WHY THE URI NEEDS NO REWRITE. The alert annotations are `.../runbooks/<name>` with NO `.md` suffix, and
# this repo must not change them (they are spread across four alerts.yaml files that other work is
# editing). Rather than rewriting the URI, the ConfigMap generated from runbooks/*.md maps each file to an
# EXTENSIONLESS key (`node-down=node-down.md` in ../kustomization.yaml) and is mounted at <root>/runbooks/.
# So `/runbooks/node-down` is a plain static file lookup: no rewrite, no fallback chain, nothing to get
# subtly wrong at 3am.
#
# CONTENT TYPE. An extensionless file has no MIME mapping, so nginx would serve it as
# application/octet-stream and a browser would DOWNLOAD it instead of showing it. The empty `types {}`
# block removes the mapping table entirely inside these locations and `default_type` forces
# text/plain;charset=utf-8 — markdown read as plain text, which is what markdown is for, and which works
# identically in a browser, in `curl`, and in a terminal with no JavaScript, no CDN and no egress. This
# namespace has DNS-only egress, so a client-side markdown renderer fetched from a CDN could not load
# anyway; plain text is the honest choice here, not a shortcut.
apiVersion: v1
kind: ConfigMap
metadata:
name: runbooks-nginx
namespace: runbooks
labels:
app.kubernetes.io/name: runbooks
data:
default.conf: |
# Replaces the image's stock conf.d/default.conf. Port 8080 because the base image is
# nginx-unprivileged (runs as uid 101 and cannot bind 80).
server {
listen 8080;
server_name _;
root /usr/share/nginx/html;
# Never leak the server version on an error page.
server_tokens off;
# Keep the 301 below relative so it works through the Gateway without knowing the public host.
absolute_redirect off;
# Probes. Kept OUT of the access log so a 15s kubelet probe does not bury the one request an
# operator actually made.
location = /healthz {
access_log off;
default_type text/plain;
return 200 "ok\n";
}
# /runbooks and /runbooks/ both land on the index (runbooks/README.md, mounted as the
# extensionless key `README`).
location = /runbooks {
return 301 /runbooks/;
}
location = /runbooks/ {
types { }
default_type "text/plain; charset=utf-8";
try_files /runbooks/README =404;
}
# The runbooks themselves. One static file per alert runbook_url.
location /runbooks/ {
types { }
default_type "text/plain; charset=utf-8";
# A ConfigMap volume is a tree of symlinks into ..data/; nginx must follow them.
disable_symlinks off;
try_files $uri =404;
add_header Cache-Control "public, max-age=300";
# An unknown name gets a 404 with a POINTER, not a blank page: the likeliest cause is an
# alert whose runbook was never written, and the reader needs to know where to look next.
error_page 404 = @no_such_runbook;
}
location @no_such_runbook {
default_type "text/plain; charset=utf-8";
return 404 "No runbook by that name.\n\nIndex of all runbooks: /runbooks/\nSource of truth: runbooks/<name>.md in the home-network-k3s-impl repo.\nIf an alert linked you here, its runbook_url has no matching runbooks/<name>.md, and the\nconformance check alert-runbooks-resolvable should have caught it before merge.\n";
}
# Nothing else is served from this pod. The apex `/` prefix belongs to homepage.
location / {
default_type "text/plain; charset=utf-8";
return 404 "This host serves /runbooks/ only.\n";
}
}