Chaos Mesh uses a sophisticated build system based on Make and containerized build environments. This guide explains the build infrastructure and available make targets.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.
Build Architecture
The build system uses two specialized Docker images for different purposes:Build Environment (build-env)
Minimal environment for compiling binaries:
- Compiling Go binaries
- Building C components (pause, fakeclock)
- Creating production artifacts
Development Environment (dev-env)
Full development environment with all tools:
- Code generation (CRDs, clients, deepcopy)
- Linting and formatting
- Running tests
- Building protobuf definitions
- Generating Swagger specs
Each branch has its own image tag for build-env and dev-env, automatically determined by
hack/env-image-tag.sh.Environment Variables
Build Configuration
Core Build Targets
Building Everything
Building Components
Container Images
Local Binaries
Build binaries without Docker for local development:Building the UI
The dashboard UI requires pnpm and is optional:hack/embed_ui_assets.sh.
Code Generation Targets
Chaos Mesh generates significant code from CRD definitions and protobuf schemas.Complete Generation
- CRD manifests (
make config) - Deepcopy methods (
make generate-deepcopy) - Kubernetes clients (
make generate-client) - Chaos builder code (
make chaos-build) - Swagger specs (
make swagger_spec) - Combined CRD YAML (
make manifests/crd.yaml)
Individual Generation Steps
CRD Manifests
config/crd/bases/*.yaml- Individual CRD fileshelm/chaos-mesh/crds/*.yaml- Copies for Helm chart
Deepcopy Methods
controller-gen to generate zz_generated.deepcopy.go files.
Kubernetes Clients
pkg/client/versioned/- Clientsetpkg/client/listers/- Listerspkg/client/informers/- Informers
Chaos Builder
bin/chaos-builder to generate boilerplate code for chaos types.
Protocol Buffers
pkg/chaosdaemon/pb/- Chaos daemon protocolpkg/chaoskernel/pb/- Chaos kernel protocol
Swagger/OpenAPI
pkg/dashboard/swaggerdocs/ for frontend consumption.
Makefiles
Quality Checks
Complete Check Suite
make generate- Regenerate all codemake vet- Rungo vetmake lint- Runrevivelintermake fmt- Format code withgoimportsmake tidy- Ensurego.modis tidymake install.sh- Regenerate install scriptmake helm-values-schema- Update Helm schema
Individual Quality Targets
Formatting
goimports -w -l -local github.com/chaos-mesh/chaos-mesh on all Go files except generated code.
Linting
revive.toml.
Vetting
Tidy Dependencies
This runs
go mod tidy in multiple directories:- Root directory
api/e2e-test/e2e-test/cmd/e2e_helper/
Security Scanning
gosec to find common security issues.
Testing Targets
Unit Tests
- Enables failpoint stubs
- Runs tests with
CGO_ENABLED=1 - Generates coverage report (
cover.out) - Disables failpoint stubs
Coverage Reports
cover.json- JSON coverage datacover.xml- XML coverage datacover/index.html- HTML coverage report
E2E Tests
Failpoint Control
Failpoints enable fault injection in tests:Test Utilities
bin/test/timer- Time testing utilitybin/test/multithread_tracee- Multi-thread tracing testpkg/time/fakeclock/*.o- Fake clock objects
Advanced Targets
Special Components
Pause Binary
hack/pause.c.
Watchmaker
Installation Scripts
hack/update_install_script.sh to create the one-line installer.
Helm Values Schema
helm/chaos-mesh/values.schema.json from helm/chaos-mesh/values.yaml.
Cleanup
Build System Internals
Containerized Shell Execution
Many targets useSHELL:=$(RUN_IN_DEV_SHELL) or SHELL:=$(RUN_IN_BUILD_SHELL) to run commands inside Docker containers.
This is determined by:
Generated Makefiles
The build system includes generated makefiles:binary.generated.mk- Binary build targetscontainer-image.generated.mk- Container image targetslocal-binary.generated.mk- Local binary targets
LDFLAGS
Build flags are set via:- Version information
- Git commit hash
- Build timestamp
-s -wfor stripping (unlessDEBUGGER=1)
Common Build Workflows
Development Iteration
Full PR Preparation
Release Build
Troubleshooting
Build Cache Issues
Clear the build cache:Environment Image Issues
Rebuild environment images:Module Issues
Ensure all modules are tidy:Generated Code Out of Sync
Regenerate everything:Next Steps
- Review Developer Guide for development workflows
- Understand Controller Design Principles
- Check Contributing Guidelines for PR process