apiVersion: apps/v1
kind: Deployment
metadata:
  name: jmeter-flagger-loadtester
  labels:
    app.kubernetes.io/name: loadtester
    app.kubernetes.io/instance: jmeter-flagger
spec:
  replicas: 1
  selector:
    matchLabels:
      app: loadtester
  template:
    metadata:
      labels:
        app: loadtester
      annotations:
        appmesh.k8s.aws/ports: "444"
        prometheus.io/port: "8080"
        prometheus.io/scrape: "true"
    spec:
      containers:
        - name: loadtester
          image: "kashinoki38/jmeter-flagger:latest"
          imagePullPolicy: Always
          ports:
            - name: http
              containerPort: 8080
          command:
            - ./loadtester
            - -port=8080
            - -log-level=info
            - -timeout=1h
          livenessProbe:
            exec:
              command:
                - wget
                - --quiet
                - --tries=1
                - --timeout=4
                - --spider
                - http://localhost:8080/healthz
            timeoutSeconds: 5
          readinessProbe:
            exec:
              command:
                - wget
                - --quiet
                - --tries=1
                - --timeout=4
                - --spider
                - http://localhost:8080/healthz
            timeoutSeconds: 5
          resources:
            requests:
              cpu: 10m
              memory: 64Mi
          volumeMounts:
            - mountPath: /load_test
              name: loadtest
              subPath: load_test
            - mountPath: /scenario.jmx
              name: jmeter-scenario-load-test1
              subPath: scenario.jmx
            - mountPath: /preparation.jmx
              name: jmeter-scenario-load-test2
              subPath: preparation.jmx
            - mountPath: /socks.csv
              name: jmeter-scenario-load-test3
              subPath: socks.csv
            - mountPath: /userlist.csv
              name: jmeter-scenario-load-test4
              subPath: userlist.csv
            # - mountPath: /sc-user-preparation
            #   name: jmeter-scenario-user-preparation
      volumes:
        - configMap:
            defaultMode: 420
            name: jmeter-loadtest-jmeter-master-config
          name: loadtest
        - configMap:
            defaultMode: 420
            name: jmeter-scenario-load-test
            items:
              - key: scenario.jmx
                path: scenario.jmx
          name: jmeter-scenario-load-test1
        - configMap:
            defaultMode: 420
            name: jmeter-scenario-load-test
            items:
              - key: preparation.jmx
                path: preparation.jmx
          name: jmeter-scenario-load-test2
        - configMap:
            defaultMode: 420
            name: jmeter-scenario-load-test
            items:
              - key: socks.csv
                path: socks.csv
          name: jmeter-scenario-load-test3
        - configMap:
            defaultMode: 420
            name: jmeter-scenario-load-test
            items:
              - key: userlist.csv
                path: userlist.csv
          name: jmeter-scenario-load-test4
        # - configMap:
        #     defaultMode: 420
        #     name: jmeter-scenario-user-preparation
        #   name: jmeter-scenario-user-preparation
