【Chaos Mesh官方文档】Simulate Faults on Physical Machines

总目录

  1. 读我
  2. 关于CM
    CM介绍:这篇文档介绍ChaosMesh的概念,用例,核心优势和架构
    基本功能:这篇文档描述了CM的基本特性,包括错误注入,混沌工作流,可视化操作和安全保证
  3. 安装&部署
    快速开始:这篇文章介绍如何在测试或本地环境开始CM
    使用Helm安装:这篇文章讲如何在生产环境安装CM
    离线安装:这份文档讲如何离线安装CM
    卸载CM:这篇文档讲如何卸载CM,包括使用helm卸载或手工卸载
  4. 管理用户许可:这篇文章讲如何在CM中管理用户许可,包括创建不同角色的用户账号,绑定许可,管理令牌,启用或停用许可授权
  5. 配置混沌实验命名空间:这个章节带你在指定的命名空间配置混沌实验,从而避免其他没有指定的命名空间里注入错误
  6. 运行一个混沌实验
    定义混沌实验范围:这篇文档讲如何定义混沌实验的范围从而精确的控制混沌错误爆炸范围
    定义调度规则:这篇文档讲如何使用CM创建调度任务,从而在一个固定时间创建混沌实验
    运行混沌实验:这篇文档讲如何在CM中创建,运行,观察,暂停,更新和删除混沌实验
    查看混沌实验结果:这篇文档讲如何使用CM查看混沌实验的运行状态和结果
  7. 编排多个混沌实验
    创建CM工作流:
    并行&串行实验
    向工作流发送HTTP请求:类似K8s Job,CM工作流对任何任务都支持任务节点,为了让用户体验更方便,CM在web界面提供一个基于Task的模板创建HTTP请求
    检查工作流状态:
  8. 混沌实验类型
    • Kubernetes
      • Pod错误:这篇文档讲如何使用CM将错误注入pod中从而模拟pod或容器错误
      • 网络错误:这篇文章讲如何使用NetworkChaos模拟网络错误
      • 压力场景:CM提供StressChaos在容器内模拟压力场景,这篇文章将如何创建StressChaos实验和准备相应配置文件
      • 文件IO错误:这篇文档讲如何使用CM创建IO混沌
      • DNS错误:这篇文档讲如何在CM中创建DNS混沌实验从而模拟DNS错误
      • 时间错误:CM提供TimeChaos实验类型,你可以使用这个类型模拟时间偏移场景,这篇文章讲如何创建一个TimeChaos实验及相关配置文件
      • JVM应用错误:
      • Linux内核错误:这篇文章讲如何使用KernelChaos模拟内核错误,这个特性使用BPF在内核相关路径注入IO相关,内存相关错误
      • HTTP错误:这篇文章讲如何通过CM创建HTTPChaos来模拟HTTP错误
    • 物理节点
      • Chaosd介绍:Chaosd是CM提供的混沌引擎测试工具
      • 物理机错误:这篇文档讲如何通过CM制造物理机混沌来在物理机或虚拟机上模拟网络,硬盘,时间,jvm等错误
      • 进程错误:这篇文章讲如何使用chaosd模拟进程错误,这个错误使用go语言提供的杀死指令来模拟进程被杀死或停止的场景
      • 网络错误:这篇文章讲如何使用chaosd模拟网络错误,这个模拟可以使用 iptables, ipsets, tc等通过修改路由和流量控制来完成
      • 宿主机错误:这篇文章讲如何使用chaosd模拟宿主机关闭的错误
      • 压力场景:这篇文章讲如何使用chaosd模拟压力场景,这个特性使用stress-ng在宿主机上产生CPU和内存压力
      • 硬盘错误:这篇文章讲如何通过Chaosd来模拟硬盘错误,这个特性帮助你模拟硬盘读写负载(通过dd)和硬盘填充(通过dd或者fallocate)
      • JVM应用错误:chaosd使用Byteman模拟jvm错误
      • 时间错误:这篇文章描述如何使用chaosd模拟时间偏移的场景.你可以通过命令行模式或者服务模式创建该场景
      • 查找和恢复Chaosd实验:你可以通过条件来查找实验并通过Chaosd使用UID来恢复实验.这篇文档讲如何通过chaosd查找和恢复实验并提供相关例子

正文

原文翻译
This document describes how to create PhysicalMachineChaos (physical machine chaos) experiments in Chaos Mesh to simulate the faults of network, disk, pressure, JVM, time, and others in physical or virtual machines.这篇文档讲如何通过CM制造物理机混沌来在物理机或虚拟机上模拟网络,硬盘,时间,jvm等错误

Introduction to PhysicalMachineChaos​

物理机混沌介绍

