-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[YUNIKORN-2037] Testing the throughput of YuniKorn (#724)
Add scripts for setting up KWOK based throughput tests. * kwok-setup.sh: Initiates a Kwok instance within a cluster and generates required nodes based on user specifications. * deploy-tool.sh: Creates or deletes a specified number of applications, along with the desired number of replicas for each application. Closes: #724 Signed-off-by: Wilfred Spiegelenburg <[email protected]>
- Loading branch information
Showing
2 changed files
with
197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
show_help() { | ||
cat << EOF | ||
Invalid option: -$OPTARG | ||
Usage: $0 [-d] [-i <interval>] <deployment_count> <replicas_count> | ||
Options: | ||
-d, --delete Delete the specified number of deployments. | ||
-i, --interval <interval> Set the interval between deployments in seconds. | ||
Arguments: | ||
<deployment_count> Number of deployments to create or delete (required). | ||
<replicas_count> Number of replicas for each deployment (required). | ||
EOF | ||
} | ||
|
||
deploy_deployments() { | ||
for (( i=0; i<deployment_count; i++ )); do | ||
kubectl apply -f - <<EOF | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: sleep-deployment-$i | ||
labels: | ||
app: sleep | ||
applicationId: "sleep-deployment-$i" | ||
queue: root.default | ||
spec: | ||
replicas: $replicas_count | ||
selector: | ||
matchLabels: | ||
app: nginx | ||
template: | ||
metadata: | ||
labels: | ||
app: nginx | ||
applicationId: "sleep-deployment-$i" | ||
queue: root.default | ||
spec: | ||
containers: | ||
- name: sleep300 | ||
image: "alpine:latest" | ||
tolerations: | ||
- key: "kwok.x-k8s.io/node" | ||
operator: "Exists" | ||
effect: "NoSchedule" | ||
EOF | ||
sleep "$interval" | ||
done | ||
} | ||
|
||
delete_deployments(){ | ||
for (( i=0; i<deployment_count; i++ )); do | ||
kubectl delete deploy/sleep-deployment-$i | ||
done | ||
} | ||
|
||
# Default values | ||
delete=false | ||
interval=0 | ||
|
||
# Process command-line options | ||
while getopts ":di:" opt; do | ||
case $opt in | ||
d) | ||
delete=true | ||
;; | ||
i) | ||
interval=$OPTARG | ||
;; | ||
\?) | ||
show_help | ||
exit 1 | ||
;; | ||
:) | ||
show_help | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
# Shift the processed options out of the command-line arguments | ||
shift $((OPTIND-1)) | ||
|
||
# Check if deployment count and replicas count are provided | ||
if [ $# -ne 2 ]; then | ||
show_help | ||
exit 1 | ||
fi | ||
|
||
# Assign provided values to variables | ||
deployment_count=$1 | ||
replicas_count=$2 | ||
|
||
# Check if delete flag is set | ||
if [ "$delete" = true ]; then | ||
echo "Deleting $deployment_count deployments with $replicas_count replicas each." | ||
delete_deployments | ||
else | ||
echo "Deploying $deployment_count deployments with $replicas_count replicas each." | ||
deploy_deployments | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
if [ $# -eq 0 ]; then | ||
echo "Error: Please provide the number of nodes to create." | ||
echo "Usage: $0 <number_of_nodes>" | ||
exit 1 | ||
fi | ||
|
||
KWOK_REPO=kubernetes-sigs/kwok | ||
KWOK_LATEST_RELEASE=$(curl "https://api.github.com/repos/${KWOK_REPO}/releases/latest" | jq -r '.tag_name') | ||
kubectl apply -f "https://github.com/${KWOK_REPO}/releases/download/${KWOK_LATEST_RELEASE}/kwok.yaml" | ||
kubectl apply -f "https://github.com/${KWOK_REPO}/releases/download/${KWOK_LATEST_RELEASE}/stage-fast.yaml" | ||
|
||
for (( i=0;i<$1; i++)) | ||
do | ||
kubectl apply -f - <<EOF | ||
apiVersion: v1 | ||
kind: Node | ||
metadata: | ||
annotations: | ||
node.alpha.kubernetes.io/ttl: "0" | ||
kwok.x-k8s.io/node: fake | ||
labels: | ||
beta.kubernetes.io/arch: amd64 | ||
beta.kubernetes.io/os: linux | ||
kubernetes.io/arch: amd64 | ||
kubernetes.io/hostname: kwok-node-$i | ||
kubernetes.io/os: linux | ||
kubernetes.io/role: agent | ||
node-role.kubernetes.io/agent: "" | ||
type: kwok | ||
name: kwok-node-$i | ||
spec: | ||
taints: # Avoid scheduling actual running pods to fake Node | ||
- effect: NoSchedule | ||
key: kwok.x-k8s.io/node | ||
value: fake | ||
status: | ||
allocatable: | ||
cpu: 32 | ||
memory: 256Gi | ||
pods: 110 | ||
capacity: | ||
cpu: 32 | ||
memory: 256Gi | ||
pods: 110 | ||
nodeInfo: | ||
architecture: amd64 | ||
bootID: "" | ||
containerRuntimeVersion: "" | ||
kernelVersion: "" | ||
kubeProxyVersion: fake | ||
kubeletVersion: fake | ||
machineID: "" | ||
operatingSystem: linux | ||
osImage: "" | ||
systemUUID: "" | ||
phase: Running | ||
EOF | ||
done |