diff --git a/charts/velero/templates/_helpers.tpl b/charts/velero/templates/_helpers.tpl index 3ac184e6..52eb4553 100644 --- a/charts/velero/templates/_helpers.tpl +++ b/charts/velero/templates/_helpers.tpl @@ -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 -}} diff --git a/charts/velero/templates/crds.yaml b/charts/velero/templates/crds.yaml index 3cceae1d..4a92f8d7 100644 --- a/charts/velero/templates/crds.yaml +++ b/charts/velero/templates/crds.yaml @@ -1,10 +1,13 @@ {{- if and .Values.installCRDs (eq .Release.Service "Tiller") }} {{- range $path, $bytes := .Files.Glob "crds/*.yaml" }} -{{- if $.Values.enableHelmHooks }} +{{- if not $.Values.enableHelmHooks }} {{ $.Files.Get $path }} {{- else }} {{- range $.Files.Lines $path }} -{{- if not ( contains "helm.sh/hook" . ) }} +{{- if contains "annotations:" . }} +{{ . }} +{{ template "velero.helmhooks.crds" . }} +{{- else }} {{ . }} {{- end }} {{- end }}