Skip to content

Commit

Permalink
Back compat for schedules.
Browse files Browse the repository at this point in the history
A touch less graceful than I'd like but it does work.

Signed-off-by: W. Kavanaugh Latiolais <[email protected]>
  • Loading branch information
kav committed Oct 26, 2020
1 parent 4d2343d commit 26d1a8a
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 5 deletions.
7 changes: 7 additions & 0 deletions charts/velero/ci/test-values-back-compat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ serviceAccount:
server:
name: velero

schedules:
mybackup:
schedule: "0 0 * * *"
template:
ttl: "240h"
includedNamespaces:
- foo
# Whether or not to clean up CustomResourceDefintions when deleting a release.
# Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured.
# Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will.
Expand Down
7 changes: 7 additions & 0 deletions charts/velero/ci/test-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ serviceAccount:
server:
name: velero

schedules:
- name: mybackup
schedule: "0 0 * * *"
template:
ttl: "240h"
includedNamespaces:
- foo
# Whether or not to clean up CustomResourceDefintions when deleting a release.
# Cleaning up CRDs will delete the BackupStorageLocation and VolumeSnapshotLocation instances, which would have to be reconfigured.
# Backup data in object storage will _not_ be deleted, however Backup instances in the Kubernetes API will.
Expand Down
34 changes: 32 additions & 2 deletions charts/velero/templates/schedule.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{{- if kindIs "slice" .Values.schedules -}}
{{- range .Values.schedules }}
apiVersion: velero.io/v1
kind: Schedule
metadata:
name: {{ include "velero.fullname" $ }}-{{ .name }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"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" $ }}
{{- if $.Values.scheduleLabels }}
{{- toYaml $.Values.scheduleLabels | nindent 4 }}
{{- if .labels }}
{{- toYaml .labels | nindent 4 }}
{{- end }}
spec:
schedule: {{ .schedule | quote }}
Expand All @@ -18,4 +22,30 @@ spec:
{{- toYaml . | nindent 4 }}
{{- end }}
---
{{- end -}}
{{- else -}}
{{- range $scheduleName, $schedule := .Values.schedules }}
apiVersion: velero.io/v1
kind: Schedule
metadata:
name: {{ include "velero.fullname" $ }}-{{ $scheduleName }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"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" $ }}
{{- if $schedule.labels }}
{{- toYaml $schedule.labels | nindent 4 }}
{{- end }}
spec:
schedule: {{ $schedule.schedule | quote }}
{{- with $schedule.template }}
template:
{{- toYaml . | nindent 4 }}
{{- end }}
---
{{- end }}
{{- end -}}
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,22 @@ manifest should match snapshot:
bucket: velero
region: us-west-1
provider: aws
5: |
apiVersion: velero.io/v1
kind: Schedule
metadata:
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-delete-policy: before-hook-creation
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: RELEASE-NAME-velero-mybackup
spec:
schedule: 0 0 * * *
template:
includedNamespaces:
- foo
ttl: 240h
19 changes: 19 additions & 0 deletions charts/velero/tests/__snapshot__/snapshot__test.yaml.snap
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,22 @@ manifest should match snapshot:
bucket: velero
region: us-west-1
provider: aws
5: |
apiVersion: velero.io/v1
kind: Schedule
metadata:
annotations:
helm.sh/hook: post-install,post-upgrade
helm.sh/hook-delete-policy: before-hook-creation
labels:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Tiller
app.kubernetes.io/name: velero
helm.sh/chart: velero-2.14.0
name: RELEASE-NAME-velero-mybackup
spec:
schedule: 0 0 * * *
template:
includedNamespaces:
- foo
ttl: 240h
1 change: 1 addition & 0 deletions charts/velero/tests/back-compat-snapshot_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ templates:
- backupstoragelocation.yaml
- restic-daemonset.yaml
- volumesnapshotlocation.yaml
- schedule.yaml
tests:
- it: manifest should match snapshot
values:
Expand Down
1 change: 1 addition & 0 deletions charts/velero/tests/snapshot__test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ templates:
- backupstoragelocation.yaml
- restic-daemonset.yaml
- volumesnapshotlocation.yaml
- schedule.yaml
tests:
- it: manifest should match snapshot
values:
Expand Down
6 changes: 3 additions & 3 deletions charts/velero/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,13 @@ restic:
# Backup schedules to create.
# Eg:
# schedules:
# name: mybackup
# - name: mybackup
# schedule: "0 0 * * *"
# template:
# ttl: "240h"
# includedNamespaces:
# - foo
schedules: []
# schedules: []

scheduleLabels: {}

Expand All @@ -287,7 +287,7 @@ configMaps: {}
## End of additional Velero resource settings.
##

# Depricated configuration key
# Deprecated
configuration:
backupStorageLocation: {}
volumeSnapshotLocation: {}

0 comments on commit 26d1a8a

Please sign in to comment.