Chaos Mesh Workflow offers two ways of scheduling experiments: serial and parallel. You can configure and schedule multiple experiments as needed.
Chaos Mesh uses composite pattern when designing serial and parallel nodes. It can contain multiple nodes of different types and run the composite nodes in a specific mode. This also means that you can nest the serial and parallel nodes to achieve complicated scheduling. | CM工作流提供两种方式调度实验:串行和并行。你可以根据需要配置和调度多个实验:
当设计串行和并行节点时CM使用混合模式。它可以包括多个不同类型的节点混合成一个特定的模式。这也意味着你可以嵌入串行和并行节点从而达到复杂的调度 |
Serial experimentsWhen you create Another required field in serial nodes is | 串行实验: 当你在工作流中创建一个模板时,使用模板类型:串行来声明一个串行节点 另一个串行节点需要的字段是孩子,它的类型是字符串数组并且值是其他模板的名字。例如: |
apiVersion: chaos-mesh.org/v1alpha1
kind: Workflow
metadata:
name: try-workflow-serial
spec:
entry: serial-of-3-node
templates:
- name: serial-of-3-node
templateType: Serial
deadline: 240s
children:
- workflow-stress-chaos
- suspending
- workflow-network-chaos
- name: suspending
templateType: Suspend
deadline: 10s
- name: workflow-network-chaos
templateType: NetworkChaos
deadline: 20s
networkChaos:
direction: to
action: delay
mode: all
selector:
labelSelectors:
'app': 'hello-kubernetes'
delay:
latency: '90ms'
correlation: '25'
jitter: '90ms'
- name: workflow-stress-chaos
templateType: StressChaos
deadline: 20s
stressChaos:
mode: one
selector:
labelSelectors:
'app': 'hello-kubernetes'
stressors:
cpu:
workers: 1
load: 20
options: ['--cpu 1', '--timeout 600']
The above commands claims a serial node named serial-of-3-node . This means Chaos Mesh executes sequentially workflow-stress-chaos , suspending , and workflow-network-chaos . After all tasks are completed, serial nodes are marked as completed. | 上面的指令声明一个名字是serial-of-3-node的串行节点。这意味着CM顺序执行workflow-stress-chaos,suspending和workflow-network-chaos。当所有任务都完成后,串行节点标记为完成 |
When Chaos Mesh executes the serial node, tasks claimed in children are run sequentially to ensure that only one task is running at the same time. | 当CM执行串行节点,孩子中声明的任务将顺序执行以确保在一个时间只有一个任务在执行 |
The deadline field in serial nodes is optional to limit the maximum duration of the entire serial process. Once this duration is running out, the sub-nodes are stopped and the nodes that are not executed yet will not be executed. If all sub-nodes finish their work before deadline time, serial nodes are immediately marked as completed and deadline is not affected. | 串行节点中deadline这个字段是可选的。这是为了限制整个串行过程的最大持续时间。一旦这个持续时间用完,子节点将终止并且没有执行的节点将不被执行。如果所有的子节点在deadline之前完成,串行节点立即被标记完成并且deadline也不在起作用 |
Parallel experiments | 并行实验 |
When you create templates in Workflow, use templateType: Parallel to claim a parallel node. | 当在工作流中创建模板时,使用模板类型:并行来声明一个并行模板 |
Another required field in parallel nodes is children . Its type is []string and values are the names of other template . For example: | 另一个在并行节点中需要的字段是children,它的类型是string[],并且值是其他模板的名字,例如: |
apiVersion: chaos-mesh.org/v1alpha1
kind: Workflow
metadata:
name: try-workflow-parallel
spec:
entry: parallel-of-2-chaos
templates:
- name: parallel-of-2-chaos
templateType: Parallel
deadline: 240s
children:
- workflow-stress-chaos
- workflow-network-chaos
- name: workflow-network-chaos
templateType: NetworkChaos
deadline: 20s
networkChaos:
direction: to
action: delay
mode: all
selector:
labelSelectors:
'app': 'hello-kubernetes'
delay:
latency: '90ms'
correlation: '25'
jitter: '90ms'
- name: workflow-stress-chaos
templateType: StressChaos
deadline: 20s
stressChaos:
mode: one
selector:
labelSelectors:
'app': 'hello-kubernetes'
stressors:
cpu:
workers: 1
load: 20
options: ['--cpu 1', '--timeout 600']
The above commands claimed a parallel node named parallel-of-2-chaos . This means Chaos Mesh executes simultaneously workflow-stress-chaos and workflow-network-chaos . After all tasks are completed, parallel nodes are marked as completed. | 上面的指令声明一个名字叫parallel-of-2-chaos的并行节点。这意味着CM同时执行workflow-stress-chaos和workflow-network-chaos。当所有任务都完成后,并行节点被标记为完成 |
When Chaos Mesh executes parallel nodes, all tasks claimed in children are executed simultaneously. | 当CM执行并行节点时,所有在children中声明的任务同时执行 |
Similar to serial nodes, the optional field deadline is also available in parallel nodes to limit the maximum execution time of the entire parallel process. If this time is reached, the sub-nodes are stopped. If all sub-nodes finish their work before deadline time, parallel nodes are immediately marked as completed and deadline is not affected. | 类似串行节点,可选字段deadline在并行节点中也可用,用来限制整个并行过程的最大执行时间。如果时间到了,子节点将停止,如果所有子节点在deadline前完成,并行节点立即被标记为完成并且dealline将不再起作用 |
Create a workflow with serial or parallel nodes using Chaos Dashboard | 使用混沌控制台创建串行和并行节点 |
Create serial nodes | 创建串行节点 |
Chaos Dashboard creates a predefined serial node called entry . Therefore, when creating a workflow with serial nodes using Chaos Dashboard, the workflow is created under entry by default. | 混沌控制台创建叫entry的预定义串行节点。因此,当使用混沌控制台创建顺序节点的工作流时, |
Create parallel nodes
You can create a parallel node Parallel
and create sub-nodes under Parallel
.
Nest serial and parallel nodes
You can create more complex processes by nesting serial and parallel nodes together.