Configure the Development Environment
Most components of Chaos Mesh are designed only for Linux, so we suggest that you also configure your development environment to run on Linux. For example, using a virtual machine or WSL 2, and using VSCode Remote as your editor.
This document assumes that you use Linux, without the restriction on specific Linux distributions. If you persist to use Windows/MacOS, you might need some tricks to make it work by yourself.
Before configuring, we suggest to install the development tools for Chaos Mesh.
After installing the above tools, follow the steps below to configure the toolchain for compiling Chaos Mesh.
Clone the Chaos Mesh repository to your local server.
Make sure that Docker is installed and running in your environment.
Compile Chaos Mesh:
You should get these container images:
ghcr.io/chaos-mesh/chaos-dashboard:latest
ghcr.io/chaos-mesh/chaos-mesh:latest
ghcr.io/chaos-mesh/chaos-daemon:latest
After compiling Chaos Mesh, you can run Chaos Mesh in a local Kubernetes cluster.
-
minikube start
Load container images into minikube
Install Chaos Mesh by Helm
note
minikube image load
would cost lots of time, so here is a trick to avoid load images again and again. Using docker from minikube node instead of host’s docker.
eval $(minikube -p minikube docker-env)
UI=1 make
We could use with remote debugging to debug the Chaos Mesh in local environment.
Compile Chaos Mesh with Debug Info
Load container images into minikube
minikube image load ghcr.io/chaos-mesh/chaos-dashboard:latest
minikube image load ghcr.io/chaos-mesh/chaos-mesh:latest
minikube image load ghcr.io/chaos-mesh/chaos-daemon:latest
Install Chaos Mesh by Helm with Enabling Remote Debugging
helm upgrade --install chaos-mesh-debug ./helm/chaos-mesh --namespace=chaos-mesh-debug --create-namespace --set chaosDlv.enable=true --set controllerManager.replicaCount=1
note
Setup Port-Forwarding and Configure IDE To Connect the Remote Debugger
We could use
kubectl port-forward
for port-forwarding the delve debugging server on a local port.For example, if we want to debug
chaos-controller-manger
, we could execute the following command:Then we could access the remote delve debugger server with
127.0.0.1:58000
.note
We always use
8000
in the pod for serving the delve debug server, that’s a convention. You could find that in helm templates files.Then we could configure our favorite IDE to connect to the remote debugger:
For Goland, see Attach to running Go processes with the debugger#Attach to a process on a remote machine.
For VSCode, see .
After finishing the above preparation, you can try to .