Skip to content

Instantly share code, notes, and snippets.

@abihf
Created February 11, 2020 05:30
Show Gist options
  • Save abihf/cecb85a03b29cf2708344cb648895eac to your computer and use it in GitHub Desktop.
Save abihf/cecb85a03b29cf2708344cb648895eac to your computer and use it in GitHub Desktop.
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: backup
namespace: jenkins
spec:
schedule: 0 17 * * * # 00:00 GMT+7
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 5
jobTemplate:
spec:
template:
spec:
serviceAccountName: jenkins-backup
containers:
- name: backup
image: traveloka/awscli:latest
workingDir: /var/jenkins_home
command:
- sh
- -c
args:
- |
tar -cv *.xml jobs/*/*.xml *.groovy.d plugins/*.jpi secrets/ users/ |
zstd --fast -T3 |
aws s3 cp - s3://${S3_BUCKET}/backup/$(date -Iseconds).tar.zst
resources:
limits:
cpu: 3000m
memory: 1Gi
requests:
cpu: 200m
memory: 500Mi
volumeMounts:
- mountPath: /var/jenkins_home
name: jenkins-home
readOnly: true
# todo: add env from configmap to get S3_BUCKET value
nodeSelector:
kubernetes.io/lifecycle: normal
restartPolicy: Never
volumes:
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins-efs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment