apiVersion: batch/v1
kind: CronJob
metadata:
  name: {{ include "kubescape.fullname" . }}
  labels:
    {{- include "kubescape.labels" . | nindent 4 }}
spec:
  schedule: "{{ .Values.schedule }}"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: {{ .Chart.Name }}
            image: "{{ .Values.image.repository }}/{{ .Values.image.imageName }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
            imagePullPolicy: {{ .Values.image.pullPolicy }}
            command: ["/bin/sh", "-c"]
            args: ["kubescape scan framework nsa --submit"]
            volumeMounts:
            - name: kubescape-config-volume
              mountPath: /root/.kubescape/config.json
              subPath: config.json
          restartPolicy: OnFailure
          serviceAccountName: {{ include "kubescape.serviceAccountName" . }}
          volumes:
          - name: kubescape-config-volume
            configMap:
              name: {{ include "kubescape.fullname" . }}-configmap
