ποΈ Architecture overview
This section is for people who want to understand the system, extend it, or debug an unusual alert. Start here, then follow the alert path from detection to delivery.
kwatch is a restart-safe, single-binary Kubernetes controller that watches cluster resources via informers, detects incidents, builds a dependency graph to explain why they happened, correlates and deduplicates them, and dispatches alerts through 56 providers. Restart-critical state is persisted in namespace-scoped ConfigMaps.
The default deployment runs two replicas with Kubernetes Lease election. One replica is the active leader; the other is a standby that serves health endpoints and participates in election. Only the leader watches resources, delivers notifications, or writes mutable state. A one-replica deployment is supported but has no Kwatch self-failover.
High-Level Architectureβ
βββββββββββββββββββββββββββββββββββββββ
β Kubernetes API Server β
ββββββββββ¬βββββββββ¬βββββββββ¬ββββββββββββ
β β β
ββββββββββββββββ ββββββ ββββββ
βΌ βΌ βΌ
βββββββββββββββββββββββββ ββββββββββββ ββββββββββββββββββ
β Pod Informer β βNode Inf. β βDeploy/Job/DS/ β
β (events, secrets) β β β βCJ/HPA Inf. β
ββββββββββββ¬βββββββββββββ ββββββ¬ββββββ βββββββββ¬βββββββββ
β β β
βΌ βΌ βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Monitor families + direct runtimes β
β policy β enrichment β observations β hints β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ Incident
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Incident Engine (internal/incident) β
β β’ Incidents keyed by owner (create/update/resolve)β
β β’ Insight engine: cause, impact, what-changed β
β β’ Dependency graph (podβnode/owner/config) β
β β’ Mass-failure detection (30% blast radius) β
β β’ Smart grouping + cooldown + escalation β
β β’ Node inhibition β
β β’ Resolve hold-down (flap dampening) β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ Enriched Incident
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Delivery Manager (internal/delivery) β
β β’ 56 providers, one report for all β
β β’ Non-blocking fan-out β
β β’ Retry (only retryable failures) β
β β’ Fallback provider β
β β’ Dead-letter queue β
ββββ¬ββββββββββββ¬ββββββββββββ¬ββββββββββββ¬βββββββββββββ
βΌ βΌ βΌ βΌ
ββββββββ ββββββββββ βββββββββ ββββββββββββ
βSlack β βDiscord β βEmail β βWebhook β ...56 providers
ββββββββ ββββββββββ βββββββββ ββββββββββββ
The source tree under internal/ organizes the controller, monitor families,
incident engine, insight, config, delivery providers, and periodic watchdogs.
Each is described in
more detail on the following pages.
Continue reading to explore each package, the end-to-end data flow, and the design decisions that shaped kwatch.