$ show linki/chaoskube
chaoskube is a Kubernetes chaos engineering tool that periodically terminates random pods in a cluster. It runs as a long-lived process (deployment or CLI) and uses the Kubernetes API to list, filter, and delete pods. The architecture is a single binary with a main entry point that wires together configuration (flags/env vars), a Kubernetes client, pod filters (labels, annotations, namespaces, kinds, name regex, age, time-based exclusions), a terminator (currently only delete-pod), and optional notifiers (Slack). The core loop in `chaoskube.Run()` ticks on a configurable interval, calls `TerminateVictims()` which checks time-based exclusions, selects victims via `Victims()` (which calls `Candidates()` applying all filters), and deletes them. The code is well-structured with clear interfaces for termination and notification, comprehensive test coverage using fake Kubernetes clients, and a Helm chart for deployment. It is a mature, actively maintained project with 1935 stars and a strong community.
The LLM identified 2 files worth highlighting for reuse:
Provides pure, well-tested utility functions for parsing weekdays, time periods, and days of year, as well as a `RandomPodSubSlice` function for shuffling and selecting a subset of pods. The `TimePeriod` struct and its `Includes` method handle both same-day and cross-midnight time ranges correctly. These functions are isolated (only depend on standard library and Kubernetes core types for pod structs) and could be extracted into a separate library for any Kubernetes-related project needing time-based filtering or random selection.
Defines a `Notifier` interface with a single `NotifyPodTermination` method and a `Notifiers` composite that fans out notifications to multiple implementations. This clean abstraction allows adding new notification channels (e.g., email, PagerDuty) without modifying core logic. The composite pattern handles errors gracefully using `go-multierror`. This component is self-contained and could be reused in any system that needs to notify multiple channels about events.