apiVersion: apps/v1
kind: Deployment
metadata:
  name: jmeter-master
  labels:
    jmeter_mode: master
spec:
  replicas: 1
  selector:
    matchLabels:
      jmeter_mode: master
  template:
    metadata:
      labels:
        jmeter_mode: master
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: jmeter_mode
                operator: In
                values:
                - slave
            topologyKey: "kubernetes.io/hostname"     
      containers:
      - name: jmmaster
        image: kubernautslabs/jmeter_master:latest
        imagePullPolicy: IfNotPresent
        command: [ "/bin/bash", "-c", "--" ]
        args: [ "while true; do sleep 30; done;" ]
        volumeMounts:
          - name: loadtest
            mountPath: /load_test
            subPath: "load_test"
        ports:
        - containerPort: 60000
        lifecycle:
          postStart:
            exec:
              command: ["/bin/sh", "-c", "cp -r /load_test /jmeter/load_test && chmod 755 /jmeter/load_test"]
      volumes:
      - name: loadtest 
        configMap:
         name: jmeter-load-test
         defaultMode: 0755
