apiVersion: apps/v1
kind: Deployment
metadata:
  name: jmeter-slaves
  labels:
    crux.jmeter_mode: slave
spec:
  replicas: 1
  selector:
    matchLabels:
      crux.jmeter_mode: slave
  template:
    metadata:
      labels:
        crux.jmeter_mode: slave
    spec:
      affinity: #schedule where master does NOT run
        nodeAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              preference:
                matchExpressions:
                  - key: crux.usage
                    operator: In
                    values:
                      - jmeter
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 1
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: crux.jmeter_mode
                      operator: In
                      values:
                        - master
                        - slave
                topologyKey: "kubernetes.io/hostname"
      volumes:
        - name: dshm
          emptyDir:
            medium: Memory
        - name: jmeter-shared-disk
          persistentVolumeClaim:
            claimName: jmeter-shared-disk
      containers:
      - name: jmslave
        image: gabrielstar/crux-slave:0.0.1
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 1099
        - containerPort: 50000
        volumeMounts:
          - mountPath: /dev/shm
            name: dshm
          - mountPath: "/shared"
            name: jmeter-shared-disk