forked from ragul28/jmeter-k8s-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjmeter_cluster_create.sh
executable file
·58 lines (43 loc) · 1.51 KB
/
jmeter_cluster_create.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
#Create Jmeter cluster on existing kuberntes cluster namespace
working_dir=`pwd`
echo "checking if kubectl is present"
if ! hash kubectl 2>/dev/null
then
echo "'kubectl' was not found in PATH"
echo "Kindly ensure that you can acces an existing kubernetes cluster via kubectl"
exit
fi
kubectl version --client
echo "Enter the namespace [default]:"
read tenant
if [[ -z $tenant ]]
then
tenant=default
echo "Using $tenant namespace"
else
kubectl create ns $tenant
echo "Using $tenant namespace has been created"
fi
echo
echo "Creating Jmeter slave nodes"
nodes=`kubectl get no | egrep -v "master|control|NAME" | wc -l`
echo "Number of worker nodes on this cluster is " $nodes
echo "Enter the number of jmeter-slaves [$((nodes - 1))]:"
read num_slaves
if [[ -z $num_slaves ]]
then
num_slaves=$((nodes - 1))
fi
echo "Creating $num_slaves Jmeter slave replicas and service"
sed -i "s~^\([[:blank:]]*\)replicas:.*$~\1replicas: $num_slaves~" $working_dir/jmeter-cluster/jmeter_slaves_deploy.yaml
kubectl create -n $tenant -f $working_dir/jmeter-cluster/jmeter_slaves_deploy.yaml
kubectl create -n $tenant -f $working_dir/jmeter-cluster/jmeter_slaves_svc.yaml
echo
echo "Creating Jmeter Master"
kubectl create -n $tenant -f $working_dir/jmeter-cluster/jmeter_master_configmap.yaml
kubectl create -n $tenant -f $working_dir/jmeter-cluster/jmeter_master_deploy.yaml
echo "Printout Of the $tenant Objects"
echo
kubectl get -n $tenant all
echo namespace = $tenant > $working_dir/tenant_export