vmware-tanzu / velero

Backup and migrate Kubernetes applications and their persistent volumes
https://velero.io
Apache License 2.0
8.57k stars 1.39k forks source link

Make it easy to mark/unmark a volume for restic backup #605

Open ncdc opened 6 years ago

ncdc commented 6 years ago

The current mechanism to mark a volume for a restic backup is

kubectl -n YOUR_POD_NAMESPACE annotate pod/YOUR_POD_NAME backup.ark.heptio.com/backup-volumes=YOUR_VOLUME_NAME_1,YOUR_VOLUME_NAME_2,...

It would be nice to make this easier with an ark subcommand. We should also make sure we can support various resources that contain pod specs (deployments, statefulsets, replicasets, jobs, replication controllers, pods themselves, ...)

agolomoodysaada commented 5 years ago

As a good starting point, I created this snippet that helps set up annotation commands for you. Install fx and then run

kubectl get pods --all-namespaces -o json | fx 'l => l.items' 'i => i.reduce((acc, p) => {acc.push("kubectl -n " + p.metadata.namespace + " annotate pod/" + p.metadata.name + " backup.ark.heptio.com/backup-volumes=" + p.spec.volumes.map(v => v.name).join(",")); return acc;}, [])'

Which outputs the following structure

[
...
  "kubectl -n redis annotate pod/redis-master-4 backup.ark.heptio.com/backup-volumes=redis-data,redis-conf,default-token-lqmpv"
...
]

It would be awesome if ark itself could help manage that out of the box and maybe take a selector as an argument. For example ark restic annotate -n mynamespace -l app=mongodb --all-volumes

zakkg3 commented 5 years ago

I wrote a cli for this, just run python3 annotate.py namespace1 namespace2 https://github.com/zakkg3/podannotator requires python3 It will annotate all pods with PVC in the given namespace(s).

carlisia commented 4 years ago

Related: https://github.com/vmware-tanzu/velero/issues/1871.

carlisia commented 4 years ago

I added this topic to our community meeting tomorrow (3/31): https://hackmd.io/Jq6F5zqZR7S80CeDWUklkA?both#March-31-2020.