Skip to content

Commit 8c419ea

Browse files
committed
feat: add scenarios for using datadog and istio to load test any js-ceramic release with simulated delays
1 parent c51f4c6 commit 8c419ea

9 files changed

Lines changed: 257 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ target/
22
*.parquet
33
.vscode
44
/analyze
5-
*.yaml
65
*.yml
76
.env*
87
/book

scenarios/.write-only.yaml.swp

12 KB
Binary file not shown.

scenarios/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Custom cluster testing
2+
3+
These scenarios require the gcloud cluster to be already set up, see below if your cluster is not set up yet or see if there is already a cluster in place with istio installed.
4+
5+
## Once your cluster is set up
6+
7+
Option 1: Run script on public tag
8+
9+
`exer_image.py [js ceramic tag]`
10+
11+
Option 2: Run the workflow manually
12+
13+
```
14+
kc config set-context --current --namespace=keramik
15+
16+
# edit the network-with-cas.yaml to specify the desired image
17+
# edit the meta tag accordingly
18+
kc apply -f network-with-cas.yaml # defines the ceramic version
19+
20+
kc config set-context --current --namespace=keramic-[your label]
21+
22+
kc edit statefulsets cas
23+
24+
####### add
25+
- name: SQS_QUEUE_URL
26+
value: ""
27+
- name: MERKLE_CAR_STORAGE_MODE
28+
value: disabled
29+
###########
30+
31+
kc label namespace keramik-[your label] istio-injection=enabled
32+
33+
kc apply -f delay-cas.yaml
34+
35+
# edit write-only.yaml to match the namespace
36+
kc apply -f write-only.yaml # runs the simulation
37+
38+
```
39+
40+
To see the results, go to https://us3.datadoghq.com/apm/home
41+
42+
Datadog -> APM-> (pick name) -> click -> service overview
43+
44+
45+
## But first, one time, set up your testing cluster
46+
47+
```
48+
gcloud config set project box-benchmarking-ipfs-testing
49+
50+
gcloud config set compute/zone us-central1-c
51+
52+
gcloud container clusters create [your cluster]
53+
54+
gcloud container node-pools create e2-standard-4 --cluster [your cluster] \
55+
--machine-type=e2-standard-4 --num-nodes=3
56+
57+
# one time get credentials into kubectl
58+
gcloud container clusters get-credentials [your cluster]
59+
60+
# if not already installed, see https://istio.io/
61+
# curl -L https://istio.io/downloadIstio | sh -
62+
63+
# install istio virtual network overlay
64+
istioctl install --set profile=demo
65+
66+
# set up namespace for datadog
67+
kubectl create ns datadog-operator
68+
helm install -n datadog-operator datadog-operator datadog/datadog-operator
69+
# add the creds to the datadog namespace
70+
kubectl create secret generic datadog-secret --from-literal=api-key=<YOUR APIP-KEY> \
71+
--from-literal=app-key=<YOUR APP-KEY> -n datadog-operator
72+
73+
kubectl apply -f datadogAgent.yaml -n datadog-operator
74+
75+
# set up keramik
76+
kubectl create ns keramik
77+
cargo run --bin crdgen | kubectl create -f -
78+
kubectl apply -k k8s/operator/
79+
80+
```

scenarios/basic.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# basic.yaml
2+
---
3+
apiVersion: "keramik.3box.io/v1alpha1"
4+
kind: Simulation
5+
metadata:
6+
name: basic
7+
namespace: keramik-db
8+
spec:
9+
scenario: ceramic-write-only
10+
users: 1000
11+
run_time: 30

scenarios/datadogAgent.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
kind: DatadogAgent
2+
apiVersion: datadoghq.com/v2alpha1
3+
metadata:
4+
name: datadog
5+
spec:
6+
global:
7+
kubelet:
8+
tlsVerify: false
9+
clusterName: gke_ipfs-ceramic-service-headless
10+
kubelet:
11+
tlsVerify: false
12+
site: us3.datadoghq.com
13+
credentials:
14+
apiSecret:
15+
secretName: datadog-secret
16+
keyName: api-key
17+
appSecret:
18+
secretName: datadog-secret
19+
keyName: app-key
20+
features:
21+
npm:
22+
enabled: true
23+
apm:
24+
enabled: true
25+
hostPortConfig:
26+
enabled: true
27+
admissionController:
28+
enabled: true
29+
mutateUnlabelled: false
30+
otlp:
31+
receiver:
32+
protocols:
33+
grpc:
34+
endpoint: 0.0.0.0:4317

