StressChaos Experiment
This document helps you create StressChaos experiments.
StressChaos can generate plenty of stresses over a collection of pods. The stressors is injected into the target pods via the chaos-daemon
internally.
Configuration
A StressChaos shares common configurations like other chaos, such as how to select pods, how to specify periodic chaos. You can refer to other docs for details. It defines stressors in either of the following two ways:
stressors
Stressors
defines a plenty of stressors supported to stress system components out. You can use one or more of them to make up various kinds of stresses. At least one of the stressors should be specified. The following is supported stressors for now:memory
A
memory
stressor will continuously stress virtual memory out.Option Type Required Description workers
Integer True Specifies concurrent stressing instance. cpu
A
cpu
stressor will continuously stress CPU out.Option Type Required Description workers
Integer True Specifies concurrent stressing instance. Actually it specifies how many CPUs to stress when it’s less than available CPUs. load
Integer False Specifies percent loading per worker. 0 is effectively a sleep (no load) and 100 is full loading.
stressngStressors
StressngStressors
defines a plenty of stressors just likeStressors
except that it’s an experimental feature and more powerful.You can define stressors in
stress-ng
(see alsoman stress-ng
) dialect.Note:
However, not all of the supported stressors are well tested. It might be retired in later releases. Therefore, it is recommended to use
Stressors
to define the stressors and use this only when you want more stressors unsupported byStressors
.When both
StressngStressors
andStressors
are defined,StressngStressors
wins.
Usage
Below is an example YAML file of StressChaos which is set to burn 1 CPU for 30 seconds in every 2 minutes:
apiVersion: chaos-mesh.org/v1alpha1
kind: StressChaos
metadata:
name: burn-cpu
namespace: chaos-testing
spec:
mode: one
selector:
namespaces:
- tidb-cluster-demo
stressors:
cpu:
workers: 1
duration: '30s'
scheduler:
cron: '@every 2m'
Create a namespace for your application. For example,
tidb-cluster-demo
:kubectl create ns tidb-cluster-demo
Create your pods in the target namespace:
kubectl apply -f *your-pods.yaml*
Inject a StressChaos:
kubectl apply -f *your-stress-chaos.yaml*
Then, your pod’s CPU will burn for 30 seconds.