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 enable/disable option for helm hooks #171

Merged
merged 10 commits into from
Nov 18, 2020
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.1
description: A Helm chart for velero
name: velero
version: 2.13.3
version: 2.13.4
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: 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
8 changes: 8 additions & 0 deletions charts/velero/templates/crds.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{{- if and .Values.installCRDs (eq .Release.Service "Tiller") }}
{{- range $path, $bytes := .Files.Glob "crds/*.yaml" }}
{{- if $.Values.enableHelmHooks }}
{{ $.Files.Get $path }}
{{- else }}
{{- range $.Files.Lines $path }}
{{- if not ( contains "helm.sh/hook" . ) }}
{{ . }}
{{- 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
4 changes: 4 additions & 0 deletions charts/velero/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ metrics:
# Install CRDs as a templates. Enabled by default.
installCRDs: true

# Enable/disable helm hooks annotations for CRDs (Helm v2) and templates
# You should disable this if using a deploy tool that doesn't support helm hooks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I don't think it's for helm2 only, these helm hooks also available on helm3
  2. maybe we could mention the deploy tool ArgoCD to help people easier to understand when to disable helm hooks annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CRDs it was helm2 only, because in helm3 CRDs can't be templated, but for all else it was for both v2 and v3.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For CRDs it was helm2 only, because in helm3 CRDs can't be templated, but for all else it was for both v2 and v3.

helm template vmware-tanzu/velero --include-crds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooks are available for Helm3, but in this chart the option enableHelmHooks will only enable/disable helm hooks for helm2 CRDs (templates/crds.yaml) and for all other templates on both versions.
I've made the changes in the comments and chart version.

enableHelmHooks: true

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