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.

    1. Clone the Chaos Mesh repository to your local server.

    2. Make sure that Docker is installed and running in your environment.

    3. 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.

      1. minikube start
    1. Load container images into minikube

    2. 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.

      1. eval $(minikube -p minikube docker-env)
      2. UI=1 make

      We could use with remote debugging to debug the Chaos Mesh in local environment.

      1. Compile Chaos Mesh with Debug Info

      2. Load container images into minikube

        1. minikube image load ghcr.io/chaos-mesh/chaos-dashboard:latest
        2. minikube image load ghcr.io/chaos-mesh/chaos-mesh:latest
        3. minikube image load ghcr.io/chaos-mesh/chaos-daemon:latest
      3. Install Chaos Mesh by Helm with Enabling Remote Debugging

        1. helm upgrade --install chaos-mesh-debug ./helm/chaos-mesh --namespace=chaos-mesh-debug --create-namespace --set chaosDlv.enable=true --set controllerManager.replicaCount=1

        Configure the Development Environment - 图2note

      4. 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 .