You can use PhysicalMachineChaos to simulate the faults of network, disk, pressure, JVM, time, and others in physical or virtual machines.你可以使用物理机混沌来在物理机或虚拟机上模拟网络,磁盘,压力,jvm,时间和其他类型错误

Deploy Chaosd server​​

部署Chaosd服务器

Before creating PhysicalMachineChaos experiments using Chaos Mesh, you need to deploy Chaosd in service mode to all physical or virtual machines that are going to be injected with faults. For the deployment method of Chaosd, refer to Download and deploy Chaosd.
After the deployment is complete, run the following command to start Chaosd in service mode:
在使用CM创建物理机混沌实验前,需要在所有准备注入错误的物理机或虚拟机上以服务模式部署Chaosd,部署Chaosd的方法参见这篇文章
部署完成后,运行下面指令以服务模式启动Chaosd
chaosd server --port 31767
NOTE
When using Chaos Mesh v2.1.0, you need to deploy Chaosd v1.1.0.
注意
当使用CMv2.1.0时,你需要部署Chaosd V1.1.0

Create experiments using Chaos Dashboard​​​

使用混沌看板创建实验

Open Chaos Dashboard, and click NEW EXPERIMENT on the page to create a new experiment:打开混沌看板,点击新实验来创建一个新实验
Click PHYSIC in Experiment Type and choose a specific type of the experiment, such as NETWORK ATTACK. Then, choose a specific behavior and fill out the corresponding configurations:实验类型中点击物理并选择一个特定实验类型,例如网络攻击,然后选择特定行为和填写对应配置
Fill out the experiment information to specify the range and the planned duration of the experiment:填写实验信息来制定范围和实验计划时间
Submit the experiment.提交实验

Create experiments using an YAML file​​​​

使用YAML文件创建实验

Write the experimental configurations to the "physicalmachine.yaml" file. For example:填写实验配置到physicalmachine.yaml文件,例如
apiVersion: chaos-mesh.org/v1alpha1
kind: PhysicalMachineChaos
metadata:
  name: physical-network-delay
  namespace: chaos-testing
spec:
  action: network-delay
  address:
   - 172.16.112.130:31767
  network-delay:
   device: ens33
   ip-address: 140.82.112.3
   latency: 1000ms
  duration: '10m'
The experimental configurations above send HTTP requests to Chaosd service in the specified physical machines or virtual machines to trigger network latency experiments.上面的实验配置通过HTTP请求发现指定的物理机或虚拟机的Chaosd服务来触发网络延时实验
2Create the experiment using kubectl. The command is as follows:2使用kubectl创建实验,命令如下:
kubectl apply -f physicalmachine.yaml

Configuration description​ 配置项描述

