{{- if .Values.scheduler.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "finaegis.fullname" . }}-scheduler
  labels:
    {{- include "finaegis.labels" . | nindent 4 }}
    app.kubernetes.io/component: scheduler
spec:
  replicas: {{ .Values.scheduler.replicaCount }}
  strategy:
    {{- toYaml .Values.scheduler.strategy | nindent 4 }}
  selector:
    matchLabels:
      {{- include "finaegis.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: scheduler
  template:
    metadata:
      annotations:
        checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
      labels:
        {{- include "finaegis.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: scheduler
    spec:
      {{- with .Values.global.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      securityContext:
        runAsNonRoot: true
        runAsUser: 82
        fsGroup: 82
      containers:
        - name: scheduler
          image: {{ include "finaegis.image" . }}-scheduler
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          envFrom:
            - configMapRef:
                name: {{ include "finaegis.configMapName" . }}
            {{- if .Values.externalSecrets.enabled }}
            - secretRef:
                name: {{ include "finaegis.secretName" . }}
            {{- end }}
          resources:
            {{- toYaml .Values.scheduler.resources | nindent 12 }}
          volumeMounts:
            - name: storage
              mountPath: /var/www/html/storage/logs
              subPath: logs
      volumes:
        - name: storage
          emptyDir: {}
      {{- with .Values.web.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.web.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
{{- end }}
