apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: kubemarks-pkb
spec:
  concurrencyPolicy: Allow
  jobTemplate:
    spec:
      template:
        spec:
          restartPolicy: Never
          containers:
            - args:
                - /bin/sh
                - -c
                - scripts/pkb/start.sh $BENCHMARKS_TO_RUN; /bin/sh
              env:
                - name: PUSHGATEWAY
                  valueFrom:
                    configMapKeyRef:
                      name: kubemarks-conf
                      key: pushgateway
                - name: BENCHMARKS_TO_RUN
                  valueFrom:
                    configMapKeyRef:
                      name: kubemarks-conf
                      key: benchmarks
              image: marcomicera/kubemarks-cronjob:latest
              name: kubemarks-pkb
              resources: {}
              volumeMounts:
                - name: kubemarks-root
                  mountPath: /home/root
                - mountPath: /home/root/kubemarks/kubemarks-num-pods.yaml
                  name: kubemarks-num-pods
                  readOnly: true
                  subPath: kubemarks-num-pods.yaml
          initContainers:
            - name: git-sync
              image: k8s.gcr.io/git-sync:v3.1.5
              env:
                - name: GIT_SYNC_REPO
                  value: https://github.com/marcomicera/kubemarks.git
                - name: GIT_SYNC_ROOT
                  value: /home/root
                - name: GIT_SYNC_DEST
                  value: kubemarks
                - name: GIT_SYNC_BRANCH
                  value: master
                - name: GIT_SYNC_ONE_TIME # exit after the initial checkout
                  value: "1"
              volumeMounts:
                - name: kubemarks-root
                  mountPath: /home/root
              securityContext:
                runAsUser: 65533 # git-sync user
                allowPrivilegeEscalation: false
                readOnlyRootFilesystem: true
                capabilities:
                  drop: ["all"]
              imagePullPolicy: Always
          serviceAccountName: kubemarks
          volumes:
            - name: kubemarks-root
              emptyDir: {}
            - name: kubemarks-num-pods
              configMap:
                name: kubemarks-num-pods
  schedule: '0 * * * *'
status: {}
