diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 503897c..4527267 100755 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -39,7 +39,7 @@ jobs: platforms: linux/amd64 push: ${{ github.event_name != 'pull_request' }} tags: | - ${{ env.GHCR_REPO }}/jmeter-base:${{ env.RELEASE_VERSION }},${{ env.GHCR_REPO }}/jmeter-base:latest + ${{ env.GHCR_REPO }}/jmeter-base:${{ env.RELEASE_VERSION }},${{ env.GHCR_REPO }}/jmeter-slave:latest if: github.event_name != 'pull_request' - name: Build master docker image diff --git a/cluster/eksctl-cluster.yaml b/cluster/eksctl-cluster.yaml new file mode 100644 index 0000000..b1dfec4 --- /dev/null +++ b/cluster/eksctl-cluster.yaml @@ -0,0 +1,22 @@ +piVersion: eksctl.io/v1alpha5 +kind: ClusterConfig + +metadata: + name: jmeter-cluster + region: us-west-1 + +nodeGroups: + - name: nodegroup-1 + instanceType: t3a.small + desiredCapacity: 3 + volumeSize: 80 + ssh: + allow: true # will use ~/.ssh/id_rsa.pub as the default ssh key + iam: + withAddonPolicies: + autoScaler: true + ebs: true + efs: true + albIngress: true + xRay: false + cloudWatch: true \ No newline at end of file diff --git a/cluster/kind-cluster.yaml b/cluster/kind-cluster.yaml new file mode 100644 index 0000000..cf0c83b --- /dev/null +++ b/cluster/kind-cluster.yaml @@ -0,0 +1,8 @@ +# three node (two workers) cluster config +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane +- role: worker +- role: worker +- role: worker \ No newline at end of file diff --git a/dashboard.sh b/dashboard.sh index 2fb0a6b..5f13dfd 100755 --- a/dashboard.sh +++ b/dashboard.sh @@ -28,14 +28,9 @@ influxdb_pod=`kubectl get po -n $tenant | grep influxdb-jmeter | awk '{print $1} kubectl exec -ti -n $tenant $influxdb_pod -- influx -execute 'CREATE DATABASE jmeter' ## Create the influxdb datasource in Grafana -echo "Creating the Influxdb data source" -grafana_pod=`kubectl get po -n $tenant | grep jmeter-grafana | awk '{print $1}'` +# echo "Creating the Influxdb data source" +# grafana_pod=`kubectl get po -n $tenant | grep jmeter-grafana | awk '{print $1}'` ## Make load test script in Jmeter master pod executable -#Get Master pod details -master_pod=`kubectl get po -n $tenant | grep jmeter-master | awk '{print $1}'` -kubectl exec -ti -n $tenant $master_pod -- cp -r /load_test /jmeter/load_test -kubectl exec -ti -n $tenant $master_pod -- chmod 755 /jmeter/load_test - # kubectl exec -ti -n $tenant $grafana_pod -c grafana -- curl 'http://admin:admin@127.0.0.1:3000/api/datasources' -X POST -H 'Content-Type: application/json;charset=UTF-8' --data-binary \ # '{"name":"jmeterdb","type":"influxdb","url":"http://jmeter-influxdb:8086","access":"proxy","isDefault":true,"database":"jmeter","user":"admin","password":"admin"}' diff --git a/grafana-dashboard/jmeter_grafana_deploy.yaml b/grafana-dashboard/jmeter_grafana_deploy.yaml index 35fb118..e0466a3 100644 --- a/grafana-dashboard/jmeter_grafana_deploy.yaml +++ b/grafana-dashboard/jmeter_grafana_deploy.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: grafana - image: grafana/grafana:6.7 + image: grafana/grafana:6.7.5 imagePullPolicy: IfNotPresent ports: - containerPort: 3000 @@ -50,7 +50,7 @@ spec: mountPath: /var/lib/grafana/dashboards/jmeter-metric.json subPath: jmeter-metric.json - name: jmreporter - image: kubernautslabs/jmeter-reporter:latest + image: izakmarais/grafana-reporter:latest imagePullPolicy: IfNotPresent ports: - containerPort: 8686 diff --git a/grafana-dashboard/jmeter_influxdb_deploy.yaml b/grafana-dashboard/jmeter_influxdb_deploy.yaml index 43858c7..4ebac45 100644 --- a/grafana-dashboard/jmeter_influxdb_deploy.yaml +++ b/grafana-dashboard/jmeter_influxdb_deploy.yaml @@ -15,7 +15,7 @@ spec: app: influxdb-jmeter spec: containers: - - image: influxdb + - image: influxdb:1.8 imagePullPolicy: IfNotPresent name: influxdb volumeMounts: diff --git a/jmeter-cluster/jmeter_master_configmap.yaml b/jmeter-cluster/jmeter_master_configmap.yaml index bb958ed..f9adb78 100644 --- a/jmeter-cluster/jmeter_master_configmap.yaml +++ b/jmeter-cluster/jmeter_master_configmap.yaml @@ -14,6 +14,7 @@ data: else mkdir csv report fi + ln -s /jmeter/apache-jmeter-* /jmeter/apache-jmeter /jmeter/apache-jmeter-*/bin/jmeter -n -t $1 -Dserver.rmi.ssl.disable=true -R `getent ahostsv4 jmeter-slaves-svc | cut -d' ' -f1 | sort -u | awk -v ORS=, '{print $1}' | sed 's/,$//'` -l /csv/Res.csv -e -o /report if [ -d "report" ]; then TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` diff --git a/jmeter-cluster/jmeter_slaves_deploy.yaml b/jmeter-cluster/jmeter_slaves_deploy.yaml index 808cc14..3a8ca56 100644 --- a/jmeter-cluster/jmeter_slaves_deploy.yaml +++ b/jmeter-cluster/jmeter_slaves_deploy.yaml @@ -5,7 +5,7 @@ metadata: labels: jmeter_mode: slave spec: - replicas: 2 + replicas: 2 selector: matchLabels: jmeter_mode: slave diff --git a/jmeter-cluster/load_test b/jmeter-cluster/load_test index 6000cf2..a4bd5f4 100755 --- a/jmeter-cluster/load_test +++ b/jmeter-cluster/load_test @@ -7,6 +7,7 @@ if [ -d "report" ]; then else mkdir csv report fi +ln -s /jmeter/apache-jmeter-* /jmeter/apache-jmeter /jmeter/apache-jmeter-*/bin/jmeter -n -t $1 -Dserver.rmi.ssl.disable=true -R `getent ahostsv4 jmeter-slaves-svc | cut -d' ' -f1 | sort -u | awk -v ORS=, '{print $1}' | sed 's/,$//'` -l /csv/Res.csv -e -o /report if [ -d "report" ]; then TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` diff --git a/jmeter_cluster_create.sh b/jmeter_cluster_create.sh index a9dcbe5..f30894b 100755 --- a/jmeter_cluster_create.sh +++ b/jmeter_cluster_create.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -#Create multiple Jmeter namespaces on an existing kuberntes cluster +#Create Jmeter cluster on existing kuberntes cluster namespace working_dir=`pwd` @@ -12,7 +12,7 @@ then exit fi -kubectl version --short +kubectl version --client echo "Enter the namespace [default]:" read tenant @@ -20,36 +20,34 @@ 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 "Using $tenant namespace has been created" echo - echo "Creating Jmeter slave nodes" -nodes=`kubectl get no | egrep -v "master|NAME" | wc -l` +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]:" +echo "Enter the number of jmeter-slaves [$((nodes - 1))]:" read num_slaves if [[ -z $num_slaves ]] then - num_slaves=$nodes + num_slaves=$((nodes - 1)) fi -echo "Creating $num_slaves Jmeter slave replicas and service" -echo +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 @@ -57,4 +55,4 @@ echo "Printout Of the $tenant Objects" echo kubectl get -n $tenant all -echo namespace = $tenant > $working_dir/jmeter-cluster/tenant_export +echo namespace = $tenant > $working_dir/tenant_export diff --git a/jmeter_stop.sh b/jmeter_stop.sh old mode 100644 new mode 100755 index 21f72d5..f63124e --- a/jmeter_stop.sh +++ b/jmeter_stop.sh @@ -3,8 +3,10 @@ set -eo pipefail +working_dir=`pwd` + #Get namesapce variable tenant=`awk '{print $NF}' $working_dir/tenant_export` master_pod=`kubectl get po -n $tenant | grep jmeter-master | awk '{print $1}'` -kubectl -n $tenant exec -ti $master_pod bash /jmeter/apache-jmeter-5.0/bin/stoptest.sh +kubectl -n $tenant exec -ti $master_pod -- /jmeter/apache-jmeter/bin/stoptest.sh