apiVersion: batch/v1
kind: Job
metadata:
  name: update-nc
  namespace: ${NS}
spec:
  template:
    spec:
      containers:
      - command:
        - /bin/sh
        - -c
        args:
        - /bin/echo start update;
          /usr/local/bin/php occ status;
          /usr/local/bin/php occ upgrade;
        env:
        - name: INSTALLED
          value: "true"
        - name: VERSION
          value: ${NC_VERSION}
        - name: OBJECTSTORE_S3_KEY 
          valueFrom:
            secretKeyRef:
              key: AWS_ACCESS_KEY_ID 
              name: ${FQDN}-s3
        - name: OBJECTSTORE_S3_SECRET 
          valueFrom:
            secretKeyRef:
              key: AWS_SECRET_ACCESS_KEY
              name: ${FQDN}-s3
        - name: MAIL_FROM_ADDRESS 
          valueFrom:
            secretKeyRef:
              key: mail_from_address
              name: ${NS}-smtp
        - name: SMTP_PASSWORD
          valueFrom:
            secretKeyRef:
              key: password 
              name: ${NS}-smtp
        - name: SMTP_NAME 
          valueFrom:
            secretKeyRef:
              key: username
              name: ${NS}-smtp
        - name: DB_PASSWORD 
          valueFrom:
            secretKeyRef:
              key: password 
              name: nextcloud.pg-${PG_DOMAIN}.credentials
        envFrom:
        - secretRef:
            name: ${FQDN}-app
        image: libresh/nextcloud:${NC_IMAGE_TAG}
        imagePullPolicy: IfNotPresent
        name: install-nuage
      restartPolicy: Never
      securityContext:
        fsGroup: 82
        runAsGroup: 82
        runAsUser: 82
