Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[velero] Add support for multiple backupstoragelocations and volumesnapshotlocations #413

Merged
merged 29 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0a8b806
Add support for multiple backupstoragelocations and volumesnapshotloc…
bsteinm2 Oct 25, 2022
27b8cbe
Make BSL and VSL templates backwards compatible
bsteinm2 Jan 5, 2023
52b5c0b
Merge branch 'main' into multiplebackupstoragelocations
bsteinm2 Jan 5, 2023
7bd0609
Merge branch 'main' into multiplebackupstoragelocations
bsteinm2 Jan 18, 2023
761ecd6
Make BSL and VSL templates backwards compatible and preserve the defa…
bsteinm2 Jan 20, 2023
0574616
Delete .DS_Store
bsteinm2 Jan 20, 2023
c10dc76
Delete .DS_Store
bsteinm2 Jan 20, 2023
9aa0ac5
Fix ci lint failure
jenting Jan 20, 2023
ff17021
fix accessMode rendering
bsteinm2 Jan 30, 2023
c314596
Merge branch 'multiplebackupstoragelocations' of https://github.com/b…
bsteinm2 Jan 31, 2023
3d7a757
Merge branch 'main' into multiplebackupstoragelocations
jenting Jan 31, 2023
a4cffb9
put values file back
bsteinm2 Feb 1, 2023
993d48a
Merge branch 'multiplebackupstoragelocations' of https://github.com/b…
bsteinm2 Feb 1, 2023
247af70
remove configuration.provider
bsteinm2 Mar 29, 2023
866613d
Merge branch 'main' into multiplebackupstoragelocations
bsteinm2 Mar 29, 2023
0fff772
add logic for BSL and VSL names
bsteinm2 Mar 31, 2023
ebcf1b3
remove names logic
bsteinm2 Apr 4, 2023
4ac8258
update ct values
bsteinm2 Apr 5, 2023
8c06bdc
fix test values for BSL credential
bsteinm2 Apr 6, 2023
ad0ee24
add BSL provider to test values
bsteinm2 Apr 6, 2023
7e9cd3b
move accessmode logic to helpers
bsteinm2 Apr 7, 2023
c2bc00c
Merge branch 'main' into multiplebackupstoragelocations
bsteinm2 Apr 7, 2023
5f4e471
fix: set credential when it's configured
jenting Apr 25, 2023
258c9f9
Merge branch 'main' into multiplebackupstoragelocations
jenting Apr 25, 2023
abb0b16
ci: test multiple BSL/VSL
jenting Apr 25, 2023
3520057
fix: fix linter error
jenting Apr 25, 2023
ba176c1
ci: only support one default BSL
jenting Apr 25, 2023
a57f7f8
doc: update README
jenting Apr 25, 2023
fe67c0d
chore: add error message when the BSL/VSL configures as map
jenting Apr 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/velero/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ appVersion: 1.11.0
kubeVersion: ">=1.16.0-0"
description: A Helm chart for velero
name: velero
version: 3.2.0
version: 4.0.0
home: https://github.com/vmware-tanzu/velero
icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png
sources:
Expand Down
13 changes: 7 additions & 6 deletions charts/velero/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ helm install velero vmware-tanzu/velero \
--namespace <YOUR NAMESPACE> \
--create-namespace \
--set-file credentials.secretContents.cloud=<FULL PATH TO FILE> \
--set configuration.provider=<PROVIDER NAME> \
--set configuration.backupStorageLocation.name=<BACKUP STORAGE LOCATION NAME> \
--set configuration.backupStorageLocation.bucket=<BUCKET NAME> \
--set configuration.backupStorageLocation.config.region=<REGION> \
--set configuration.volumeSnapshotLocation.name=<VOLUME SNAPSHOT LOCATION NAME> \
--set configuration.volumeSnapshotLocation.config.region=<REGION> \
--set configuration.backupStorageLocation[0].name=<BACKUP STORAGE LOCATION NAME> \
--set configuration.backupStorageLocation[0].provider=<PROVIDER NAME> \
--set configuration.backupStorageLocation[0].bucket=<BUCKET NAME> \
--set configuration.backupStorageLocation[0].config.region=<REGION> \
--set configuration.volumeSnapshotLocation[0].name=<VOLUME SNAPSHOT LOCATION NAME> \
--set configuration.volumeSnapshotLocation[0].provider=<PROVIDER NAME> \
--set configuration.volumeSnapshotLocation[0].config.region=<REGION> \
--set initContainers[0].name=velero-plugin-for-<PROVIDER NAME> \
--set initContainers[0].image=velero/velero-plugin-for-<PROVIDER NAME>:<PROVIDER PLUGIN TAG> \
--set initContainers[0].volumeMounts[0].mountPath=/target \
Expand Down
25 changes: 19 additions & 6 deletions charts/velero/ci/test-values.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
# Set provider name and backup storage location bucket name
configuration:
provider: aws
backupStorageLocation:
name: primary
bucket: velero
- name: backups-primary
bucket: velero-backups
default: true
provider: aws
credential:
name: test-credential
key: test-key
config:
region: us-east-1
profile: us-east-1-profile
- name: backups-secondary
bucket: velero-backups
provider: aws
config:
region: us-west-1
profile: test
profile: us-west-1-profile
volumeSnapshotLocation:
- name: ebs-us-east-1
provider: aws
config:
bucket: velero
region: us-west-1
region: us-east-1
- name: portworx-cloud
provider: portworx
config:
type: cloud

schedules:
mybackup:
Expand Down
12 changes: 12 additions & 0 deletions charts/velero/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ More info on the official site: https://velero.io/docs
{{- $breaking_title = print $breaking_title "\n###### the `helm template` command. #####" }}
{{- $breaking_title = print $breaking_title "\n#################################################################################" }}

{{- if typeIs "map[string]interface {}" .Values.configuration.backupStorageLocation }}
{{- $breaking = print $breaking "\n\nERROR: Please make .configuration.backupStorageLocation from map to slice" }}
{{- end }}

{{- if typeIs "map[string]interface {}" .Values.configuration.volumeSnapshotLocation }}
{{- $breaking = print $breaking "\n\nERROR: Please make .configuration.volumeSnapshotLocation from map to slice" }}
{{- end }}

{{- if hasKey .Values.configuration "provider" }}
{{- $breaking = print $breaking "\n\nREMOVED: .configuration.provider has been removed, instead each backupStorageLocation and volumeSnapshotLocation has a provider configured" }}
{{- end }}

{{- if hasKey .Values "resticTimeout" }}
{{- $breaking = print $breaking "\n\nREMOVED: resticTimeout has been removed, and it is named fsBackupTimeout" }}
{{- end }}
Expand Down
36 changes: 0 additions & 36 deletions charts/velero/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,42 +75,6 @@ Create the node-Agent priority class name.
{{- end -}}
{{- end -}}

{{/*
Create the backup storage location name
*/}}
{{- define "velero.backupStorageLocation.name" -}}
{{- with .Values.configuration.backupStorageLocation -}}
{{ default "default" .name }}
{{- end -}}
{{- end -}}

{{/*
Create the backup storage location provider
*/}}
{{- define "velero.backupStorageLocation.provider" -}}
{{- with .Values.configuration -}}
{{ default .provider .backupStorageLocation.provider }}
{{- end -}}
{{- end -}}

{{/*
Create the volume snapshot location name
*/}}
{{- define "velero.volumeSnapshotLocation.name" -}}
{{- with .Values.configuration.volumeSnapshotLocation -}}
{{ default "default" .name }}
{{- end -}}
{{- end -}}

{{/*
Create the volume snapshot location provider
*/}}
{{- define "velero.volumeSnapshotLocation.provider" -}}
{{- with .Values.configuration -}}
{{ default .provider .volumeSnapshotLocation.provider }}
{{- end -}}
{{- end -}}