scenarios/delay-cas.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
apiVersion: networking.istio.io/v1alpha3
2+
kind: VirtualService
3+
metadata:
4+
name: delay-cas
5+
spec:
6+
hosts:
7+
# verify the service name via `kubectl get svc cas`
8+
- cas.default.svc.cluster.local
9+
http:
10+
- match:
11+
- sourceLabels:
12+
# verify the label via `kubectl get pods -l app=ceramic -o=jsonpath='{.items[*].metadata.labels}'`
13+
app: ceramic
14+
fault:
15+
delay:
16+
percent: 100
17+
fixedDelay: 5s # Introducing a 5 second delay
18+
route:
19+
- destination:
20+
host: cas.default.svc.cluster.local

scenarios/exer_image.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import os
2+
import sys
3+
import re
4+
5+
6+
try:
7+
img_tag = sys.argv[1]
8+
9+
except:
10+
print("Image tag is required.")
11+
print("Choose an available tag from https://hub.docker.com/r/ceramicnetwork/js-ceramic/tags")
12+
exit(0)
13+
14+
label = 'load-with-delay-for-' + img_tag
15+
16+
# replace for valid chars only
17+
label = re.sub(r'\.', '-', label)
18+
19+
os.system('kubectl config set-context --current --namespace=keramik')
20+
21+
# set the image tag
22+
os.system("perl -pi -e 's/js-ceramic:.*$/js-ceramic:{}/g' network-with-cas.yaml".format(img_tag))
23+
24+
# apply the label to the network config
25+
os.system("perl -pi -e 's/^ name:.*$/ name: {}/g' network-with-cas.yaml".format(label))
26+
27+
# apply the label to the simulation
28+
os.system("perl -pi -e 's/^ namespace:.*$/ namespace: keramik-{}/g' write-only.yaml".format(label))
29+
30+
# create the network
31+
os.system('kubectl apply -f network-with-cas.yaml')
32+
33+
# switch to the network namespace
34+
os.system('kubectl config set-context --current --namespace=keramik-{}'.format(label))
35+
36+
do_edit = """
37+
38+
kubectl patch statefulset cas --type='json' -p='[
39+
{
40+
"op": "add",
41+
"path": "/spec/template/spec/containers/0/env/-",
42+
"value": {"name": "SQS_QUEUE_URL", "value": ""}
43+
},
44+
{
45+
"op": "add",
46+
"path": "/spec/template/spec/containers/0/env/-",
47+
"value": {"name": "MERKLE_CAR_STORAGE_MODE", "value": "disabled"}
48+
}
49+
]'
50+
51+
"""
52+
53+
os.system(do_edit)
54+
55+
os.system('kubectl label namespace keramik-{} istio-injection=enabled'.format(label))
56+
57+
os.system('kubectl apply -f delay-cas.yaml')
58+
59+
os.system('kubectl apply -f write-only.yaml')
60+
61+
print("Running simulation for " + label)
62+
63+
print("See https://us3.datadoghq.com/apm/home for results")
64+
65+
print("to clean up in 15 minutes run `kubectl delete -f network-with-cas.html`")
66+
67+
68+
69+

scenarios/network-with-cas.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# network configuration
2+
---
3+
apiVersion: "keramik.3box.io/v1alpha1"
4+
kind: Network
5+
metadata:
6+
# this is what the label will be in datadog
7+
# add the version of ceramic being tested here
8+
name: load-with-delay-for-2-37-0-rc-1
9+
spec:
10+
replicas: 1
11+
datadog:
12+
enabled: true
13+
version: "normal-cas"
14+
profilingEnabled: true
15+
cas:
16+
image: ceramicnetwork/ceramic-anchor-service:latest
17+
casResourceLimits:
18+
cpu: "2000m"
19+
memory: "1Gi"
20+
ceramic:
21+
image: ceramicnetwork/js-ceramic:2.37.0-rc.1
22+
imagePullPolicy: Always
23+
resourceLimits:
24+
cpu: "2000m"
25+
memory: "2Gi"
26+
ipfs:
27+
go:
28+
image: ceramicnetwork/go-ipfs-daemon:develop
29+
imagePullPolicy: IfNotPresent
30+
resourceLimits:
31+
cpu: "1000m"
32+
memory: "512M"
33+
#commands:
34+
# - ipfs config Routing.Type none

scenarios/write-only.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: "keramik.3box.io/v1alpha1"
2+
kind: Simulation
3+
metadata:
4+
name: ceramic-write-only-simulation
5+
namespace: keramik-load-with-delay-for-2-37-0-rc-1
6+
spec:
7+
scenario: ceramic-write-only
8+
users: 3000
9+
run_time: 15

0 commit comments

Comments
 (0)