0

I'm currently trying out Azure AKS and during setup I obviously also want to make backups. For this the best practice seems to be velero. According to the documentation of velero to include pv snapshots you would annotate the pod/deployment. Example:

backup.velero.io/backup-volumes: wp-pv

Note the above is when using a static managed disk. I can see the snapshot is created. However, when I do a restore a new pv is created instead of using the one from the restore. Is this expected behavior?

Ideally, I would like to use dynamic pv's instead but this would make it even more trivial because I don't know what name the pv will have and thus can't add proper annotations beforehand.

How can I solve this in a clean way? My ideal situation would be to have scheduled backups using velero and in case of a recovery automatically have it use the snapshot as base for the pv instead of it creating a new one that doesn't contain my data. For now, it seems this is a manual procedure? Am I missing something?

xtrc
  • 89
  • 9

1 Answers1

1

This is by design.

PersistantVolumes by definitions can only ever belong to one PVC claimant. Even when set as dynamic.

I think what you want is to have the reclaim policy set to retain. See here:

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#retain

A state of "Retain" should mean that the PVs data persists, it is just needing to be reclaimed by a new PV/PVC. The AKS should pick up on this... But I've only ever done this with AWS/Baremetal

In this case Velero, rightly, has to both recreate the PVC and PV for the volume to be released and reassigned to the new claimant.

Dandy
  • 1,466
  • 16
  • 31
  • Hi Dandy, I changed the reclaim policy to retain for the persistent volume but in my recovery scenario I delete the namespace that includes my resources and the pv that's associated. After deletion I create a restore and I can see a new PV is created to setup the environment. – xtrc Oct 21 '19 at 07:00
  • That should still be fine, Velero will simply restore all missing resources that it finds in it's etcd backup file. The recovered PV/PVC will be "different" but should still reference the Azure AKS data. I am assuming that the Azure AKS doesn't need something special to ensure the data is retained, Are you saying that the PV is wrong, or the data goes missing in your storage provider when deleting the namespace? – Dandy Oct 21 '19 at 07:03
  • Well, if I don't delete the PV after removing the namespace. The data is retained upon a restore but I also want to see the restore of velero work even if I delete the PV in my case the snapshot disk is now named myAKSDisk-03b7d48a-17fa-44c5-9011-18951943f9ef and the deployment is now using "myAKSDisk" which is a new PV. – xtrc Oct 21 '19 at 07:05
  • Oh, yeah, I hadn't considered that. I am not even sure how Velero would manage this scenario, as it would have to effectively remove the retained PV. I will see if I can try a similar scenario but I'll see if someone else has any good answers for this. May be worth asking Velero devs on Slack. – Dandy Oct 21 '19 at 07:10