apiVersion: batch/v1
kind: Job
metadata:
  name: spring-job-$JOB_NAME
spec:
  parallelism: 3
  template:
    spec:
      serviceAccountName: batch
      restartPolicy: OnFailure
      containers:
        - name: spring-job
#          image: gcr.io/$PROJECT_NAME/spring-batch:0.0.1
          image: us-central1-docker.pkg.dev/$PROJECT_NAME/shinyay-docker-repo/spring-batch:0.0.1
          imagePullPolicy: Always
          resources:
            requests:
              cpu: 2000m
              memory: 4Gi
          args: ["fileName=$(FILE_NAME)"]
          env:
            - name: SPRING_DATASOURCE_DRIVER-CLASS-NAME
              value: com.mysql.cj.jdbc.Driver
            - name: FILE_NAME
              valueFrom:
                configMapKeyRef:
                  name: mydb-config
                  key: filename
            - name: SPRING_CLOUD_GCP_SQL_INSTANCE-CONNECTION-NAME
              valueFrom:
                configMapKeyRef:
                  name: mydb-config
                  key: db.instance
            - name: SPRING_DATASOURCE_USERNAME
              valueFrom:
                secretKeyRef:
                  name: mydb-secret
                  key: db.username
            - name: SPRING_DATASOURCE_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: mydb-secret
                  key: db.password
            - name: SPRING_CLOUD_GCP_SQL_ENCODED-KEY
              valueFrom:
                secretKeyRef:
                  name: mydb-secret
                  key: db.accountkey