From 34ec97260d123661e370b79d2e105b5d00599c4e Mon Sep 17 00:00:00 2001 From: mookkiah Date: Fri, 5 Feb 2021 17:38:26 -0500 Subject: [PATCH] using JMeter 5.4, Helm3, allowing additional volume, etc., --- Chart.yaml | 12 -------- Dockerfile | 15 +++------ README.md | 26 +++++++++++----- k8s/Chart.yaml | 8 +++-- k8s/README.md | 7 ++++- k8s/templates/NOTES.txt | 4 +-- k8s/templates/jmeter-master-deployment.yaml | 24 ++++++++++----- k8s/templates/jmeter-server-deployment.yaml | 17 ++++++++--- k8s/templates/jmeter-server-service.yaml | 5 +-- k8s/values.yaml | 4 +++ scripts/docker-entrypoint.sh | 2 +- templates/NOTES.txt | 16 ---------- templates/_helpers.tpl | 32 ------------------- templates/jmeter-master-deployment.yaml | 34 --------------------- templates/jmeter-server-deployment.yaml | 34 --------------------- templates/jmeter-server-service.yaml | 23 -------------- 16 files changed, 75 insertions(+), 188 deletions(-) delete mode 100644 Chart.yaml delete mode 100644 templates/NOTES.txt delete mode 100644 templates/_helpers.tpl delete mode 100644 templates/jmeter-master-deployment.yaml delete mode 100644 templates/jmeter-server-deployment.yaml delete mode 100644 templates/jmeter-server-service.yaml diff --git a/Chart.yaml b/Chart.yaml deleted file mode 100644 index 54e230b..0000000 --- a/Chart.yaml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: v1 -appVersion: "3.3" -description: A Distributed JMeter Helm chart -name: distributed-jmeter -version: 1.0.0 -home: http://jmeter.apache.org/ -icon: http://jmeter.apache.org/images/logo.svg -sources: - - https://github.com/pedrocesar-ti/distributed-jmeter-docker -maintainers: - - name: pedrocesar-ti - email: pedrocesar.ti@gmail.com diff --git a/Dockerfile b/Dockerfile index 278ee54..4bf0e6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM openjdk:8-jre-slim ARG JMETER_VERSION -ENV JMETER_VERSION ${JMETER_VERSION:-3.3} +ENV JMETER_VERSION ${JMETER_VERSION:-5.4} ENV JMETER_HOME /jmeter/apache-jmeter-$JMETER_VERSION/ ENV PATH $JMETER_HOME/bin:$PATH @@ -16,20 +16,15 @@ WORKDIR /jmeter RUN wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz && \ tar -xzf apache-jmeter-$JMETER_VERSION.tgz && \ - rm apache-jmeter-$JMETER_VERSION.tgz && \ - mkdir /jmeter-plugins && \ - cd /jmeter-plugins/ && \ - wget https://jmeter-plugins.org/downloads/file/JMeterPlugins-ExtrasLibs-1.4.0.zip && \ - unzip -o JMeterPlugins-ExtrasLibs-1.4.0.zip -d /jmeter/apache-jmeter-$JMETER_VERSION + rm apache-jmeter-$JMETER_VERSION.tgz WORKDIR $JMETER_HOME - + COPY config/user.properties bin/user.properties -COPY scripts/install_plugin-manager.sh . + COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh -RUN chmod +x install_plugin-manager.sh /docker-entrypoint.sh -RUN ./install_plugin-manager.sh +RUN chmod +x /docker-entrypoint.sh EXPOSE 6000 1099 50000 ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/README.md b/README.md index e19df2d..06d8f7a 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,11 @@ # Distributed JMeter - Docker -Apache Jmeter™ is an open source tool that helps creating and running load test plans. And this Docker image was created to help you running different versions of JMeter in a Docker container, also helping you running in a distributed fashion (master -> server approach). +Apache Jmeter™ is an open source tool that helps creating and running load test plans. And this Docker image was created to help you running different versions of JMeter in a Docker container, also helping you running in a distributed fashion (master -> server approach). ## Supported tags -The [Dockerfile](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob/master/Dockerfile) here is managed and built with arguments what helps building and pushing our JMeter images for all versions of JMeter available. If you want more information, have a look on the [Makefile](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob/master/Makefile). +The [Dockerfile](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob/master/Dockerfile) here is managed and built with arguments what helps building and pushing our JMeter images for all versions of JMeter available. If you want more information, have a look on the [Makefile](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob/master/Makefile). -- 3.3, latest - 2.6 - 2.7 - 2.8 @@ -18,40 +17,53 @@ The [Dockerfile](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob - 3.0 - 3.1 - 3.2 +- 3.3 - 4.0 -- 5.0 +- 5.4, latest ## Running Master or Server + ### Master + ```sh docker run -p 60000:60000 -v : -d pedrocesarti/jmeter-docker:latest master ``` ### Server + ```sh -docker run -p 1099:1099 -p 50000:50000 -d pedrocesarti/jmeter-docker:latest server +docker run -p 1099:1099 -p 50000:50000 -v /Users/mookkiahm/git/github/distributed-jmeter-docker/rmi_keystore.jks:/jmeter/apache-jmeter-5.0/bin/rmi_keystore.jks -d pedrocesarti/jmeter-docker:latest server ``` +Example to supply JMeter and JVM arguments + +```sh +docker run -p 1099:1099 -p 50000:50000 -d -v /Users/mookkiahm/git/github/distributed-jmeter-docker/rmi_keystore.jks:/jmeter/apache-jmeter-5.4/rmi_keystore.jks pedrocesarti/jmeter-docker:5.4 server +docker run -p 1099:1099 -p 50000:50000 -d -e JMETER_SERVER_ADDITIONA_ARGS="-Jserver.rmi.ssl.disable=true" -e JVM_ARGS="-Xms300M" pedrocesarti/jmeter-docker:5.4 server +``` ## Running Master and Server (Docker Compose) + You can also create a whole stack with master and servers to run a distributed JMeter tests locally or in a Docker Swarm Cluster. Check out this [docker-compose.yml](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob/master/local/docker-compose.yml) to see one example of this infra running locally. This example is going to create a master and a server container running locally, and you can also scale up and down the number servers instancesrunning. + ```sh docker-compose up -d docker-compose scale server=5 ``` ## Volumes + Another good point to mention here is that we suggest that you use volumes to share your test plans with the master container and once you have your test plans on your master container, you only going to need exec: ```sh jmeter -n -t script.jmx -R server1,server2,… -``` +``` You can also use this [docker-compose](https://github.com/pedrocesar-ti/distributed-jmeter-docker/blob/master/local/docker-compose.yml) to deploy in a Docker Swarm cluster defining better techniques to scale the number of replicas you want for each service and add all power of the internal discovery service. ## K8s -For the Kubernetes support, also have a look at the official helm/[chart](https://github.com/helm/charts/tree/master/stable/distributed-jmeter) repository. +For the Kubernetes support, also have a look at the official helm/[chart](https://github.com/helm/charts/tree/master/stable/distributed-jmeter) repository. Enjoy! :) diff --git a/k8s/Chart.yaml b/k8s/Chart.yaml index 0107466..75a36b2 100644 --- a/k8s/Chart.yaml +++ b/k8s/Chart.yaml @@ -1,8 +1,8 @@ -apiVersion: v1 -appVersion: "1.0" +apiVersion: v2 +appVersion: "5.4" description: A Distributed JMeter Helm chart name: distributed-jmeter -version: 0.1.0 +version: 2.0.0 home: http://jmeter.apache.org/ icon: http://jmeter.apache.org/images/logo.svg sources: @@ -10,3 +10,5 @@ sources: maintainers: - name: pedrocesar-ti email: pedrocesar.ti@gmail.com + - name: mookkiah + email: mahendran.mookkiah@gmail.com diff --git a/k8s/README.md b/k8s/README.md index 7ed8c35..d76bfda 100644 --- a/k8s/README.md +++ b/k8s/README.md @@ -5,21 +5,26 @@ Based on the work done [here](https://github.com/pedrocesar-ti/distributed-jmete Apache Jmeter™ is an open source tool that helps creating and running load test plans. This helm/chart was created to help you running different versions of JMeter in a distributed fashion (master -> server architecture), for more info. ## Chart Details: + This chart will do the following: + - Deploy a JMeter master (by default 1) that is responsible to store the test plans and test results after running on the servers. - Deploy a JMeter server service (by default 3 replicas) that are responsible to run the actual test and send back the results to the master. - ## Installing the Chart: + To install the chart with the release name jmeter: + ``` $ helm install --name distributed-jmeter stable/distributed-jmeter ``` ## Deploying different versions of JMeter + The default [image](https://hub.docker.com/r/pedrocesarti/jmeter-docker/) allows you to run JMeter in all versions available. To change the version running on the helm you only need: + ``` $ helm install --name distributed-jmeter --set master.image.tag=4.0 --set server.image.tag=4.0 stable/distributed-jmeter ``` diff --git a/k8s/templates/NOTES.txt b/k8s/templates/NOTES.txt index 8603443..7be1090 100644 --- a/k8s/templates/NOTES.txt +++ b/k8s/templates/NOTES.txt @@ -3,7 +3,7 @@ JMeter is now starting. To get get a shell session on the master you only need to run: -$ export MASTER_NAME=$(kubectl get pods -l role=master -o jsonpath='{.items[*].metadata.name}') +$ export MASTER_NAME=$(kubectl get pods -l app.kubernetes.io/component=master -o jsonpath='{.items[*].metadata.name}') $ kubectl exec -it $MASTER_NAME -- /bin/bash @@ -12,5 +12,5 @@ $ kubectl cp sample.jmx $MASTER_NAME:/jmeter To run your test in all servers you need first a list of all servers IPs (comma-separated) and then you can run your test: -$ export SERVER_IPS=$(kubectl get pods -lrole=server -o jsonpath='{.items[*].status.podIP}' | tr ' ' ',') +$ export SERVER_IPS=$(kubectl get pods -l app.kubernetes.io/component=server -o jsonpath='{.items[*].status.podIP}' | tr ' ' ',') $ kubectl exec -it $MASTER_NAME -- jmeter -n -t /jmeter/sample.jmx -R $SERVER_IPS diff --git a/k8s/templates/jmeter-master-deployment.yaml b/k8s/templates/jmeter-master-deployment.yaml index 5159f0a..18059b8 100644 --- a/k8s/templates/jmeter-master-deployment.yaml +++ b/k8s/templates/jmeter-master-deployment.yaml @@ -1,12 +1,13 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }}-master + name: {{ template "distributed-jmeter.fullname" . }}-master labels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} helm.sh/chart: {{ include "distributed-jmeter.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} - role: master + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/component: master spec: replicas: {{ .Values.master.replicaCount }} strategy: @@ -14,19 +15,28 @@ spec: selector: matchLabels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }}-master - role: master + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: master template: metadata: labels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }}-master - role: master + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/component: master spec: containers: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} - args: ["master"] + args: + - master ports: - containerPort: 60000 + volumeMounts: + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file diff --git a/k8s/templates/jmeter-server-deployment.yaml b/k8s/templates/jmeter-server-deployment.yaml index 9ada172..bc1e933 100644 --- a/k8s/templates/jmeter-server-deployment.yaml +++ b/k8s/templates/jmeter-server-deployment.yaml @@ -1,12 +1,13 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ .Release.Name }}-server + name: {{ template "distributed-jmeter.fullname" . }}-server labels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} helm.sh/chart: {{ include "distributed-jmeter.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} - role: server + app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/component: server spec: replicas: {{ .Values.server.replicaCount }} strategy: @@ -15,13 +16,13 @@ spec: matchLabels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} - role: server + app.kubernetes.io/component: server template: metadata: labels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} - role: server + app.kubernetes.io/component: server spec: containers: - name: {{ .Chart.Name }} @@ -31,3 +32,11 @@ spec: ports: - containerPort: 50000 - containerPort: 1099 + volumeMounts: + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file diff --git a/k8s/templates/jmeter-server-service.yaml b/k8s/templates/jmeter-server-service.yaml index 6da639e..ace1d0a 100644 --- a/k8s/templates/jmeter-server-service.yaml +++ b/k8s/templates/jmeter-server-service.yaml @@ -1,12 +1,13 @@ apiVersion: v1 kind: Service metadata: - name: {{ .Release.Name }}-server + name: {{ template "distributed-jmeter.fullname" . }}-server labels: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} helm.sh/chart: {{ include "distributed-jmeter.chart" . }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + app.kubernetes.io/component: server spec: clusterIP: None ports: @@ -19,4 +20,4 @@ spec: selector: app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} - role: server + app.kubernetes.io/component: server diff --git a/k8s/values.yaml b/k8s/values.yaml index 76580b3..3f4b2ee 100644 --- a/k8s/values.yaml +++ b/k8s/values.yaml @@ -22,3 +22,7 @@ image: ## The tag for the image ## ref: https://hub.docker.com/r/pedrocesarti/jmeter-docker/tags/ tag: 3.3 + +volumes: [] + +volumeMounts: [] diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 031ed41..1f853eb 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -8,7 +8,7 @@ case $1 in server) $JMETER_HOME/bin/jmeter-server \ -Dserver.rmi.localport=50000 \ - -Dserver_port=1099 + -Dserver_port=1099 $JMETER_SERVER_ADDITIONA_ARGS ;; *) echo "Sorry, this option doesn't exist!" diff --git a/templates/NOTES.txt b/templates/NOTES.txt deleted file mode 100644 index 8603443..0000000 --- a/templates/NOTES.txt +++ /dev/null @@ -1,16 +0,0 @@ -JMeter is now starting. - - -To get get a shell session on the master you only need to run: - -$ export MASTER_NAME=$(kubectl get pods -l role=master -o jsonpath='{.items[*].metadata.name}') -$ kubectl exec -it $MASTER_NAME -- /bin/bash - - -To copy your test plans to the master pod: -$ kubectl cp sample.jmx $MASTER_NAME:/jmeter - - -To run your test in all servers you need first a list of all servers IPs (comma-separated) and then you can run your test: -$ export SERVER_IPS=$(kubectl get pods -lrole=server -o jsonpath='{.items[*].status.podIP}' | tr ' ' ',') -$ kubectl exec -it $MASTER_NAME -- jmeter -n -t /jmeter/sample.jmx -R $SERVER_IPS diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl deleted file mode 100644 index d21e372..0000000 --- a/templates/_helpers.tpl +++ /dev/null @@ -1,32 +0,0 @@ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "distributed-jmeter.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "distributed-jmeter.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} - -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "distributed-jmeter.chart" -}} -{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} -{{- end -}} diff --git a/templates/jmeter-master-deployment.yaml b/templates/jmeter-master-deployment.yaml deleted file mode 100644 index 06e490d..0000000 --- a/templates/jmeter-master-deployment.yaml +++ /dev/null @@ -1,34 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "distributed-jmeter.fullname" . }}-master - labels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - helm.sh/chart: {{ include "distributed-jmeter.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/component: master -spec: - replicas: {{ .Values.master.replicaCount }} - strategy: - type: RollingUpdate - selector: - matchLabels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: master - template: - metadata: - labels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: master - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - args: - - master - ports: - - containerPort: 60000 diff --git a/templates/jmeter-server-deployment.yaml b/templates/jmeter-server-deployment.yaml deleted file mode 100644 index 3c1f19b..0000000 --- a/templates/jmeter-server-deployment.yaml +++ /dev/null @@ -1,34 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ template "distributed-jmeter.fullname" . }}-server - labels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - helm.sh/chart: {{ include "distributed-jmeter.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/component: server -spec: - replicas: {{ .Values.server.replicaCount }} - strategy: - type: RollingUpdate - selector: - matchLabels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: server - template: - metadata: - labels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: server - spec: - containers: - - name: {{ .Chart.Name }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - args: ["server"] - ports: - - containerPort: 50000 - - containerPort: 1099 diff --git a/templates/jmeter-server-service.yaml b/templates/jmeter-server-service.yaml deleted file mode 100644 index ace1d0a..0000000 --- a/templates/jmeter-server-service.yaml +++ /dev/null @@ -1,23 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: {{ template "distributed-jmeter.fullname" . }}-server - labels: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - helm.sh/chart: {{ include "distributed-jmeter.chart" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/managed-by: {{ .Release.Service }} - app.kubernetes.io/component: server -spec: - clusterIP: None - ports: - - port: 50000 - protocol: TCP - name: tcp-50000 - - port: 1099 - protocol: TCP - name: tcp-1099 - selector: - app.kubernetes.io/name: {{ include "distributed-jmeter.name" . }} - app.kubernetes.io/instance: {{ .Release.Name }} - app.kubernetes.io/component: server