Skip to main content

JMeter Kubernetes Config

To create JMeter Master & Slaves in Kubernetes we need to create config yaml files.

I have created base yaml files for master and slave based on which we will be creating final yaml files that would be applied to create pods.

create.sh script which is located in kubernetes-init folder, will create master and slave yaml files under config folder in same directory once you execute the below command

create.sh <No of slaves> <JMeter Script name>

Now we have master.yaml and slavex.yaml files under config folder which we can use to create Kubernetes pods.

create.sh script does the following:

It takes input on number of JMeter slaves to be created and the script to be used and place them in Kubernetes yaml files which will be passed on the JMeter pods when started in Kubernetes.

create.sh Script will also assign unique name for Results, Logs, HTML report, and assigns Slaves to be connected by JMeter master pod. You can also add additional attributes required to JMeter by appending to below args as you do for regular JMeter.

args: ["-n -t /mnt/jmeter/JMXSCRIPT -l /mnt/jmeter/results/result-DATETIME.jtl -j /mnt/jmeter/logs/master-log-DATETIME.log -e -o /mnt/jmeter/HtmlReport-DATETIME -R SERVERS"]  

We are using only one Docker images but we can configure JMeter to run in Master or Slave mode based on environment variable mode which is present in Kubernetes yaml files.

You can configure JMeter Heap size and other JVM arguments by changing value corresponding to JVM_ARGS

env:
- name: JVM_ARGS
  value: "-Xms512m -Xmx1024m"
- name: mode
  value: "master"

You can set CPU and Memory Limits as per your requirement.
  • requests should never be more than limits.  
  • CPU is allocated in millicores
    • 1 physical core = 1000 millicores 
  • Memory can be allocated in MB or GB
    • MB  = Mi
    • GB = Gi
resources:
  limits:
memory: 1024Mi
cpu: 1000m
  requests:
cpu: 1000m
memory: 1024Mi