With this code you can build Jmeter docker image and deploy it into Kubernetes environment and run Jmeter scripts remotely.
I inspired by the docker-jmeter project on GitHub and adapted it based on my needs.
Create a Kubernetes cluster with either Minikube for local testing, or with IBM Bluemix Container Service to deploy in cloud.
You will need to create your Kubernetes cluster first and make sure it is fully deployed in your Bluemix account.
Please follow the steps below to install the sample application into your Bluemix Kubernetes cluster and generate load.
- Prepare Bluemix Kubernetes cluster
- Build and Push Docker Image
- Deploy Jmeter Image to Kubernetes
- Generate Load
Follow the instructions in Getting Started to setup required tools and Bluemix Kubernetes cluster.
After building the Docker image, it can be pushed into the Bluemix Container Registry or DockerHub. The example below builds the docker image to be put into the Bluemix Container Registry, please replace the with the name of your namespace.
$ docker build -t registry.eu-gb.bluemix.net/<namespace>/jmeter .
$ docker push registry.eu-gb.bluemix.net/<namespace>/jmeter
Use the following command to deploy the Jmeter Image to Kubernetes cluster on Bluemix.
$ kubectl create -f jmeter-deployment.yaml
After deploying Jmeter Image onto your Kubernetes cluster, you can use the following commands to run the Jmeter script and collect performance logs.
JMETER_POD_NAME="jmeter-2150202267-g1vbh" # replace with your Jmeter Pod name
kubectl exec -it ${JMETER_POD_NAME} -- rm -rf /tmp/jmeter-report # Clean the scripts that might be sent previously
kubectl cp ./jmeter-script ${JMETER_POD_NAME}:/tmp/jmeter-script # Copy your Jmeter script to Jmeter Pod
kubectl exec -it ${JMETER_POD_NAME} -- ./bin/jmeter.sh -n -t /tmp/jmeter-script/sample.jmx # Run your Jmeter script on Jmeter Pod
rm -rf /tmp/jmeter-report # Clean the logs from previous run
kubectl cp ${JMETER_POD_NAME}:/tmp/jmeter-report /tmp/jmeter-report # Copy the logs to your local machine