Skip to content

Commit

Permalink
[velero] Add enable/disable option for helm hooks (#171)
Browse files Browse the repository at this point in the history
* Add enable/disable option for helm hooks
* Adjust crds.yaml
* Make one variable for all hooks
* Remove all helm hooks in crds folder
* Add Helm v2 hooks for CRDs from _helpers template
* Bump chart version and change hook comments

Signed-off-by: Igor Cezar <[email protected]>
  • Loading branch information
igorcezar authored Nov 18, 2020
1 parent 1a420ff commit 0fc0edc
Show file tree
Hide file tree
Showing 18 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion charts/velero/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v1
appVersion: 1.5.2
description: A Helm chart for velero
name: velero
version: 2.13.6
version: 2.13.7
home: https://github.com/vmware-tanzu/velero
icon: https://cdn-images-1.medium.com/max/1600/1*-9mb3AKnKdcL_QD3CMnthQ.png
sources:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/backups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: velero
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: backups.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/backupstoragelocations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: backupstoragelocations.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/deletebackuprequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: deletebackuprequests.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/downloadrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: downloadrequests.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/podvolumebackups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: podvolumebackups.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/podvolumerestores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: podvolumerestores.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/resticrepositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: resticrepositories.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/restores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: velero
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: restores.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/schedules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,post-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: schedules.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/serverstatusrequests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: serverstatusrequests.velero.io
spec:
Expand Down
2 changes: 0 additions & 2 deletions charts/velero/crds/volumesnapshotlocations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
labels:
app.kubernetes.io/name: "velero"
annotations:
"helm.sh/hook": pre-install,pre-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
controller-gen.kubebuilder.io/version: v0.3.0
name: volumesnapshotlocations.velero.io
spec:
Expand Down
8 changes: 8 additions & 0 deletions charts/velero/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,11 @@ Create the volume snapshot location provider
{{ default .provider .volumeSnapshotLocation.provider }}
{{- end -}}
{{- end -}}

{{/*
Helm hooks for Helm v2 CRDs
*/}}
{{- define "velero.helmhooks.crds" -}}
{{ print "\"helm.sh/hook\": pre-install,pre-upgrade" | indent 4 }}
{{ print "\"helm.sh/hook-delete-policy\": \"before-hook-creation\"" | indent 4 }}
{{- end -}}
2 changes: 2 additions & 0 deletions charts/velero/templates/backupstoragelocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ kind: BackupStorageLocation
metadata:
name: {{ include "velero.backupStorageLocation.name" . }}
annotations:
{{- if .Values.enableHelmHooks }}
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
{{- end }}
labels:
app.kubernetes.io/name: {{ include "velero.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
11 changes: 11 additions & 0 deletions charts/velero/templates/crds.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{{- if and .Values.installCRDs (eq .Release.Service "Tiller") }}
{{- range $path, $bytes := .Files.Glob "crds/*.yaml" }}
{{- if not $.Values.enableHelmHooks }}
{{ $.Files.Get $path }}
{{- else }}
{{- range $.Files.Lines $path }}
{{- if contains "annotations:" . }}
{{ . }}
{{ template "velero.helmhooks.crds" . }}
{{- else }}
{{ . }}
{{- end }}
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
2 changes: 2 additions & 0 deletions charts/velero/templates/schedule.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ kind: Schedule
metadata:
name: {{ include "velero.fullname" $ }}-{{ $scheduleName }}
annotations:
{{- if $.Values.enableHelmHooks }}
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
{{- end }}
labels:
app.kubernetes.io/name: {{ include "velero.name" $ }}
app.kubernetes.io/instance: {{ $.Release.Name }}
Expand Down
2 changes: 2 additions & 0 deletions charts/velero/templates/volumesnapshotlocation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ kind: VolumeSnapshotLocation
metadata:
name: {{ include "velero.volumeSnapshotLocation.name" . }}
annotations:
{{- if .Values.enableHelmHooks }}
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": "before-hook-creation"
{{- end }}
labels:
app.kubernetes.io/name: {{ include "velero.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
5 changes: 5 additions & 0 deletions charts/velero/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ metrics:
# Install CRDs as a templates. Enabled by default.
installCRDs: true

# Enable/disable all helm hooks annotations
# You should disable this if using a deploy tool that doesn't support helm hooks,
# such as ArgoCD
enableHelmHooks: true

##
## End of deployment-related settings.
##
Expand Down

0 comments on commit 0fc0edc

Please sign in to comment.