...

/

Setting up Chaos Toolkit in Kubernetes

Setting up Chaos Toolkit in Kubernetes

In this lesson, we set up Chaos Toolkit in Kubernetes by defining configurations using ConfigMap and creating a ServiceAccount.

Defining configuration in Kubernetes using the ConfigMap

Before we start running chaos experiments inside the Kubernetes cluster, we’ll need to set up at least two things:

  1. We’ll need experiment definitions stored somewhere in the cluster. The most common and the most logical way to define a configuration in Kubernetes is to use ConfigMap.
  2. Apart from having experiment definitions readily available, we will also need to create a ServiceAccount that will provide the necessary privileges to processes that will run the experiments.

Inspecting the definition of ConfigMap

Let’s start with the ConfigMap.

Press + to interact
cat k8s/chaos/experiments.yaml

The output, limited to the first experiment, is as follows.

...
apiVersion: v1
kind: ConfigMap
metadata:
  name: chaostoolkit-experiments
data:
  health-http.yaml: |
    version: 1.0.0
    title: What happens if we terminate an instance of the application?
    description: If an instance of the application is terminated, the applications as a whole should still be operational.
    tags:
    - k8s
    - pod
    steady-state-hypothesis:
      title: The app is healthy
      probes:
      - name: app-responds-to-requests
        type: probe
        tolerance: 200
        provider:
          type: http
          timeout: 3
          verify_tls: false
          url: http://go-demo-8.go-demo-8/demo/person
          headers:
            Host: go-demo-8.acme.com
    method:
    - type: action
      name: terminate-app-pod
 
...