diff --git a/k8s/import.cronjob.yml b/k8s/import.cronjob.yml new file mode 100644 index 0000000000000000000000000000000000000000..2706a944bcd0226035c7885b41a5515e3b65a6fa --- /dev/null +++ b/k8s/import.cronjob.yml @@ -0,0 +1,92 @@ +apiVersion: batch/v1beta1 +kind: CronJob +metadata: + name: eclipsefdn-import-backup + namespace: foundation-internal-webdev-apps +spec: + schedule: "0 1 * * 0" + # if it is time for a new job run and the previous job run hasn’t finished yet, the cron job skips the new job run + concurrencyPolicy: Forbid + jobTemplate: + spec: + template: + spec: + affinity: + nodeAffinity: + preferredDuringSchedulingIgnoredDuringExecution: + - preference: + matchExpressions: + - key: speed + operator: NotIn + values: + - fast + weight: 1 + containers: + - name: eclipsefdn-import-backup + image: eclipsefdn/eclipsefdn-import-backup:latest + imagePullPolicy: Always # TODO: change to IfNotPresent once the deploy step is integrated into CD + args: + - /bin/sh + - -c + - npm run import-backup -- --verbose=true --host="https://gitlab.eclipse.org" --tls-min-v1.0 --target=openhw-group/github-backup --organization=openhwgroup 2>&1 | tee -a /app/logs/import-stdout-$(date +%Y-%m-%d).log + volumeMounts: + - name: logs + mountPath: /app/logs + - name: cache + mountPath: /app/.cache + - name: import-backup-secrets + mountPath: "/run/secrets/access-token" + readOnly: true + # workaround https://github.com/kubernetes/kubernetes/issues/65835 + subPath: access-token + - name: import-sync-secrets + mountPath: "/run/secrets/github-access-token" + readOnly: true + # workaround https://github.com/kubernetes/kubernetes/issues/65835 + subPath: github-access-token + restartPolicy: Never + volumes: + - name: logs + persistentVolumeClaim: + claimName: import-backup-logs + - name: cache + emptyDir: {} + - name: import-backup-secrets + secret: + secretName: import-backup-secrets + # workaround https://github.com/kubernetes/kubernetes/issues/65835 + items: + - key: access-token + path: access-token + - key: github-access-token + path: github-access-token +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: import-backup-logs + annotations: + volume.beta.kubernetes.io/mount-options: rw,nfsvers=3,noexec +spec: + capacity: + storage: 10Gi + accessModes: + - ReadWriteOnce + claimRef: + namespace: foundation-internal-webdev-apps + name: import-backup-logs + nfs: + server: fred + path: /opt/export/eclipsefdn-import-backup/logs +--- +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: import-backup-logs + namespace: foundation-internal-webdev-apps +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi diff --git a/package.json b/package.json index 3768c947773005c0c2c78314979c2cbb73171b79..9ff857716e7269461e32d6d322a3bbd7e38c3091 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "start": "node src/Sync.js -c", "pretest": "eslint --ignore-path .gitignore .", "test": "mocha --timeout 60000", - "lab-sync": "node src/GitlabSync.js -c" + "lab-sync": "node src/GitlabSync.js -c", + "import-backup": "node src/auto_backup/Import.js" }, "license": "EPL-2.0", "bugs": {