-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lep): multiple backup stores support
Ref: 5411 Signed-off-by: James Lu <james.lu@suse.com>
- Loading branch information
1 parent
67b4b38
commit b43e811
Showing
1 changed file
with
188 additions
and
0 deletions.
There are no files selected for viewing
188 changes: 188 additions & 0 deletions
188
enhancements/20230828-multiple-backup-stores-support.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
# Multiple Backup Stores Support | ||
|
||
## Summary | ||
|
||
The current Longhorn only support a single backup store for all volumes. The feature aims to provide multiple backup stores with tiering. | ||
|
||
### Related Issues | ||
|
||
https://github.com/longhorn/longhorn/issues/2317 | ||
https://github.com/longhorn/longhorn/issues/5411 | ||
|
||
## Motivation | ||
|
||
Users can choose backup stores to that they want to back up volumes. | ||
|
||
### Goals | ||
|
||
- There are difference backup targets at the same time on Longhorn. | ||
- Backups can be synchronized from difference remote backup targets. | ||
- Backups can be backed up to difference remote backup targets. | ||
- A backup can be restored from difference remote backup targets to be a new volume. | ||
|
||
### Non-goals [optional] | ||
|
||
`None` | ||
|
||
## Proposal | ||
|
||
1. Allow users to create, delete or modify extra backup targets except `default`. | ||
- backup target controller needs to synchronize the data from the extra backup target created. | ||
- backup target controller needs to delete the data in the cluster related the extra backup target deleted. | ||
2. Introduce new fields `BackupTargetURL` in `Spec` and `BackupTargetName` in `Status` of both BackupVolume and Backup CRDs to keep backup target information. | ||
|
||
### User Stories | ||
|
||
User can setup the default backup target as usual on the page `Setting/General` and create extra backup targets on the page `Settings/Backup Target` or create/modify backup targets by the manifest. After extra backup targets created and synchronized, users can start to create a backup on these remote backup targets. | ||
|
||
### User Experience In Detail | ||
|
||
#### Create Or Modify Backup Targets By UI | ||
|
||
1. User can find the link `Backup Target` in drop down menu of `Setting`. | ||
2. We have a default backup target on the page `Backup Target` and it would show its name, backup target url, secret name for this backup target (credential), poll interval and availability status. | ||
3. User can create a new backup target on the page `Backup Target` by clicking the button `Create`. | ||
4. User have to fill out the necessary items for backup target name and url, and secret(credential) name, poll interval can be optional. | ||
5. User can click the button `Edit` to modify the backup target information. | ||
|
||
#### Create Or Modify Backup Targets By CLI | ||
|
||
User can the bash command to create or modify a backup target such as below: | ||
|
||
```bash | ||
cat <<EOF >>new-backup-target.yaml | ||
apiVersion: longhorn.io/v1beta2 | ||
kind: BackupTarget | ||
metadata: | ||
name: azure-blob-server-001 | ||
namespace: longhorn-system | ||
spec: | ||
backupTargetURL: azblob://demo@core.windows.net/ | ||
credentialSecret: azblob-secret | ||
pollInterval: 4m30s | ||
status: | ||
default: true | ||
EOF | ||
|
||
kubectl apply -f new-backup-target.yaml | ||
``` | ||
|
||
#### Create A Backup To Remote Backup Targets By UI | ||
|
||
After users click the button `Create Backup` on the `Volume Details` page, they can choose multiple backup targets they just created by checkboxes to create backups on backup targets. | ||
|
||
#### Create A Backup To Remote Backup Targets By CLI | ||
|
||
1. Create a snapshot of the volume first | ||
2. Create backups for each backup target you want to store the snapshot by the manifest as below: | ||
|
||
```txt | ||
apiVersion: longhorn.io/v1beta2 | ||
kind: Backup | ||
metadata: | ||
labels: | ||
backup-volume: pvc-xxxxxxxx-9ab9-4055-9eb4-558999b09a11 | ||
name: backup-test-001 | ||
namespace: longhorn-system | ||
spec: | ||
backupTarget: azure-blob-server-001 | ||
labels: | ||
longhorn.io/volume-access-mode: rwo | ||
snapshotName: xxxxxxxx-9a69-4ede-ab88-c9853459462c | ||
status: | ||
default: true | ||
``` | ||
|
||
#### Restore From A Backup From A Remote Backup Target | ||
|
||
Restoring from a backup will behave as before. Choose a backup and do the `Restore` operation in drop down menu on UI. | ||
|
||
### API changes | ||
|
||
- Introduce new APIs `BackupTargetCreate`,`BackupTargetDelete` and `BackupTargetGet`: | ||
|
||
| API | Input | Output | Comments | HTTP Endpoint | | ||
| --- | --- | --- | --- | --- | | ||
| Create | name, backupTargetURL, credentialSecret string, pollInterval time.Duration, default boolean | err error | Create a new backup target and start to synchronize data | **POST** `/v1/backuptargets/{backupTargetName}` | | ||
| Delete | name string | err error | Remove a backup target and its related backup volume and backup CR objects in the cluster | **DELETE** `/v1/backuptargets/{backupTargetName}` | | ||
| Get | | backupTarget BackupTarget, err error | Get the backup targets information | **GET** `/v1/backuptargets/{backupTargetName}` | | ||
| Update | backupTargetURL, credentialSecret string, pollInterval time.Duration, default boolean | err error | Update the backup targets information | **PUT** `/v1/backuptargets/{backupTargetName}` | | ||
|
||
- Modify the APIs `BackupVolumeGet`, `BackupVolumeList`: | ||
- Add new fields `BackupTargetName` and `VolumeName` in returning `BackupVolume` information. | ||
- Modify the APIs `BackupCreate`, `BackupGet`: | ||
- Add a new field `BackupTargetName` in returning `Backup` information. | ||
|
||
## Design | ||
|
||
### Implementation Overview | ||
|
||
#### CRDs | ||
|
||
1. Modify the Backup CRD `backups.longhorn.io` to add new fields `BackupTargetURL` in `Spec` and `BackupTargetName` in `Status`. | ||
|
||
```yaml | ||
metadata: | ||
name: the backup name. (string) | ||
spec: | ||
backupTargetURL: the backup target URL. (string) | ||
status: | ||
backupTargetName: the backup target Name. (string) | ||
``` | ||
2. Modify the Backup Volume CRD `backupvolumes.longhorn.io` to add new fields `BackupTargetURL` and `VolumeName` in `Spec` and `BackupTargetName` in `Status`. | ||
|
||
```yaml | ||
metadata: | ||
name: the backup name. (string) | ||
spec: | ||
backupTargetURL: the backup target URL. (string) | ||
volumeName: the volume name for backups. (string) | ||
status: | ||
backupTargetName: the backup target Name. (string) | ||
``` | ||
|
||
3. Modify the Backup Target CRD `backuptagets.longhorn.io` to add a new fields `Default` in `Status`. | ||
|
||
```yaml | ||
metadata: | ||
name: the backup name. (string) | ||
... | ||
status: | ||
default: the backup target is default or not. (boolean) | ||
``` | ||
|
||
#### Backup Related Controllers | ||
|
||
1. Remove `default` backup target from the setting controller. | ||
|
||
2. Modify backup target controller to allow to add and delete a extra backup target. | ||
|
||
- Clean up backup volume CR objects in the cluster by label `backup-target` when deleting a backup target. | ||
- Create a pulling backup volume from the backup target by the backup volume name `volumeName` + `-` + `backupTarget.Name` and adding a label `backup-target` with the backup target URL. | ||
- Get backup volume CR objects in the cluster by label `backup-target` with the backup target URL. | ||
|
||
3. Modify backup volume controller to tell which backup volume belongs to which backup target and synchronize the backups of the backup volume from remote backup target. | ||
|
||
- Clean up backup CR objects in the cluster by the volume name `backupVolume.Spec.volumeName` and `backupVolume.Spec.backupTargetURL` when deleting a backup volume. | ||
- Create a pulling backup from the backup target by the volume name `backupVolume.Spec.volumeName` and `backupVolume.Spec.backupTargetURL`. | ||
|
||
### Test plan | ||
|
||
1. Setup the default backup target. | ||
2. Create a backup to default backup target and it succeeds. | ||
3. Setup an extra old backup target. | ||
4. Backups created with default backup target will not be deleted. | ||
5. Backups on the extra old backup target can be synchronized. | ||
6. Create a backup to extra backup target and it succeeds. | ||
7. Restore a backup from default remote backup target, and it succeeds and data is correct. | ||
8. Restore a backup from the extra remote backup target, and it succeeds and data is correct. | ||
|
||
### Upgrade strategy | ||
|
||
1. Fill in fields `BackupTargetURL` in `Spec` and `BackupTargetName` in `Status` for backup CR objects with corresponding values. | ||
2. Fill in fields `BackupTargetURL` and `VolumeName` in `Spec` and `BackupTargetName` in `Status` for backup volume CR objects with corresponding values. | ||
|
||
## Note [optional] | ||
|
||
`None` |