apiVersion: v1
kind: ConfigMap
metadata:
  name: example-fio-warmup-workload
  namespace: cnsbench-library
  labels:
    type: workload
  annotations:
    cnsbench.default.initConfig: fio-rw-warmupconfig
    cnsbench.default.config: fio-rw-config
    cnsbench.default.rw: rw
    cnsbench.default.pctread: "50"
    cnsbench.default.fiosize: 6g
    cnsbench.default.pvcsize: 7Gi
data:
  pvc.yaml: |
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      name: vol-{{ACTION_NAME}}-{{INSTANCE_NUM}}
      namespace: default
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: {{pvcsize}}
      storageClassName: {{storageClass}}
      volumeMode: Filesystem
  warmupconfig.yaml: |
    apiVersion: v1
    data:
      fio-rw-warmupconfig: |
        [global]
        filename=/var/data/testfile
        size={{fiosize}}

        [test]
        rw={{rw}}
        rwmixread={{pctread}}
        nrfiles=1
        blocksize=1M
        time_based
        runtime=5m
    kind: ConfigMap
    metadata:
      name: fio-rw-warmupconfig
      namespace: default
  config.yaml: |
    apiVersion: v1
    data:
      fio-rw-config: |
        [global]
        filename=/var/data/testfile
        size={{fiosize}}

        [test]
        rw={{rw}}
        rwmixread={{pctread}}
        nrfiles=1
        blocksize=1M
        time_based
        runtime=20s
    kind: ConfigMap
    metadata:
      name: fio-rw-config
      namespace: default
  workload.yaml: |
    apiVersion: batch/v1
    kind: Job
    metadata:
      name: fio-{{ACTION_NAME}}-{{INSTANCE_NUM}}
      namespace: default
      annotations:
        sync: "1"
        role: workload
        outputFile: /output/output.json
        parser: null-parser
    spec:
      backoffLimit: 0
      template:
        spec:
          restartPolicy: Never
          initContainers:
          - image: fio
            imagePullPolicy: IfNotPresent
            name: warmup-fio
            command: ["fio", "/var/config/config"]
            volumeMounts:
              - mountPath: /var/data/
                name: data
              - mountPath: /var/config/
                name: warmupconfig
          containers:
          - image: fio
            imagePullPolicy: IfNotPresent
            name: fio
            command: ["sh", "-c", "fio /var/config/config | tee /output/output"]
            volumeMounts:
              - mountPath: /var/data/
                name: data
              - mountPath: /var/config/
                name: config
          volumes:
          - name: data
            persistentVolumeClaim:
              claimName: {{volname}}
          - name: config
            configMap:
              name: {{config}}
              items:
              - key: {{config}}
                path: config
          - name: warmupconfig
            configMap:
              name: {{warmupConfig}}
              items:
              - key: {{warmupConfig}}
                path: config
