apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: "kathra-synchro"
  annotations:
    "helm.sh/hook": post-install
    "helm.sh/hook-delete-policy": "hook-succeeded"
    "helm.sh/hook-delete-policy": "before-hook-creation"
spec:
  schedule: "*/1 * * * *"
  startingDeadlineSeconds: 120
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          imagePullSecrets:
          - name: regcred
          containers:
          - name: kathra-synchro
            image: "{{ .Values.global.docker.registry.url }}{{ .Values.global.docker.registry.root_repository }}/{{ .Values.image }}:{{ .Values.version }}"
            imagePullPolicy: Always
            env:
            - name: SOURCE_MANAGER_URL
              valueFrom:
                configMapKeyRef:
                  name: sync-config
                  key: SOURCE_MANAGER_URL
            - name: PIPELINE_MANAGER_URL
              valueFrom:
                configMapKeyRef:
                  name: sync-config
                  key: PIPELINE_MANAGER_URL
            - name: KEYCLOAK_AUTH_URL
              valueFrom:
                configMapKeyRef:
                  key: KEYCLOAK_AUTH_URL
                  name: keycloak-config
            - name: KEYCLOAK_REALM
              valueFrom:
                configMapKeyRef:
                  key: KEYCLOAK_REALM
                  name: keycloak-config
            - name: RESOURCE_MANAGER_URL
              valueFrom:
                configMapKeyRef:
                  name: sync-config
                  key: RESOURCE_MANAGER_URL
            - name: USER_MANAGER_URL
              valueFrom:
                configMapKeyRef:
                  name: sync-config
                  key: USER_MANAGER_URL
            - name: BINARY_REPOSITORY_MANAGER_URL_HARBOR
              valueFrom:
                configMapKeyRef:
                  name: sync-config
                  key: BINARY_REPOSITORY_MANAGER_URL_HARBOR
            - name: BINARY_REPOSITORY_MANAGER_URL_NEXUS
              valueFrom:
                configMapKeyRef:
                  name: sync-config
                  key: BINARY_REPOSITORY_MANAGER_URL_NEXUS
            - name: USERNAME
              valueFrom:
                secretKeyRef:
                  name: sync-secret
                  key: USERNAME
            - name: PASSWORD
              valueFrom:
                secretKeyRef:
                  name: sync-secret
                  key: PASSWORD
            - name: KEYCLOAK_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: keycloak-secret
                  key: KEYCLOAK_CLIENT_ID
            - name: KEYCLOAK_CLIENT_SECRET
              valueFrom:
                secretKeyRef:
                  name: keycloak-secret
                  key: KEYCLOAK_CLIENT_SECRET
            - name: JAVA_OPTS
              value: "-XX:+UnlockExperimentalVMOptions  -XX:MaxRAMFraction=1 -Xms128M -Xmx512M"
          restartPolicy: OnFailure

