Skip to content

Commit c79105d

Browse files
authored
Adding test, readme and rbac for pod-delete experiment and minor docs update for sdk (#32)
* adding test, readme, and rbac for pod-delete experiment and docs update for SDK Signed-off-by: Oum Kale <[email protected]>
1 parent e51ebe1 commit c79105d

File tree

9 files changed

+113
-7
lines changed

9 files changed

+113
-7
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ You can contribute by raising issues, improving the documentation, contributing
3434

3535
Head over to the [Contribution guide](CONTRIBUTING.md)
3636

37-
3837
### Blogs
3938
- [Create Chaos Experiments Using the LitmusChaos Python SDK](https://dev.to/oumkale/create-chaos-experiments-using-the-litmuschaos-python-sdk-4492)
4039

bin/experiment/experiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
import experiments.generic.pod_delete.pod_delete as pod_delete
3+
import experiments.generic.pod_delete.experiment.pod_delete as pod_delete
44
import argparse
55
import logging
66
import pkg.utils.client.client as client

contribute/developer-guide/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ The *generate_experiment.py* script is a simple way to bootstrap your experiment
2323
appropriate directory (i.e., as per the chaos_category) based on an attributes file provided as input by the chart-developer. The
2424
scaffolded files consist of placeholders which can then be filled as desired.
2525

26-
### Pre-Requisites
27-
28-
- *python3* is available (`sudo apt-get install python3`)
29-
- *jinja2* & *pyYaml* python packages are available (`sudo apt-get install python3-pip`, `pip install jinja2`, `pip install pyYaml`)
30-
3126
### Steps to Generate Experiment Manifests
3227

3328
- Clone the litmus-python repository & navigate to the `contribute/developer-guide` folder
@@ -264,6 +259,11 @@ Follow the steps provided below to setup okteto & test the experiment execution.
264259
This dev container inherits the env, serviceaccount & other properties specified on the test deployment & is now suitable for
265260
running the experiment.
266261
262+
- Install dependencies
263+
- Run `curl -L https://storage.googleapis.com/kubernetes-release/release/"v1.18.0"/bin/linux/"amd64"/kubectl -o /usr/local/bin/kubectl && chmod +x /usr/local/bin/kubectl`
264+
- Run `pip3 install -r requirements.txt`
265+
- Run `python3 setup.py install`, run this command for every change in experiment code.
266+
267267
- Execute the experiment against the sample app chosen & verify the steps via logs printed on the console.
268268
269269
```
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Experiment Metadata
2+
3+
<table>
4+
<tr>
5+
<th> Name </th>
6+
<th> Description </th>
7+
<th> Documentation Link </th>
8+
</tr>
9+
<tr>
10+
<td> Pod Delete </td>
11+
<td> This experiment causes (forced/graceful) pod failure of random replicas of an application deployment. It tests deployment sanity (replica availability & uninterrupted service) and recovery workflows of the application pod </td>
12+
<td> <a href="https://litmuschaos.github.io/litmus/experiments/categories/pods/pod-delete/"> Here </a> </td>
13+
</tr>
14+
</table>
15+

experiments/generic/pod_delete/experiment/__init__.py

Whitespace-only changes.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
apiVersion: v1
3+
kind: ServiceAccount
4+
metadata:
5+
name: pod-delete-sa
6+
namespace: default
7+
labels:
8+
name: pod-delete-sa
9+
---
10+
apiVersion: rbac.authorization.k8s.io/v1
11+
kind: Role
12+
metadata:
13+
name: pod-delete-sa
14+
namespace: default
15+
labels:
16+
name: pod-delete-sa
17+
rules:
18+
- apiGroups: ["","litmuschaos.io","batch","apps"]
19+
resources: ["pods","deployments","pods/log","events","jobs","chaosengines","chaosexperiments","chaosresults"]
20+
verbs: ["create","list","get","patch","update","delete","deletecollection"]
21+
---
22+
apiVersion: rbac.authorization.k8s.io/v1
23+
kind: RoleBinding
24+
metadata:
25+
name: pod-delete-sa
26+
namespace: default
27+
labels:
28+
name: pod-delete-sa
29+
roleRef:
30+
apiGroup: rbac.authorization.k8s.io
31+
kind: Role
32+
name: pod-delete-sa
33+
subjects:
34+
- kind: ServiceAccount
35+
name: pod-delete-sa
36+
namespace: default
37+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: litmus-experiment
6+
spec:
7+
replicas: 1
8+
selector:
9+
matchLabels:
10+
app: litmus-experiment
11+
template:
12+
metadata:
13+
labels:
14+
app: litmus-experiment
15+
spec:
16+
serviceAccountName: pod-delete-sa
17+
containers:
18+
- name: gotest
19+
image: busybox
20+
command:
21+
- sleep
22+
- "3600"
23+
env:
24+
- name: APP_NAMESPACE
25+
value: ''
26+
27+
- name: APP_LABEL
28+
value: ''
29+
30+
- name: APP_KIND
31+
value: ''
32+
33+
- name: TOTAL_CHAOS_DURATION
34+
value: ''
35+
36+
- name: CHAOS_INTERVAL
37+
value: ''
38+
39+
- name: FORCE
40+
value: ''
41+
42+
- name: LIB
43+
value: 'litmus'
44+
45+
- name: CHAOS_NAMESPACE
46+
value: ''
47+
48+
- name: RAMP_TIME
49+
value: ''
50+
51+
- name: POD_NAME
52+
valueFrom:
53+
fieldRef:
54+
fieldPath: metadata.name

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def get_version_from_package() -> str:
6969
'experiments',
7070
'experiments/generic',
7171
'experiments/generic/pod_delete',
72+
'experiments/generic/pod_delete/experiment',
7273
]
7374
needs_pytest = set(['pytest', 'test']).intersection(sys.argv)
7475
package_data = {

0 commit comments

Comments
 (0)