# Upgrade job for making sure that Aleph DB is up2date
apiVersion: batch/v1
kind: Job
metadata:
  name: search-upgrade
  namespace: aleph
spec:
  backoffLimit: 4
  template:
    spec:
      restartPolicy: Never
      containers:
        - name: search-upgrade
          image: alephdata/aleph:{{ .Values.global.imagetag }}
          imagePullPolicy: Always
          command: ["aleph", "upgrade"]
          resources:
            requests:
              memory: 500Mi
              cpu: 200m
            limits:
              memory: 1000Mi
              cpu: 600m
          env:
            - name: GOOGLE_APPLICATION_CREDENTIALS
              value: /credentials/service-account.json
          envFrom:
            - configMapRef:
                name: search-config
            - secretRef:
                name: common-secrets
          volumeMounts:
            - mountPath: /credentials
              name: service-account-app
        - name: search-db-sidecar
          resources:
            requests:
              memory: 64Mi
              cpu: "0.1"
            limits:
              memory: 64Mi
              cpu: "0.1"
          image: b.gcr.io/cloudsql-docker/gce-proxy:latest
          imagePullPolicy: Always
          command:
            - /cloud_sql_proxy
            - -dir=/cloudsql
            - -instances={{ .Values.global.dbInstance }}
            - -credential_file=/credentials/service-account.json
          livenessProbe:
            exec:
              command:
                - nc
                - -z
                - 127.0.0.1
                - "5432"
          readinessProbe:
            exec:
              command:
                - nc
                - -z
                - 127.0.0.1
                - "5432"
          volumeMounts:
            - mountPath: /credentials
              name: service-account-db
      volumes:
        - name: service-account-app
          secret:
            secretName: service-account-app
        - name: service-account-db
          secret:
            secretName: service-account-db
