-
Notifications
You must be signed in to change notification settings - Fork 367
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
Conversation
Signed-off-by: Igor Cezar <[email protected]>
Signed-off-by: Igor Cezar <[email protected]>
Signed-off-by: Igor Cezar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works as expected! Thanks for the correction.
charts/velero/values.yaml
Outdated
@@ -72,6 +72,12 @@ metrics: | |||
# Install CRDs as a templates. Enabled by default. | |||
installCRDs: true | |||
|
|||
# Enable/disable helm hooks annotations for Helm v2 in CRDs and/or templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I say ArgoCD uses helm v2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ArgoCD uses only Helm v2 until v1.4. Starting in v1.5 it has both v2 and v3, using v3 when Chart.yaml apiVersion is v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, since we're using apiVersion: v1
https://github.com/vmware-tanzu/helm-charts/blob/c90e413/charts/velero/Chart.yaml#L1, so the ArgoCD would use helm v2 behavior even we use ArgoCD version >= 1.5, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s right!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly, if you want to provide your own values.yaml for this chart for the helm install you need to build your own chart which has this one as a dependency. Which results in usually helm v3 being the actual engine.
This is because argocd requires the source of both helm chart and altered values.yaml to be in the same repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly, if you want to provide your own values.yaml for this chart for the helm install you need to build your own chart which has this one as a dependency. Which results in usually helm v3 being the actual engine.
This is because argocd requires the source of both helm chart and altered values.yaml to be in the same repository.
I use it that way, with velero chart as a dependency, and ArgoCD also uses Helm v2. For Helm v3 I have to change Chart.yaml apiVersion of the chart that I build (the one which imports velero chart) to v2, or force ArgoCD to use Helm v3 as described here.
@simran3695, @fabianmet could you please take a look a this 🙇 ? It seems to fix #158. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual issue arises because if you install this chart with helm v3 the pre-install pre-sync hooks are also triggered on the CRD's in the CRD directory.
This causes the state to be dropped by ArgoCD because a hook has no state. It is a one off job.
The only way to fix this is either remove the hook notations in the CRD directory all together, or change them back to the helm hook for crd-install.
I understand you want this helm chart to keep the CRD's in line with your actual helm velero installation but this goes against what helm themselves say as explained here.
I tried the same approach as @igorcezar did in this PR but it did not solve the issue where the CRD's were installed but constantly in a bad state because of the pre-install pre-sync hooks still being present on the CRD's themselves.
Also its a shame but the CRD directory does not treat files as templates, so there is no way to properly disable helm hooks in the CRD files.
Having the option to see what changes in a CRD is really helpful for upgrade purposes. So im a big fan of having them available easily in git instead of having velero themselves generate it but that is my opinion.
charts/velero/values.yaml
Outdated
@@ -72,6 +72,12 @@ metrics: | |||
# Install CRDs as a templates. Enabled by default. | |||
installCRDs: true | |||
|
|||
# Enable/disable helm hooks annotations for Helm v2 in CRDs and/or templates |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not exactly, if you want to provide your own values.yaml for this chart for the helm install you need to build your own chart which has this one as a dependency. Which results in usually helm v3 being the actual engine.
This is because argocd requires the source of both helm chart and altered values.yaml to be in the same repository.
Signed-off-by: Igor Cezar <[email protected]>
In this PR we remove hook notations from templates/crds.yaml and the CR's templates, which for ArgoCD solves the problem, since it uses Helm v2 if you don't change the chart apiVersion to v2. But for sure the best solution would be to also remove from CRD folder so ArgoCD can work even using Helm v3. @jenting the hook notations were included in CRD directory just for templates/crds.yaml could import the crds with the hooks, right? |
I think so.
Not sure what you'd like to remove? The helm annotation or CRD folder? |
The helm annotation in all *.yaml of CRD folder. |
Signed-off-by: Igor Cezar <[email protected]>
Signed-off-by: Igor Cezar <[email protected]>
@jenting I have pushed the changes I was talking about. With this, the chart works for ArgoCD with Helm v2 (setting enableHelmHooks: false) and Helm v3 ( no matter how enableHelmHooks is set, but the preference is set to false, so that BSL/VSL/Schedule don't become Post Sync hooks). Also works with helm install for both versions too (tested with helm v2.15.2 and v3.1.2), with enableHelmHooks: true (which is the default). |
I want to play ArgoCD so I'll review this PR slowly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@igorcezar could you please address the comments and fix the conflicts? thank you.
charts/velero/values.yaml
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I don't think it's for helm2 only, these helm hooks also available on helm3
- maybe we could mention the deploy tool ArgoCD to help people easier to understand when to disable helm hooks annotations.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Signed-off-by: Igor Cezar <[email protected]> Remove whitespaces Signed-off-by: Igor Cezar <[email protected]>
0739463
to
da91321
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you
Any news on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, did not see any issues
thanks!
Special notes for your reviewer:
Create an option in values to disable helm hooks used in CRDs (for Helm v2) and templates manifest (like BackupStorageLocation), introduced in #109 and #153.
With this change it's possible to install this chart using ArgoCD without any problems, setting the new option to false:
It's possible to disable only CRD hooks or template hooks, in case you don't want to disable both.
The default option is true, which enables all helm hooks.
Helm hooks in crds folder, for Helm v3, are untouched, because they can't be templated.
Fix #158
Checklist
[velero]
)