Skip to content

Commit 6a7fb81

Browse files
committed
docs
1 parent 0b6fc3b commit 6a7fb81

File tree

8 files changed

+119
-75
lines changed

8 files changed

+119
-75
lines changed

book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- [Test Configuration](./framework/test_configuration_overrides.md)
2121
- [Exposing Components](framework/components/state.md)
2222
- [Debugging Tests](framework/components/debug.md)
23+
- [Debugging K8s Chaos Tests](framework/chaos/debug-k8s.md)
2324
- [Components Cleanup](framework/components/cleanup.md)
2425
- [Components Caching](framework/components/caching.md)
2526
- [Components Resources](framework/components/resources.md)

book/src/framework/chaos/chaos.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ We also offer a set of blockchain-specific experiments, which typically involve
5757
- Utilizing developer APIs (e.g., Anvil)
5858

5959
Check [gas](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/examples/myproject/chaos/chaos_blockchain_evm_gas_test.go) and [reorg](https://github.com/smartcontractkit/chainlink-testing-framework/blob/main/framework/examples/myproject/chaos/chaos_blockchain_evm_reorg_test.go) examples.
60+
61+
## Debugging
62+
63+
To debug `Docker` applications you can just use `CTFv2` deployments.
64+
65+
To debug `K8s` please use our [simulator](../chaos/debug-k8s.md).
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Debugging K8s Chaos Tests
2+
3+
This deployment is used to debug various [ChaosMesh](https://chaos-mesh.org/) with [Kind](https://kind.sigs.k8s.io/)
4+
5+
Install [DevBox](https://www.jetify.com/devbox) and run your environment
6+
```
7+
devbox run up
8+
```
9+
10+
Overview the services
11+
```
12+
devbox shell
13+
k9s
14+
```
15+
Apply experiments (inside devbox shell)
16+
17+
If you running it from any other shell or using `Go` don't forget to apply `kubectl config set-context kind-cm-playground` before!
18+
```
19+
kubectl apply -f manifests/latency.yaml
20+
```
21+
Debug `ChaosMesh` using `k9s`, check daemon logs.
22+
23+
Remove the environment
24+
```
25+
devbox run down
26+
```

infra/chaosmesh-playground/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ devbox shell
1313
k9s
1414
```
1515
Apply experiments (inside devbox shell)
16+
17+
If you running it from any other shell or using `Go` don't forget to apply `kubectl config set-context kind-cm-playground` before!
1618
```
1719
kubectl apply -f manifests/latency.yaml
1820
```
19-
Debug `ChaosMesh` using k9s, check daemon logs.
21+
Debug `ChaosMesh` using `k9s`, check daemon logs.
2022

2123
Remove the environment
2224
```

infra/chaosmesh-playground/devbox.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,22 @@
1414
"up": [
1515
"kind create cluster --name cm-playground --config kind.yaml",
1616
"helm repo add chaos-mesh https://charts.chaos-mesh.org",
17+
"kubectl create ns chaos-mesh",
1718
"helm install chaos-mesh chaos-mesh/chaos-mesh -n=chaos-mesh --set chaosDaemon.runtime=containerd --set chaosDaemon.socketPath=/run/containerd/containerd.sock --version 2.7.0",
18-
"kubectl apply -f dummy.yaml"
19+
"kubectl apply -f dummy-cluster.yaml"
1920
],
2021
"down": [
2122
"kind delete cluster --name cm-playground"
2223
],
24+
"rm-chaos": [
25+
"kubectl delete networkchaos --all -A",
26+
"kubectl delete podchaos --all -A",
27+
"kubectl delete iochaos --all -A",
28+
"kubectl delete timechaos --all -A",
29+
"kubectl delete stresschaos --all -A",
30+
"kubectl delete dnschaos --all -A",
31+
"kubectl delete kernelchaos --all -A"
32+
],
2333
"context": [
2434
"kubectl config set-context"
2535
]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: http-ping-deployment
5+
spec:
6+
replicas: 4
7+
selector:
8+
matchLabels:
9+
app: http-ping-app
10+
template:
11+
metadata:
12+
labels:
13+
app: http-ping-app
14+
spec:
15+
containers:
16+
- name: http-ping-container
17+
image: python:3.9-alpine
18+
command:
19+
- sh
20+
- -c
21+
- |
22+
apk add --no-cache bind-tools
23+
python -m http.server 8080 &
24+
while true; do
25+
POD_IPS=$(nslookup http-ping-service | awk '/Address/ {print $2}' | tail -n +2)
26+
for IP in $POD_IPS; do
27+
if [ "$IP" != "$(hostname -i)" ]; then
28+
LATENCY=$(ping -c 1 $IP | grep 'time=' | awk -F'time=' '{print $2}' | awk '{print $1}')
29+
echo "$IP ->> $LATENCY ms"
30+
fi
31+
done
32+
sleep 1
33+
done
34+
ports:
35+
- containerPort: 8080
36+
37+
---
38+
apiVersion: v1
39+
kind: Service
40+
metadata:
41+
name: http-ping-service
42+
spec:
43+
selector:
44+
app: http-ping-app
45+
ports:
46+
- protocol: TCP
47+
port: 8080
48+
targetPort: 8080
49+
clusterIP: None
50+
---
51+
apiVersion: apps/v1
52+
kind: Deployment
53+
metadata:
54+
name: production-app-that-must-be-safe
55+
spec:
56+
replicas: 1
57+
selector:
58+
matchLabels:
59+
app: production-app
60+
template:
61+
metadata:
62+
labels:
63+
app: production-app
64+
spec:
65+
containers:
66+
- name: ping-container
67+
image: alpine:latest
68+
command: ["sh", "-c", "while true; do ping -c 1 google.com; sleep 1; done"]

infra/chaosmesh-playground/dummy.yaml

Lines changed: 0 additions & 70 deletions
This file was deleted.

infra/chaosmesh-playground/manifests/latency.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ metadata:
66
spec:
77
action: delay
88
mode: all
9+
duration: "30s"
910
selector:
1011
labelSelectors:
11-
app: ping-app
12+
app: http-ping-app
1213
delay:
13-
latency: "100ms"
14-
correlation: "100"
14+
latency: "50ms"
15+
correlation: "0"
1516
jitter: "0ms"

0 commit comments

Comments
 (0)