apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: withings-garmin-sync
spec:
  concurrencyPolicy: Allow
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - args:
            - -v

            # override $HOME to put our oauth file in a known place
            env:
            - name: HOME
              value: /root

            # read usernames/passwords from the secret we defined
            envFrom:
            - secretRef:
                name: credentials
            image: stv0g/withings-sync
            imagePullPolicy: Always
            name: withings-garmin-sync
            volumeMounts:
            - mountPath: /root/
              name: oauth-cache

          restartPolicy: Never

          # Never run this container as root
          securityContext:
            fsGroup: 1234
            runAsGroup: 1234
            runAsUser: 1234
            runAsNonRoot: True
          
          volumes:
          - name: oauth-cache
            persistentVolumeClaim:
              claimName: withings-oauth-cache

  schedule: '* */3 * * *'
  successfulJobsHistoryLimit: 3