{{/*
Kubernetes version
Built-in object .Capabilities.KubeVersion.Minor can provide non-number output
Expand Down
33 changes: 23 additions & 10 deletions charts/velero/templates/backupstoragelocation.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
{{- if .Values.backupsEnabled }}

{{- if typeIs "[]interface {}" .Values.configuration.backupStorageLocation }}
{{- range .Values.configuration.backupStorageLocation }}
---
apiVersion: velero.io/v1
kind: BackupStorageLocation
metadata:
name: {{ include "velero.backupStorageLocation.name" . }}
namespace: {{ .Release.Namespace }}
name: {{ .name | default "default" }}
namespace: {{ $.Release.Namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation
labels:
app.kubernetes.io/name: {{ include "velero.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "velero.chart" . }}
app.kubernetes.io/name: {{ include "velero.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
helm.sh/chart: {{ include "velero.chart" $ }}
spec:
provider: {{ include "velero.backupStorageLocation.provider" . }}
{{- with .Values.configuration.backupStorageLocation.default }}
{{- if not (empty .credential) }}
credential:
{{- with .credential.name }}
name: {{ . }}
{{- end }}
{{- with .credential.key }}
key: {{ . }}
{{- end }}
{{- end }}
provider: {{ .provider }}
accessMode: {{ .accessMode | default "ReadWrite" }}
{{- with .default }}
default: {{ . }}
{{- end }}
accessMode: {{ .Values.configuration.backupStorageLocation.accessMode }}
{{- with .Values.configuration.backupStorageLocation }}
objectStorage:
bucket: {{ .bucket | quote }}
{{- with .prefix }}
Expand All @@ -35,3 +47,4 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- end }}
22 changes: 14 additions & 8 deletions charts/velero/templates/volumesnapshotlocation.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
{{- if .Values.snapshotsEnabled }}

{{- if typeIs "[]interface {}" .Values.configuration.volumeSnapshotLocation }}
{{- range .Values.configuration.volumeSnapshotLocation }}
---
apiVersion: velero.io/v1
kind: VolumeSnapshotLocation
metadata:
name: {{ include "velero.volumeSnapshotLocation.name" . }}
namespace: {{ .Release.Namespace }}
name: {{ .name | default "default" }}
namespace: {{ $.Release.Namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-delete-policy": before-hook-creation
labels:
app.kubernetes.io/name: {{ include "velero.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "velero.chart" . }}
app.kubernetes.io/name: {{ include "velero.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
helm.sh/chart: {{ include "velero.chart" $ }}
spec:
provider: {{ include "velero.volumeSnapshotLocation.provider" . }}
{{- with .Values.configuration.volumeSnapshotLocation.config }}
provider: {{ .provider }}
{{- with .config }}
config:
{{- range $key, $value := . }}
{{- $key | nindent 4 }}: {{ $value | quote }}
{{- end }}
{{- end -}}
{{- end }}
{{- end }}
{{- end }}
21 changes: 12 additions & 9 deletions charts/velero/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,12 @@ cleanUpCRDs: false
## and additional server settings.
##
configuration:
# Cloud provider being used (e.g. aws, azure, gcp).
provider:

# Parameters for the `default` BackupStorageLocation. See
# https://velero.io/docs/v1.6/api-types/backupstoragelocation/
# Parameters for the BackupStorageLocation(s). Configure multiple by adding other element(s) to the backupStorageLocation slice.
# See https://velero.io/docs/v1.6/api-types/backupstoragelocation/
backupStorageLocation:
# name is the name of the backup storage location where backups should be stored. If a name is not provided,
# a backup storage location will be created with the name "default". Optional.
name:
- name:
# provider is the name for the backup storage location provider. If omitted
# `configuration.provider` will be used instead.
provider:
Expand All @@ -256,6 +253,11 @@ configuration:
# accessMode determines if velero can write to this backup storage location. Optional.
# default to ReadWrite, ReadOnly is used during migrations and restores.
accessMode: ReadWrite
credential:
# name of the secret used by this backupStorageLocation.
name:
# name of key that contains the secret data to be used.
key:
# Additional provider-specific configuration. See link above
# for details of required/optional fields for your provider.
config: {}
Expand All @@ -275,11 +277,11 @@ configuration:
# flag. For Velero client Command like velero backup describe, velero backup logs needs to add the flag --insecure-skip-tls-verify
# insecureSkipTLSVerify:

# Parameters for the `default` VolumeSnapshotLocation. See
# https://velero.io/docs/v1.6/api-types/volumesnapshotlocation/
# Parameters for the VolumeSnapshotLocation(s). Configure multiple by adding other element(s) to the volumeSnapshotLocation slice.
# See https://velero.io/docs/v1.6/api-types/volumesnapshotlocation/
volumeSnapshotLocation:
# name is the name of the volume snapshot location where snapshots are being taken. Required.
name:
- name:
# provider is the name for the volume snapshot provider. If omitted
# `configuration.provider` will be used instead.
provider:
Expand Down Expand Up @@ -499,6 +501,7 @@ nodeAgent:
# useOwnerReferencesInBackup: false
# template:
# ttl: "240h"
# storageLocation: default
# includedNamespaces:
# - foo
schedules: {}
Expand Down