How netflix/chaosmonkey works
Chaos Monkey is a Go CLI that schedules randomized production instance terminations through Spinnaker. Its main workflow builds a schedule, persists it and installs cron entries; later, a terminate command checks safeguards, selects an eligible instance, records the event and invokes a terminator. The README documents Spinnaker as required, while sampled code shows its API client and the termination interfaces. Some runtime wiring is unsampled, so uncertain links are omitted or marked dashed.
Main entry points: chaosmonkey.go Command router · term.go Termination logic · main.go CLI entry · schedule.go Schedule engine
Components 17
CLI and configuration
- CLI entry
cmd/chaosmonkey/main.go - Command router
command/chaosmonkey.go - Configuration
config/monkey.go
Scheduling and eligibility
- Schedule engine
schedule/schedule.go - Eligibility checks
eligible/eligible.go - Schedule storage
schedstore/schedstore.go
Termination workflow
- Termination logic
term/term.go - Terminator adapter
term/terminator.go - Tracker providers
tracker/tracker.go - Outage guard
outage/outage.go
External integrations
- Deployment model
deploy/deployment.go - MySQL persistence
mysql/mysql.go - Spinnaker client
spinnaker/spinnaker.go - Spinnaker terminator
spinnaker/terminator.go
Other components
- Operator
- MySQL service
- Spinnaker service
Connections 22
- Operator → CLI entry: runs CLI
cmd/chaosmonkey/main.go - CLI entry → Command router: executes
cmd/chaosmonkey/main.go - Command router → Configuration: loads settings
command/chaosmonkey.go - Command router → Schedule engine: generates schedule
command/chaosmonkey.go - Command router → Schedule storage: uses schedule store
command/chaosmonkey.go - Command router → MySQL persistence: configures persistence
command/chaosmonkey.go - Command router → Spinnaker client: configures client
command/chaosmonkey.go - Schedule engine → Deployment model: queries deployments
schedule/schedule.go - Schedule engine → Configuration: reads app settings
schedule/schedule.go - Command router → Eligibility checks: lists eligible instances
- Eligibility checks → Deployment model: queries instances
eligible/eligible.go - Command router → Termination logic: runs termination
- Termination logic → Eligibility checks: selects instance
term/term.go - Termination logic → Tracker providers: records termination
term/term.go - Termination logic → Outage guard: checks outage
term/term.go - MySQL persistence → MySQL service: reads and writes
mysql/mysql.go - Spinnaker client → Spinnaker service: queries API
spinnaker/spinnaker.go - Termination logic → Terminator adapter: uses terminator
- Terminator adapter → Spinnaker terminator: may delegate
- Spinnaker terminator → Spinnaker service: terminates instances
- CLI entry → Outage guard: registers provider
cmd/chaosmonkey/main.go - CLI entry → Tracker providers: registers provider
cmd/chaosmonkey/main.go