【Chaos Mesh官方文档】Simulate Stress Scenarios

StressChaos Introduction​

Chaos Mesh provides StressChaos experiments to simulate stress scenarios inside containers. This document describes how to create StressChaos experiments and how to prepare the corresponding configuration file.

You can create experiments using either Chaos Dashboard or the YAML configuration files.
Create experiments using Chaos Dashboard​

Open Chaos Dashboard, and click NEW EXPERIMENT on the page to create a new experiment:

Create Experiment

In the Choose a Target area, choose STRESS TEST and fill out the experiment information. For specific configuration fields, refer to the description in [Configuration Description](#fields description).

StressChaos Experiment

Fill out the experiment information, and specify the experiment scope and the scheduled experiment duration:

Experiment Information

Submit the experiment information.

Create experiments using the YAML file​

Write the experiment configuration to the YAML configuration file. In the following example, the memory-stress.yaml file is used.

apiVersion: chaos-mesh.org/v1alpha1
kind: StressChaos
metadata:
  name: memory-stress-example
  namespace: chaos-testing
spec:
  mode: one
  selector:
    labelSelectors:
      'app': 'app1'
  stressors:
    memory:
      workers: 4
      size: '256MB'

This experiment configuration will create a process in the selected container, continuously allocate and read and write in memory, occupying up to 256MB of memory.

After the configuration file is prepared, use kubectl to create an experiment:

kubectl apply -f memory-stress.yaml

Field description​

The fields in the YAML configuration file are described in the following table:
Parameter Type Description Default value Required Example
duration string Specifies the duration of the experiment. None Yes 30s
stressors Stressors Specifies the stress of CPU or memory None No
stressngStressors string Specifies the stres-ng parameter to reach richer stress injection None No --clone 2
mode string Specifies the mode of the experiment. The mode options include one (selecting a random Pod), all (selecting all eligible Pods), fixed (selecting a specified number of eligible Pods), fixed-percent (selecting a specified percentage of Pods from the eligible Pods), and random-max-percent (selecting the maximum percentage of Pods from the eligible Pods). None Yes one
value string Provides a parameter for the mode configuration, depending on mode.For example, when mode is set to fixed-percent, value specifies the percentage of Pods. None No 1
containerNames []string Specifies the name of the container into which the fault is injected. None No [“nginx”]
selector struct Specifies the target Pod. For details, refer to Define the Scope of Chaos Experiments. None Yes
Stressors​
Parameter Type Description Default value Required Example
memory MemoryStressor Specifies the memory stress None No
cpu CPUStressor Specifies the CPU stress None No
MemoryStressor​
Parameter Type Description Default value Required Example
workers int Specifies the number of threads that apply memory stress Yes 1
size string Specifies the memory size to be occupied or a percentage of the total memory size. The final sum of the occupied memory size is size. No 256MB / 25%
CPUStressor​
Parameter Type Description Default value Required Example
workers int Specifies the number of threads that apply CPU stress Yes 1
load int Specifies the percentage of CPU occupied. 0 means that no additional CPU is added, and 100 refers to full load. The final sum of CPU load is workers * load. No 50

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值