-
Notifications
You must be signed in to change notification settings - Fork 191
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
Add reconcile strategy for HelmCharts #308
Conversation
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.
Helm has a strict SemVer requirement for charts since v3.5.2.
Instead of using the revision of the source, we should probably create a valid SemVer using the allowed build metadata, e.g v0.1.0-alpha+<commit SHA>
. Using the full revision is not possible as:
Identifiers MUST comprise only ASCII alphanumerics and hyphens [0-9A-Za-z-].
– SemVer spec
This change also requires a documentation update, as the migration guide currently states that this Helm Operator-like feature is no longer supported.
Have I misunderstood how revision works? I'm not attempting to change the The tarball from a apiVersion: v2
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 10.3.13
description: A Helm chart for an app
home: https://github.com/example/charts/tree/main/my-app
name: my-app
type: application
version: 0.1.0 The release looks like: NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
release-name default 4 2021-03-13 00:50:05.404387943 +0000 UTC deployed my-app-0.1.0
Willing to do whatever is necessary if you're willing to accept the feature. 😁 |
You are correct, but I think it would be better to change the SemVer to include the build number than to copy the revision from the |
I am still excited about this contribution, I think the compromise sounds fairly well fleshed out. This will enable many uses of Helm Controller that have been problematic since changing from Helm Operator. |
Would this also support the "ignore version" feature for local chart dependencies? For example, we maintain multiple helm charts in a git repository and they depend on each other using local file references. If we change the |
does it will work also for fluxcd in version 2 ? |
All work done in
If they live in the same repository, then yes. |
Tests are failing so I think this has stopped working and I'll invest a bit more time on it this week. |
After we merge this, we should update the modified lines from fluxcd/flux2#1067 |
@arbourd are you still committed to finishing this PR? |
@hiddeco Yup, just a little burnt out and taking a break. |
Hey @hiddeco I will get back to this, this weekend or next week. Thank you for your patience everyone. |
Awesome, and take your time! I have been chewing myself on things like #361 for ages :-) |
Latest changes:
|
I will do a proper review of changes later, but would it be an idea to rename |
Yup! That shoulda been obvious 😅 |
Got this running in our staging environment nicely 😁 |
Is there plans to get this merged in soon? Really keen to use this feature and it's one of the dependencies my team needs to move to flux2 |
@jack-evans originally the plan was to get this merged after some refactor work (see @arbourd if you take my review comments into consideration, update the documentation in the |
Anything I'm missing from a docs point of view @hiddeco? I've documented the values (consts) similar to other examples, and I have a draft in the real docs which will be more structured. |
Before the weekend update after a long period of waiting. While I was debugging the issue that suddenly popped up in the CI, it became clear that we needed a more permanent, safe and controllable way of building against Thanks for your patience 🌻 |
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.
|
||
version := v.String() | ||
if chart.Spec.ReconcileStrategy == sourcev1.ReconcileStrategyRevision { | ||
// Isolate the commit SHA from GitRepository type artifacts by removing the branch/ prefix. |
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.
We need to extract this in fluxcd/pkg
as it's being used in notification-controller also.
This commit adds a `ReconcileStrategy` field to the `HelmChart` resource, which allows defining when a new chart should be packaged and/or published if it originates from a `Bucket` or `GitRepository` resource. The two available strategies are: - `ChartVersion`: creates a new artifact when the version of the Helm chart as defined in the `Chart.yaml` from the Source is different from the current version. - `Revision`: creates a new artifact when the revision of the Source is different from the current revision. For the `Revision` strategy, the (checksum part of the) revision of the artifact the chart originatesfrom is added as SemVer metadata. A chart from a `GitRepository` with Artifact revision `main/f0faacd5164a875ebdbd9e3fab778f49c5aadbbc` and a chart with e.g. SemVer `0.1.0` will be published as `0.1.0+f0faacd5164a875ebdbd9e3fab778f49c5aadbbc`. A chart from a `Bucket` with Artifact revision `f0faacd5164a875ebdbd9e3fab778f49c5aadbbc` and a chart with e.g. SemVer `0.1.0` will be published as `0.1.0+f0faacd5164a875ebdbd9e3fab778f49c5aadbbc`. Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
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.
Made some tiny changes to the doc blocks and commit message, but the code was all looking OK @arbourd. Thank you very much 🙇
good job guys ! @hiddeco @stefanprodan |
Adds
ReconcileStrategy
option allowing theHelmChart
CRD to use the source's revision (ex:0.1.0+a96eff73a282d408a960086d978ca97a0a1fb2ef
) in place of the Chart version (ex:0.1.0
), by using theRevision
option.ReconcileStrategy
defaults toChartVersion
.This is only applicable to
GitRepository
andBucket
sources asHelmRepository
has a clearly defined contract that Charts are (should be) immutable.This change would allow Flux users to determine if they want to install/upgrade on each change to the source. A more detailed workflow and reasoning as to why is below:
Use Case
We manage a single repository which houses a single chart that manages all microservices. Beside the
./templates
livesvalues-<environment>
for staging, test, dev, etc. Some developers keep their ownvalues-name.yaml
lying around elsewhere. We utilize Helm to its templating-fullest for production workloads and local develop (like bringing up databases in containers).We chose not to package the Helm chart and ship it to a Helm repository. This would serve no purpose and just requires another step. We also chose to place the values files beside the
values.yaml
similar to how Bitnami once did. Currently, we use ArgoCD which uses a similar-toGitRepository
source, templates on each change, and deploys when differences occur.I feel like our use of Helm is optimal for GitOps:
values.yaml
) in Git.values-production.yaml
) in the same Git repository.terraform plan
)values-env.yaml
for changes to image tags.Without this change, Flux requires us to move values out of the Git repository and into other objects (mentioned above) or version the Chart.yaml with every change.
What happens with this change:
ReconcileStrategy
toRevision
GitRepository
changes reconcile with a new revision0.1.0+f0faacd5164a875ebdbd9e3fab778f49c5aadbbc
HelmChart
reconciliation with the revision0.1.0+f0faacd5164a875ebdbd9e3fab778f49c5aadbbc
HelmRelease
reconciliation with revision0.1.0+f0faacd5164a875ebdbd9e3fab778f49c5aadbbc
This has been tested in an environment with a patched helm-controller. Changes to the
HelmRelease
andHelmChart
CRD look like: