apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cluster-scan-collector
  namespace: cluster-image-scanner-image-collector
spec:
  schedule: "*/5 * * * *"
  concurrencyPolicy: Forbid
  failedJobsHistoryLimit: 1
  successfulJobsHistoryLimit: 1
  suspend: false
  jobTemplate:
    spec:
      template:
        spec:
          serviceAccountName: image-collector
          automountServiceAccountToken: true # mount cluster-scan
          restartPolicy: Never
          containers:
            - name: cluster-scan-image-collector
              securityContext:
                runAsNonRoot: true
                allowPrivilegeEscalation: false
                runAsUser: 1001
              image: quay.io/sdase/cluster-image-scanner-imagecollector:2.0
              imagePullPolicy: Always
              env:
                - name: CLUSTER_NAME
                  value: "minikube"
                - name: GITHUB_REPOSITORY
                  value: "github.com/pagel-pro/cluster-image-scanner-test-targets.git"
                - name: GITHUB_APP_ID
                  valueFrom:
                    configMapKeyRef:
                      name: collector-upload-repository
                      key: collector.upload.github.appid
                - name: GITHUB_INSTALLATION_ID
                  valueFrom:
                    configMapKeyRef:
                      name: collector-upload-repository
                      key: collector.upload.github.installlationid
                - name: NAMESPACE_MAPPINGS
                  valueFrom:
                    configMapKeyRef:
                      name: collector-upload-repository
                      key: collector.namespacemapping
              resources:
                limits:
                  cpu: 200m
                  memory: 124Mi
          volumes:
            - name: collector-upload-repository
              configMap:
                name: collector-upload-repository
