Skip to content

Instantly share code, notes, and snippets.

@dmc5179
Created March 25, 2021 03:01
Show Gist options
  • Save dmc5179/ed7285c5f7d67a5575e5414251d09662 to your computer and use it in GitHub Desktop.
Save dmc5179/ed7285c5f7d67a5575e5414251d09662 to your computer and use it in GitHub Desktop.
etcd backup kubecron to S3
---
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: etcd-backup
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: etcd-backup
image: docker.io/amazon/aws-cli
imagePullPolicy: IfNotPresent
command: ["/bin/sh"]
args:
- -c
- 'chroot /host /usr/local/bin/cluster-backup.sh /home/core/assets/backup && aws s3 sync /host/home/core/assets/backup/ "s3://${BUCKET_NAME}/${BUCKET_PATH}/"'
securityContext:
privileged: true
runAsUser: 0
env:
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: aws-creds
key: aws_access_key_id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: aws-creds
key: aws_secret_access_key
- name: AWS_DEFAULT_REGION
value: "us-east-1"
- name: BUCKET_NAME
value: 'mybucket'
- name: BUCKET_PATH
value: "etcd"
volumeMounts:
- name: host
mountPath: /host
restartPolicy: OnFailure
dnsPolicy: ClusterFirst
enableServiceLinks: true
hostNetwork: true
hostPID: true
securityContext: {}
serviceAccount: default
serviceAccountName: default
tolerations:
- operator: Exists
nodeSelector:
node-role.kubernetes.io/master: ''
volumes:
- name: host
hostPath:
path: /
type: Directory
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment