@@ -4,3 +4,110 @@ title = "Chaos Engineering in ShardingSphere"
44weight = 6
55chapter = true
66+++
7+
8+ ## Abstract
9+
10+ For automatically chaos engineering, ShardingSphere Operator supports a CRD named Chaos and build corresponding chaos platform CRD manifest with the attributions contained by the Chaos CRD. It supports Chaos Mesh currently, and is going to support LitmusChaos in future releases.
11+
12+ ![ ] ( ../../../img/user-manual/chaos-concepts-1.png )
13+
14+ ## Installation of Operator
15+
16+ Please refer to ShardingSphere Operator user manual's Operator Installation chapter.
17+
18+ ## CRD Introduction
19+
20+ ### Chaos
21+
22+ #### Operator Configuration
23+
24+ It need to be activated by enabling the responding FeatureGate:
25+
26+ ``` shell
27+ helm install [RELEASE_NAME] shardingsphere/apache-shardingsphere-operator-charts --set operator.featureGates.chaos=true
28+ ```
29+
30+ #### Parameters
31+
32+ ##### Required Paramaters
33+
34+ Name | Description| Type |Example
35+ ------------------ | --------------------------|------------------------------------------------------ | ----------------------------------------
36+ ` metadata.name ` | Name | string | ` foo `
37+ ` metadata.namespace ` | Namespace,default 'default '| string | | ` shardingsphere-system `
38+
39+ ##### Optional Parameters
40+
41+ Name | Description | Type | Example
42+ ------------------ | --------------------------|------------------------------------------------------ | ----------------------------------------
43+ ` spec.podChaos.selector.namespaces ` | Pod Selector: Namespace| [ ] string |
44+ ` spec.podChaos.selector.labelSelectors ` | Pod Selector:Labels| map[ string] string |
45+ ` spec.podChaos.selector.annotationSelectors ` | Pod Selector:Annotations| map[ string] string |
46+ ` spec.podChaos.selector.nodes ` | Pod Selector:Node| [ ] string |
47+ ` spec.podChaos.selector.pods ` | Pod Selector:Pod | map[ string] [ ] string|
48+ ` spec.podChaos.selector.nodeSelectors ` | Pod Selector:NodeSelector| map[ string] string |
49+ ` spec.podChaos.selector.expressionSelectors ` | Pod Selector:ExpressionSelector| [ ] metav1.LabelSelectorRequirement |
50+ ` spec.podChaos.action ` | PodChaos Type,including PodFailure、ContainerKill、PodKill、CPUStress、MemoryStress| PodChaosAction | ` PodFailure `
51+ ` spec.podChaos.params.podFailure.duration ` | PodFailure Duration| string | ` 1m `
52+ ` spec.podChaos.params.containerKill.containerNames ` | ContainerKill target container names| [ ] string | ` shardingsphere-proxy `
53+ ` spec.podChaos.params.podKill.gracePeriod ` | PodKill graceful period time | number | ` 0 `
54+ ` spec.podChaos.params.cpuStress.duration ` | CPU duration | string | ` 1m `
55+ ` spec.podChaos.params.cpuStress.cores ` | CPU cores| number | ` 2 `
56+ ` spec.podChaos.params.cpuStress.load ` | CPU load| number | ` 50 `
57+ ` spec.podChaos.params.memoryStress.duration ` | Memory duration| string | ` 1m `
58+ ` spec.podChaos.params.memoryStress.workers ` | Memory workers | numbers | ` 2 `
59+ ` spec.podChaos.params.memoryStress.consumption ` | Memory consumption| string | ` 50 `
60+ ` spec.networkChaos.source.namespaces ` | Pod Selector:namespace| [ ] string |
61+ ` spec.networkChaos.soruce.labelSelectors ` | Pod Selector: labels| map[ string] string |
62+ ` spec.networkChaos.source.annotationSelectors ` | Pod Selector: annotations| map[ string] string |
63+ ` spec.networkChaos.source.nodes ` | Pod Selector: node| [ ] string |
64+ ` spec.networkChaos.source.pods ` | Pod Selector:Pod | map[ string] [ ] string|
65+ ` spec.networkChaos.source.nodeSelectors ` | Pod Selector:NodeSlector| map[ string] string |
66+ ` spec.networkChaos.source.expressionSelectors ` | Pod Selector:ExpressionSelector| [ ] metav1.LabelSelectorRequirement |
67+ ` spec.networkChaos.target.namespaces ` | Pod Selector:Namespace| [ ] string |
68+ ` spec.networkChaos.target.labelSelectors ` | Pod Selector:Labels| map[ string] string |
69+ ` spec.networkChaos.target.annotationSelectors ` | Pod Selector:Annotations| map[ string] string |
70+ ` spec.networkChaos.target.nodes ` | Pod Selector:Node| [ ] string |
71+ ` spec.networkChaos.target.pods ` | Pod Selector:Pod | map[ string] [ ] string|
72+ ` spec.networkChaos.target.nodeSelectors ` | Pod Selector:NodeSelector| map[ string] string |
73+ ` spec.networkChaos.target.expressionSelectors ` | Pod Selector:ExpressionSelector| [ ] metav1.LabelSelectorRequirement |
74+ ` spec.networkChaos.action. ` | NetworkChaos type,including Delay,Loss,Duplication,Corruption,Partition,Bandwidth | string | ` 50 `
75+ ` spec.networkChaos.duration. ` | Duration| string | ` 1m `
76+ ` spec.networkChaos.direction. ` | Traffic direction,including to、from 和 both | string | ` both `
77+ ` spec.networkChaos.params.deplay.latency ` | Packet delay| string | ` 100 `
78+ ` spec.networkChaos.params.loss.loss ` | Packet loss | string | ` 80 `
79+ ` spec.networkChaos.params.duplicate.duplicate ` | Packet duplication | string | ` 80 `
80+ ` spec.networkChaos.params.corrupt.corrupt ` | Packet Corrupt| string | ` 80 `
81+
82+ ##### Annotations Introduction
83+
84+ While using PodChaos and NetworkChaos, some parameters need to be setup with annotations according to the difference of chaos platform, such as:
85+
86+ * Select target ComputeNode: selector.chaos-mesh.org/mode: one
87+ * Select target traffic: target-selector.chaos-mesh.org/mode: all
88+
89+ #### Example
90+
91+ Here is a example of PodChaos which injects CPU Stress:
92+
93+ ``` yaml
94+ apiVersion : shardingsphere.apache.org/v1alpha1
95+ kind : Chaos
96+ metadata :
97+ name : cpu-chaos
98+ annotations :
99+ selector.chaos-mesh.org/mode : one
100+ spec :
101+ podChaos :
102+ selector :
103+ labelSelectors :
104+ app : foo
105+ namespaces :
106+ - " default"
107+ params :
108+ cpuStress :
109+ duration : 1m
110+ cores : 2
111+ load : 50
112+ action : " CPUStress"
113+ ` ` `
0 commit comments