Skip to content

Instantly share code, notes, and snippets.

@sebastien-prudhomme
Created April 27, 2020 15:26
Show Gist options
  • Save sebastien-prudhomme/c53e870dc6b4987fefa4c36ea9f1187c to your computer and use it in GitHub Desktop.
Save sebastien-prudhomme/c53e870dc6b4987fefa4c36ea9f1187c to your computer and use it in GitHub Desktop.
Kubernetes volume snapshot-based backup with Stash and Argo
apiVersion: stash.appscode.com/v1beta1
kind: BackupConfiguration
metadata:
name: mongodb
spec:
schedule: "0 23 * * 0"
paused: true
driver: VolumeSnapshotter
target:
ref:
apiVersion: apps/v1
kind: Deployment
name: mongodb
snapshotClassName: scw-snapshot
retentionPolicy:
name: mongodb
keepLast: 5
prune: true
apiVersion: argoproj.io/v1alpha1
kind: CronWorkflow
metadata:
name: mongodb-backup
spec:
schedule: "0 23 * * 0"
suspend: false
concurrencyPolicy: Forbid
workflowSpec:
entrypoint: mongodb-backup
activeDeadlineSeconds: 3600
templates:
- name: mongodb-backup
serviceAccountName: mongodb-backup
resource:
action: create
manifest: |
apiVersion: stash.appscode.com/v1beta1
kind: BackupSession
metadata:
generateName: mongodb-
spec:
invoker:
apiGroup: stash.appscode.com
kind: BackupConfiguration
name: mongodb
successCondition: status.phase == Succeeded
failureCondition: status.phase == Failed
metrics:
prometheus:
- name: backup_duration_seconds
help: Duration of the backup in seconds
gauge:
value: "{{duration}}"
labels:
- key: application
value: mongodb
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: mongodb-backup
rules:
- apiGroups:
- stash.appscode.com
resources:
- backupsessions
verbs:
- create
- get
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: mongodb-backup
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: mongodb-backup
subjects:
- kind: ServiceAccount
name: mongodb-backup
namespace: default
apiVersion: v1
kind: ServiceAccount
metadata:
name: mongodb-backup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment