Installation

This document describes how to install Chaos Mesh to perform chaos experiments against your application in Kubernetes.

If you want to try Chaos Mesh on your your laptop (Linux or macOS), you can refer the following two documents:

Prerequisites

Before deploying Chaos Mesh, make sure the following items have been installed:

  • Kubernetes version >= 1.12
  • RBAC enabled (optional)

Install Chaos Mesh

  1. curl -sSL https://mirrors.chaos-mesh.org/latest/install.sh | bash

The above command installs all the CRDs, required service account configuration, and all components. Before you start running a chaos experiment, verify if Chaos Mesh is installed correctly.

If you are using k3s or k3d, please also specify --k3s flag.

  1. curl -sSL https://mirrors.chaos-mesh.org/latest/install.sh | bash -s -- --k3s

Note:

install.sh is suitable for trying Chaos Mesh out. If you want to use Chaos Mesh in production or other serious scenarios, Helm is the recommended deployment method.

Verify your installation

Verify if Chaos Mesh is running (For the use of kubectl, you can refer to the documentation.)

  1. kubectl get pod -n chaos-testing

Expected output:

  1. NAME READY STATUS RESTARTS AGE
  2. chaos-controller-manager-6d6d95cd94-kl8gs 1/1 Running 0 3m40s
  3. chaos-daemon-5shkv 1/1 Running 0 3m40s
  4. chaos-dashboard-d998856f6-vgrjs 1/1 Running 0 3m40s

Uninstallation

You can uninstall Chaos Mesh by deleting the namespace.

  1. curl -sSL https://mirrors.chaos-mesh.org/latest/install.sh | bash -s -- --template | kubectl delete -f -

Install by helm

You also can install Chaos Mesh by helm. Before you start installing, make sure that helm v2 or helm v3 is installed correctly.

Step 1: Add Chaos Mesh repository to Helm repos

  1. helm repo add chaos-mesh https://charts.chaos-mesh.org

After adding the repository successfully, you can search available version by the following command:

  1. helm search repo chaos-mesh

Step 2: Create custom resource type

To use Chaos Mesh, you must create the related custom resource type first.

  1. curl -sSL https://mirrors.chaos-mesh.org/latest/crd.yaml | kubectl apply -f -

Step 3: Install Chaos Mesh

Depending on your environment, there are two methods of installing Chaos Mesh:

  • Install in Docker environment

    1. Create namespace chaos-testing:

      1. kubectl create ns chaos-testing
    2. Install Chaos Mesh using helm:

      • For helm 2.X
      1. helm install chaos-mesh/chaos-mesh --name=chaos-mesh --namespace=chaos-testing
      • For helm 3.X
      1. helm install chaos-mesh chaos-mesh/chaos-mesh --namespace=chaos-testing
    3. Check whether Chaos Mesh pods are installed:

      1. kubectl get pods --namespace chaos-testing -l app.kubernetes.io/instance=chaos-mesh

      Expected output:

      1. NAME READY STATUS RESTARTS AGE
      2. chaos-controller-manager-6d6d95cd94-kl8gs 1/1 Running 0 3m40s
      3. chaos-daemon-5shkv 1/1 Running 0 3m40s
      4. chaos-daemon-jpqhd 1/1 Running 0 3m40s
      5. chaos-daemon-n6mfq 1/1 Running 0 3m40s
      6. chaos-dashboard-d998856f6-vgrjs 1/1 Running 0 3m40s
  • Install in containerd environment (kind)

    1. Create namespace chaos-testing:

      1. kubectl create ns chaos-testing
    2. Install Chaos Mesh using helm:

      • for helm 2.X
      1. helm install chaos-mesh/chaos-mesh --name=chaos-mesh --namespace=chaos-testing --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/containerd/containerd.sock
      • for helm 3.X
      1. helm install chaos-mesh chaos-mesh/chaos-mesh --namespace=chaos-testing --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/containerd/containerd.sock
    3. Check whether Chaos Mesh pods are installed:

      1. kubectl get pods --namespace chaos-testing -l app.kubernetes.io/instance=chaos-mesh

      Expected output:

      1. NAME READY STATUS RESTARTS AGE
      2. chaos-controller-manager-6d6d95cd94-kl8gs 1/1 Running 0 3m40s
      3. chaos-daemon-5shkv 1/1 Running 0 3m40s
      4. chaos-daemon-jpqhd 1/1 Running 0 3m40s
      5. chaos-daemon-n6mfq 1/1 Running 0 3m40s
      6. chaos-dashboard-d998856f6-vgrjs 1/1 Running 0 3m40s
  • Install in containerd environment (k3s)

    1. Create namespace chaos-testing:

      1. kubectl create ns chaos-testing
    2. Install Chaos Mesh using helm:

      • for helm 2.X
      1. helm install chaos-mesh/chaos-mesh --name=chaos-mesh --namespace=chaos-testing --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/k3s/containerd/containerd.sock
      • for helm 3.X
      1. helm install chaos-mesh chaos-mesh/chaos-mesh --namespace=chaos-testing --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/k3s/containerd/containerd.sock
    3. Check whether Chaos Mesh pods are installed:

      1. kubectl get pods --namespace chaos-testing -l app.kubernetes.io/instance=chaos-mesh

      Expected output:

      1. NAME READY STATUS RESTARTS AGE
      2. chaos-controller-manager-6d6d95cd94-kl8gs 1/1 Running 0 3m40s
      3. chaos-daemon-5shkv 1/1 Running 0 3m40s
      4. chaos-daemon-jpqhd 1/1 Running 0 3m40s
      5. chaos-daemon-n6mfq 1/1 Running 0 3m40s
      6. chaos-dashboard-d998856f6-vgrjs 1/1 Running 0 3m40s

Note:

Currently, Chaos Dashboard is not installed by default. If you want to try it out, add --set dashboard.create=true in the helm install commands above. Refer to Configuration for more information.

After executing the above commands, you should be able to see the output indicating that all Chaos Mesh pods are up and running. Otherwise, check the current environment according to the prompt message or create an issue for help.