Key Structures
April 15, 2026 ยท View on GitHub
cmd/kuberhealthy
Config(config.go)- Holds all runtime settings loaded from environment variables.
- Fields cover listen addresses, default scheduling intervals, retention limits, and TLS options.
- Leader election fields (enablement, lease name/namespace, and timing durations) control Lease-based failover behavior.
ReportingURL()derives the absolute/checkendpoint advertised to pods.
Globals(main.go)- Struct literal containing the Kubernetes REST config, Kubernetes clientset,
controller-runtime client, and the active
*kuberhealthy.Kuberhealthyinstance. - Shared across HTTP handlers so they can perform CRUD operations.
- Struct literal containing the Kubernetes REST config, Kubernetes clientset,
controller-runtime client, and the active
internal/kuberhealthy
Kuberhealthy(kuberhealthy.go)- Encapsulates the scheduling logic for
HealthCheckresources. - Stores the process context, cancellation function, Kubernetes client, event
recorder, reporting URL, leader state, and coordination primitives such as
loopMu. - Captures controller metrics snapshots (scheduler loop timing, due checks, reaper sweep timing, and deletion counts) for Prometheus export.
- Exposes methods for starting and stopping the scheduler, beginning specific runs, tracking timeouts, and validating report UUIDs.
- Encapsulates the scheduling logic for
checkRun/activeCheckhelpers- Maintain in-memory bookkeeping for currently executing checks, ensuring duplicate runs do not overlap and that timeout cleanup can resume after a restart.
pkg/api
HealthCheck- Custom resource definition representing a synthetic check.
Specembeds aCheckPodSpecthat includes Kubernetes pod metadata and the exactPodSpecto run, whileStatuscaptures runtime results.Statusnow includes success/failure counters and timestamps for the last OK or failed run, enabling SLO-focused metrics.
CheckPodSpecandCheckPodMetadata- Define the pod template executed for each run, plus optional labels and annotations applied by the controller.
- Helper Functions
- Functions such as
GetCheck,UpdateCheck, andSetCurrentUUIDwrap common CRUD tasks and guarantee consistent error handling across packages.
- Functions such as
internal/metrics
Exporter(exporter.go)- Reads the stored check status and emits Prometheus gauges, counters, and histograms.
- Renders metrics from the current in-memory and persisted check state.
These structures communicate primarily through the Kubernetes API server and the
shared Globals clients, enabling the controller to orchestrate checks while the
HTTP layer provides observability and reporting interfaces.