Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple scale script #490

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions doc/developer_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
Run `go mod` with:

```
go mod tidy
go mod vendor
go mod verify
```

## Running with CNI's `docker-run.sh`
Expand Down Expand Up @@ -66,3 +68,14 @@ spec:
EOF
```

## Using the scale script `/scripts/scale-test.sh`

1. This will not work unless you have a running cluster
A simple way to spin a cluster to use this with is by using
```
./hack/e2e-setup-kind-cluster -n 3
```
2. This script leverages the `whereaboutsScaleNAD` and `scaleTestDeployment` yamls in /yamls
3. To modify the number of pods spun by the script, change the replicas value in the `scaleTestDeployment` yaml


26 changes: 26 additions & 0 deletions script/scale-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -eo pipefail

#An easy way to run this is to create a kind cluster using ./hack/e2e-setup-kind-cluster

HERE="$(dirname "$(readlink --canonicalize ${BASH_SOURCE[0]})")"
ROOT="$(readlink --canonicalize "$HERE/..")"
WHEREABOUTSNAD="$ROOT/yamls/whereaboutsScaleNAD.yaml"
SCALEDEPLOYMENT="$ROOT/yamls/scaleTestDeployment.yaml"

#create the whereabouts nad
oc apply -f "$WHEREABOUTSNAD"
#start a timer to record how long the pods take to spin up
start=$SECONDS
#create the deployment (change the replicas feild in the scale-deployment yaml if you want to test a different number of pods)
oc apply -f "$SCALEDEPLOYMENT"
kubectl rollout status deploy/scale-deployment
#wait for all pods to be deployed

#Log the amount of time it took the pods to create
createTime=$(( SECONDS - start ))
echo Pod creation duration:"$createTime"

#delete the deployment and track pod deletion timing
oc delete deploy/scale-deployment

25 changes: 25 additions & 0 deletions yamls/scaleTestDeployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: scale-deployment
labels:
app: scale-deployment
spec:
replicas: 10 #use this to modify the number of pods spun up by the scale-test script
selector:
matchLabels:
app: scale-pod
template:
metadata:
annotations:
k8s.v1.cni.cncf.io/networks: whereabouts-scale
labels:
app: scale-pod
spec:
containers:
- name: scale
image: nicolaka/netshoot
command:
- sleep
- "3600"
imagePullPolicy: IfNotPresent
16 changes: 16 additions & 0 deletions yamls/whereaboutsScaleNAD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: "k8s.cni.cncf.io/v1"
kind: NetworkAttachmentDefinition
metadata:
name: whereabouts-scale
spec:
config: '{
"cniVersion": "0.3.0",
"name": "whereabouts-scale",
"type": "macvlan",
"master": "eth0",
"mode": "bridge",
"ipam": {
"type": "whereabouts",
"range": "192.168.2.225/24"
}
}'
Loading