Skip to content

Instantly share code, notes, and snippets.

@lfaoro
Last active June 25, 2018 10:32
Show Gist options
  • Save lfaoro/4cdcbba3491080d887e67410600b7a1b to your computer and use it in GitHub Desktop.
Save lfaoro/4cdcbba3491080d887e67410600b7a1b to your computer and use it in GitHub Desktop.
batch-sql-backup.yaml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: batch-sql-backup
spec:
schedule: "* */60 * * *"
concurrencyPolicy: Forbid
jobTemplate:
spec:
template:
spec:
volumes:
- name: cloudsql-instance-credentials
secret:
secretName: cloudsql-instance-credentials
containers:
- name: backup-sql
image: google/cloud-sdk:latest
command: ["/bin/sh", "-c"]
args: ["gcloud auth activate-service-account {{ .Values.cloudSQLServiceAccount }} --key-file=/secrets/cloudsql/credentials.json && gcloud config set project {{ .Values.projectID }} && gcloud sql backups create -i {{ .Values.cloudSQLName }}"]
volumeMounts:
- name: cloudsql-instance-credentials
mountPath: /secrets/cloudsql
readOnly: true
restartPolicy: OnFailure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment