This is an automated email from the ASF dual-hosted git repository.

wilfreds pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new c01047fb [YUNIKORN-2037] Testing the throughput of YuniKorn (#724)
c01047fb is described below

commit c01047fb1456266f911bf3c010544ea7b2a121a6
Author: wusamzong <[email protected]>
AuthorDate: Thu Dec 7 11:46:14 2023 +1100

    [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]>
---
 deployments/kwok-perf-test/deploy-tool.sh | 121 ++++++++++++++++++++++++++++++
 deployments/kwok-perf-test/kwok-setup.sh  |  76 +++++++++++++++++++
 2 files changed, 197 insertions(+)

diff --git a/deployments/kwok-perf-test/deploy-tool.sh 
b/deployments/kwok-perf-test/deploy-tool.sh
new file mode 100755
index 00000000..64bb64fd
--- /dev/null
+++ b/deployments/kwok-perf-test/deploy-tool.sh
@@ -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
diff --git a/deployments/kwok-perf-test/kwok-setup.sh 
b/deployments/kwok-perf-test/kwok-setup.sh
new file mode 100755
index 00000000..6e528883
--- /dev/null
+++ b/deployments/kwok-perf-test/kwok-setup.sh
@@ -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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to