Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt

Use this file to discover all available pages before exploring further.

StressChaos

StressChaos is the Schema for generating CPU and memory stress over a collection of pods.

Metadata

apiVersion
string
required
chaos-mesh.org/v1alpha1
kind
string
required
StressChaos
metadata
ObjectMeta
Standard Kubernetes metadata. Refer to the Kubernetes API documentation for fields like name, namespace, labels, and annotations.

Spec

spec
StressChaosSpec
required
Defines the behavior of a stress chaos experiment.

StressChaosSpec

stressors
*Stressors
Stressors defines 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.
stressngStressors
string
StressngStressors defines stressors in stress-ng dialect (see man stress-ng). This is an experimental feature and more powerful than Stressors.Note: Not all stressors are well tested. This may be retired in later releases. You should always use Stressors to define the stressors and use this only when you want stressors unsupported by Stressors.When both StressngStressors and Stressors are defined, StressngStressors wins.
duration
*string
Duration represents the duration of the chaos action. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m".Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
remoteCluster
string
RemoteCluster represents the remote cluster where the chaos will be deployed.

Container Selector Fields

StressChaosSpec embeds ContainerSelector which includes:
selector
PodSelectorSpec
required
Selector is used to select pods that are used to inject chaos action.
mode
SelectorMode
required
Mode defines the mode to run chaos action.Supported values:
  • one - Select one random pod
  • all - Select all pods
  • fixed - Select a fixed number of pods
  • fixed-percent - Select a fixed percentage of pods
  • random-max-percent - Select a random percentage up to max
value
string
Value is required when mode is fixed, fixed-percent, or random-max-percent.
containerNames
[]string
ContainerNames indicates list of the name of affected container. If not set, the first container will be injected.

Stressors

Stressors defines the stressors to apply.
memory
*MemoryStressor
MemoryStressor stresses virtual memory out.
cpu
*CPUStressor
CPUStressor stresses CPU out.

MemoryStressor

workers
int
required
Workers specifies N workers to apply the stressor.Maximum: 8192 (stress-ng limitation)
size
string
Size specifies N bytes consumed per vm worker, default is the total available memory.One can specify the size as % of total available memory or in units of B, KB/KiB, MB/MiB, GB/GiB, TB/TiB.Examples: "256MB", "1GB", "50%"
oomScoreAdj
int
default:"0"
OOMScoreAdj sets the oom_score_adj of the stress process. See man 5 proc to know more about this option.Range: -1000 to 1000
options
[]string
Options to extend stress-ng with additional flags.

CPUStressor

workers
int
required
Workers specifies N workers to apply the stressor.Maximum: 8192 (stress-ng limitation)
load
*int
Load specifies P percent loading per CPU worker. 0 is effectively a sleep (no load) and 100 is full loading.Range: 0 to 100
options
[]string
Options to extend stress-ng with additional flags.

StressChaosStatus

conditions
[]ChaosCondition
Conditions represents the current global condition of the chaos.
experiment
ExperimentStatus
Experiment records the last experiment state.
instances
map[string]StressInstance
Instances always specifies stressing instances.

StressInstance

uid
string
UID is the stress-ng identifier.
memoryUid
string
MemoryUID is the memStress identifier.
startTime
*metav1.Time
StartTime specifies when the stress-ng starts.
memoryStartTime
*metav1.Time
MemoryStartTime specifies when the memStress starts.

Example

CPU Stress Example

apiVersion: chaos-mesh.org/v1alpha1
kind: StressChaos
metadata:
  name: cpu-stress-example
  namespace: chaos-mesh
spec:
  mode: one
  selector:
    namespaces:
      - default
    labelSelectors:
      app: myapp
  stressors:
    cpu:
      workers: 4
      load: 80
  duration: '60s'

Memory Stress Example

apiVersion: chaos-mesh.org/v1alpha1
kind: StressChaos
metadata:
  name: memory-stress-example
  namespace: chaos-mesh
spec:
  mode: all
  selector:
    namespaces:
      - default
    labelSelectors:
      app: myapp
  stressors:
    memory:
      workers: 2
      size: '256MB'
  duration: '60s'

Combined Stress Example

apiVersion: chaos-mesh.org/v1alpha1
kind: StressChaos
metadata:
  name: combined-stress-example
  namespace: chaos-mesh
spec:
  mode: fixed
  value: '2'
  selector:
    namespaces:
      - default
  stressors:
    cpu:
      workers: 2
      load: 50
    memory:
      workers: 1
      size: '512MB'
  duration: '120s'