Configuration item/配置项Type类型Description描述Default value/默认值Required是否必填Example/示例
actionstring字符串Defines the actions of physical machines faults, optional values are as follows: “stress-cpu”, “stress-mem”, “disk-read-payload”, “disk-write-payload”, “disk-fill”, “network-corrupt”, “network-duplicate”, “network-loss”, “network-delay”, “network-partition”, “network-dns”, “process”, “jvm-exception”, “jvm-gc”, “jvm-latency”, “jvm-return”, “jvm-stress”, “jvm-rule-data”, “clock”定义物理机错误的操作,可选项如下:“stress-cpu”, “stress-mem”, “disk-read-payload”, “disk-write-payload”, “disk-fill”, “network-corrupt”, “network-duplicate”, “network-loss”, “network-delay”, “network-partition”, “network-dns”, “process”, “jvm-exception”, “jvm-gc”, “jvm-latency”, “jvm-return”, “jvm-stress”, “jvm-rule-data”, “clock”NoneYes“stress-cpu”
addressstring array字符串 数组Selects the address of Chaosd service to inject faults选择注入失败的Chaosd服务的地址[]Yes[“192.168.0.10:31767”]
durationstring字符串Specifies the duration of experiments指明实验持续时间NoneYes30s
原文翻译
Each fault action has its own specific configurations. The following section introduces various fault types and their corresponding configuration methods.每种错误类型有它自己配置项,下面一节介绍了各种错误类型和他们对应配置方法
CPU stress​CPU压力
To simulate a CPU stress scenario, you need to set the action to “stress-cpu”. For the corresponding configurations, refer to Parameters of simulating CPU stress.为了模拟CPU压力场景,你需要将行为设置为"stress-cpu",参见这里得到对应配置项
Memory stress内存压力
To simulate a memory stress scenario, you need to set the action to “stress-mem”. For the corresponding configurations, refer to Parameters of simulating memory stress.为了模拟内存压力场景,你需要将行为设置为stress-mem,参见这里得到对应配置项
Disk read load​
To simulate a disk read load scenario, you need to set the action to “disk-read-payload”. For the corresponding configurations, refer to Parameters of simulating disk read load.
磁盘读负载
为了模拟磁盘读负载场景,你需要将行为设置为disk-read-payload参见这里得到对应配置项
Disk write load​
To simulate a disk write load scenario, you need to set the action to “disk-write-payload”. For the corresponding configurations, refer to Parameters of simulating disk write load.
磁盘写负载
为了模拟磁盘写负载场景,你需要将行为设置为disk-write-payload参见这里得到对应配置项
Disk fill
To simulate a disk fill scenario, you need to set the action to “disk-fill”. For the corresponding configurations, refer to Parameters of simulating disk fill.
磁盘填充
为了模拟磁盘填充场景,你需要将行为设置为disk-fill参见这里得到对应配置项
Network corruption​
To simulate a network corruption scenario, you need to set the action to “network-corrupt”. For the corresponding configurations, refer to Parameters of simulating network corruption.
网络损坏
为了模拟网络损坏场景,你需要将行为设置为network-corrupt,参见这里得到对应配置项
Network latency​​
To simulate a network latency scenario, you need to set the action to “network-delay”. For the corresponding configurations, refer to Parameters of simulating network latency.
网络延迟
为了模拟网络延迟场景,你需要将行为设置为network-delay,参见这里得到对应配置项
Network duplication​​
To simulate a network duplication scenario, you need to set the action to “network-duplicate”. For the corresponding configurations, refer to Parameters of simulating network duplication.
网络重复
为了模拟网络重复场景,你需要将行为设置为network-duplicate,参见这里得到对应配置项
Network loss​​
To simulate a network loss scenario, you need to set the action to “network-loss”. For the corresponding configurations, refer to Parameters of simulating network loss.
网络丢失
为了模拟网络丢失场景,你需要将行为设置为network-loss,参见这里得到对应配置项
Network partition​​
To simulate a network partition scenario, you need to set the action to “network-partition”. For the corresponding configurations, refer to Parameters of simulating network partition.
网络分区
为了模拟网络分区场景,你需要将行为设置为network-partition,参见这里得到对应配置项
DNS fault​​
To simulate a DNS fault scenario, you need to set the action to “network-dns”. For the corresponding configurations, refer to Parameters of simulating DNS fault.
DNS错误
为了模拟DNS错误场景,你需要将行为设置为network-dns,参见这里得到对应配置项
Process fault​​
To simulate a process fault scenario, you need to set the action to “process”. For the corresponding configurations, refer to Parameters of simulating process fault.
进程错误
为了模拟进程错误场景,你需要将行为设置为process,参见这里得到对应配置项
Throw custom exceptions for JVM applications​​
To simulate a scenario that JVM applications throw custom exceptions, you need to set the action to “jvm-exception”. For the corresponding configurations, refer to Parameters for throwing custom exceptions.
JVM应用抛出自定义异常
为了模拟VM应用抛出自定义异常场景,你需要将行为设置为jvm-exception,参见这里得到对应配置项
Increase method latency for JVM applications​​
To simulate a scenario that JVM applications increase method latency, you need to set the action to “jvm-latency”. For the corresponding configurations, refer to Parameters for increasing method latency.
增加JVM应用方法延迟
为了模拟增加JVM应用方法延迟场景,你需要将行为设置为jvm-latency,参见这里得到对应配置项
Modify return values of methods for JVM applications​​
To simulate a scenario that JVM applications modify return values of methods, you need to set the action to “jvm-return”. For the corresponding configurations, refer to Parameters for modifying return values of a method.
修改JVM应用方法返回值
为了模拟修改JVM应用方法返回值场景,你需要将行为设置为jvm-return,参见这里得到对应配置项
Trigger garbage collection for JVM applications​​
To simulate a scenario that JVM applications trigger garbage collection, you need to set the action to “jvm-gc”. For the corresponding configurations, refer to Parameters for triggering garbage collection.
触发JVM应用垃圾回收
为了模拟JVM应用垃圾回收场景,你需要将行为设置为jvm-gc,参见这里得到对应配置项
Trigger faults using Byteman configuration files for JVM applications​​
To simulate a scenario that JVM applications trigger faults using Byteman configuration files, you need to set the action to “jvm-rule-data”. For the corresponding configurations, refer to Parameters for triggering faults by setting Byteman configuration files.
使用Byteman配置文件触发JVM应用错误
为了用Byteman配置文件模拟JVM应用错误场景,你需要将行为设置为jvm-rule-data,参见这里得到对应配置项
Time offset​​
To simulate a time offset scenario, you need to set the action to “clock”. For the corresponding configurations, refer to Parameters of simulating time offset.
时间偏移
为了模拟时间偏移场景,你需要将行为设置为clock,参见这里得到对应配置项
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值