Skip to content

chaosblade-io/chaosblade-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Action for ChaosBlade Engineering in Kubernetes

chaosblade-action is a GitHub action that applies chaos engineering to your development workflow using CHAOSBLADE. This action privides a way to perform different chaos experiment on the Kubernetes environment.

For more details on CHAOSBLADE, refer to https://chaosblade.io/.

Pre-requisites

  • Kubernetes 1.16 or later.
  • Helm 3.*

Usage

Step 1. Prepare chaos configuration file

Prepare the configuration file (YAML) of the failures which you expect to inject into the system, for example container-cpu-fullload.yaml:

apiVersion: chaosblade.io/v1alpha1
kind: ChaosBlade
metadata:
  name: increase-container-cpu-load-by-id
spec:
  experiments:
    - scope: container
      target: cpu
      action: fullload
      desc: "increase container cpu load by id"
      matchers:
        - name: container-names
          value:
            - "nginx"
        - name: cpu-percent
          value: ["100"]
          # pod names
        - name: names
          value: ["nginx-0"]
        - name: cgroup-root
          value: ["/host-sys/fs/cgroup"]

Step 2. Encode the chaos configuration file with base64 (optional)

Obtain the base64 value of the chaos configuration file using the following command:

CBCFY_BASE64=`base64 container-cpu-fullload.yaml`

Step 3. Create the workflow

  1. Deploy the Kubernetes cluster

A Kubernetes cluster is required for the workflow. You can use the following action to deploy :

  1. Deploy Application

The application needs to be deployed to perform the chaos injection. You can see the example:nginx-statefulset

  1. Use chaosblade-action.

To create the workflow in GitHub action, use chaosblade-io/chaosblade-action in the yaml configuration file and configure the base64 value of the chaos configuration file, and set the version of CHAOSBLADE.

    - name: Run chaosblade experiment
      uses: chaosblade-io/chaosblade-action@master
      env:
        CBCFY_BASE64: ${CBCFY_BASE64}
        CHAOSBLADE_VERSION: v1.7.1

If the chaos configuration file is committed to GitHub, you can set CBCFY_FILE as the path to the file:

    - name: Run chaosblade experiment
      uses: chaosblade-io/chaosblade-action@master
      env:
        CBCFY_FILE: https://raw.githubusercontent.com/chaosblade-io/chaosblade-action/main/experiments/container-cpu-fullload/container-cpu-fullload.yaml
        CHAOSBLADE_VERSION: v1.7.1
Variables Description Default Value
CBCFY_BASE64 Configure the base64 value of the chaos configuration file. Just set one of CBCFY_BASE64 and CBCFY_FILE NULL
CBCFY_FILE The path of the chaos configuration file. Just set one of CBCFY_BASE64 and CBCFY_FILE NULL
CHAOSBLADE_VERSION The version of CHAOSBLADE LATEST

For the complete configuration file, see sample.