This guide covers the essential information you need to develop and contribute to Chaos Mesh.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt
Use this file to discover all available pages before exploring further.
Project Overview
Chaos Mesh is a cloud-native Chaos Engineering platform for Kubernetes that provides various types of fault simulation. It consists of three main components:- Chaos Controller Manager: Core component responsible for scheduling and managing Chaos experiments through various CRD controllers (Workflow, Scheduler, and fault type controllers)
- Chaos Daemon: Runs as a DaemonSet with privileged permissions, interferes with network devices, file systems, and kernels by accessing target Pod namespaces
- Chaos Dashboard: Web UI for managing, designing, and monitoring Chaos experiments
Project Structure
The Chaos Mesh codebase is organized as follows:cmd/: Main entry points for binaries (controller-manager, daemon, dashboard, builder)controllers/: Controller implementations and reconciliation logicpkg/: Shared packages (chaosdaemon, dashboard, grpc, selector, metrics, etc.)api/: CRD API definitions (v1alpha1)config/: Kubernetes manifests (CRD, RBAC, webhook)helm/chaos-mesh/: Helm chart for deploymente2e-test/: End-to-end test suiteimages/: Dockerfiles for all componentshack/: Build and development scriptsui/: Frontend dashboard (pnpm-based)
Development Workflow
Before Making Changes
Always run checks to ensure your environment is properly set up:Making Changes
-
Fork and Clone the repository:
-
Set up upstream remote:
-
Create a working branch:
- Make your changes in the code
After Code Changes
Depending on what you modified, you may need to regenerate code:If you modified CRDs or APIs:
Run quality checks:
- Format code with
goimports - Lint with
revive - Run
go vet - Check
go.modis tidy - Regenerate install scripts and Helm schemas
Testing Your Changes
Unit Tests
Run all unit tests:- Enables failpoint stubs for testing
- Runs tests with coverage
- Generates coverage reports in
cover.out
E2E Tests
Build and run end-to-end tests:E2E tests require a running Kubernetes cluster. Ensure you have access to a cluster before running these tests.
Building Components
Build all images:
- chaos-controller-manager
- chaos-daemon
- chaos-dashboard
Build specific components locally:
Build the UI:
Committing Changes
-
Keep your branch synced:
-
Commit with sign-off (required for DCO compliance):
-
Push your changes:
Code Generation
Chaos Mesh uses several code generation tools. Here’s what each command does:Generate everything:
Individual generation commands:
Development Environments
Chaos Mesh provides containerized development environments:Build Environment
For compiling binaries with minimal build tools:Dev Environment
For development tasks (code generation, linting, testing):Code Style
Formatting
Usegoimports with local import prefix:
Linting
Run therevive linter:
revive.toml.
Go Modules
Keepgo.mod tidy across all submodules:
go mod tidy in:
- Root directory
api/e2e-test/e2e-test/cmd/e2e_helper/
Security Scanning
Run security scans with gosec:Chaos Types
Chaos implementations are located incontrollers/chaosimpl/:
awschaos: AWS fault injectionazurechaos: Azure fault injectionblockchaos: Block device faultsdnschaos: DNS fault injectiongcpchaos: GCP fault injectionhttpchaos: HTTP fault injectioniochaos: I/O fault injectionjvmchaos: JVM fault injectionkernelchaos: Kernel fault injectionnetworkchaos: Network fault injectionphysicalmachinechaos: Physical machine faultspodchaos: Pod lifecycle faultsstresschaos: CPU/Memory stresstimechaos: Time skew simulation
- CRD definition in
api/v1alpha1/ - Controller implementation in
controllers/chaosimpl/ - Webhooks for validation and defaulting
Common Pitfalls
- Forgetting to run
make check: Always run this before creating a PR - Not regenerating after CRD changes: When modifying CRD structs, always run:
- Failpoint misuse: Enable and disable failpoints properly in tests
- Multi-module complexity: Remember to run
go mod tidyin all directories:- Root
api/e2e-test/
- Controller design violations: Follow the “one controller per field” principle
Next Steps
- Read the Build System documentation
- Understand Controller Design Principles
- Review Contributing Guidelines
- Check out the Development Guide on chaos-mesh.org