Run Chaos Experiment

    The first step is always to deploy a testing cluster. For illustration purposes, web-show is used as an example cluster because it allows us to directly observe the effect of network chaos. You can also deploy your own application for testing.

    After executing the above command, you can access in the browser to check the web-show application.

    The chaos experiment configuration is defined in a YAML file. You need to create your own experiment configuration file based on the available fields in the sample below:

    1. apiVersion: chaos-mesh.org/v1alpha1
    2. metadata:
    3. name: web-show-network-delay
    4. spec:
    5. action: delay # the specific chaos action to inject
    6. mode: one # the mode to run chaos action; supported modes are one/all/fixed/fixed-percent/random-max-percent
    7. selector: # pods where to inject chaos actions
    8. - default
    9. labelSelectors:
    10. "app": "web-show" # the label of the pod for chaos injection
    11. latency: "10ms"
    12. duration: "30s" # duration for the injected chaos experiment
    13. scheduler: # scheduler rules for the running time of the chaos experiments about pods.
    14. cron: "@every 60s"
    1. kubectl apply -f network-delay.yaml

    Then you can access http://localhost:8081 in the browser to check the result of the chaos experiment.

    From the line graph, you can tell that there is a 10 ms network delay every 60 seconds. If you are intrigued and want to try out more chaos experiments with Chaos Mesh, check out .

    In this section, you will learn some follow-up operations when the chaos experiment is running.

    1. kubectl annotate networkchaos web-show-network-delay experiment.chaos-mesh.org/pause=true
    1. kubectl annotate networkchaos web-show-network-delay experiment.chaos-mesh.org/pause-

    If you encounter a situation that the delete action is blocked, it means that there are some target pods fail to recover. You can check the log of Chaos Mesh or just feel free to file an issue. In addition, you also can force delete the chaos experiment by the following command:

    1. kubectl annotate networkchaos web-show-network-delay chaos-mesh.chaos-mesh.org/cleanFinalizer=forced

    Note:

    If Chaos Dashboard was not installed, upgrade Chaos Mesh by executing helm upgrade chaos-mesh chaos-mesh/chaos-mesh --namespace=chaos-testing --set dashboard.create=true.

    A typical way to access it is to use kubectl port-forward:

    1. kubectl port-forward -n chaos-testing svc/chaos-dashboard 2333:2333

    Then you can access in the browser.

    To get a quick look of Chaos Dashboard workflow, check out the following articles: