-
Notifications
You must be signed in to change notification settings - Fork 26
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
refactor(chart): provide CRDs in a subchart #414
refactor(chart): provide CRDs in a subchart #414
Conversation
ce5a45c
to
de4761b
Compare
Seems the commit lint must have a bug as it's crashing :) @cmontemuino any pros/cons to having the CRD files as a sub-chart, rather than just using a plain crd: true/false and checking for this in the yaml template? @niladrih please take a look at this PR |
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.
@cmontemuino -- I understand if you want to move the csi-snapshot CRDs to the chart/template
directory. What is the motivation for moving them into a subchart? Maybe a new directory inside the template directory would suffice for this use-case?
6621a36
to
c93fde9
Compare
thanks for pointing this out. I've just squashed the offending commit |
@niladrih do you mean adding the Jaeger CRD as a template? |
@tiagolobocastro using Helm 3 approach to install CRDs forces you to upgrade CRDs manually (Helm won't upgrade them if you touch the files). That's problematic when doing GitOps. That said, the main problem here is to avoid installing the Jaeger CRD. It is not possible to template CRDs in the A better approach here would be to publish CRDs in a separate chart. This PR is about applying the minimum required changes. |
c93fde9
to
3117120
Compare
That's right. Something like this: {{- if and .Values.crds.enabled .Values.base.jaeger.enabled .Values.crds.jaeger-}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: jaegers.jaegertracing.io
...
{{- end -}} {{- if and .Values.crds.enabled .Values.crds.volumeSnapshots-}}
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: volumesnapshots.snapshot.storage.k8s.io
...
{{- end -}} chart/
├── crds
└── templates/
└── crds/
├── jaeger.yaml
├── volumesnapshots.yaml
├── volumesnapshotclasses.yaml
└── volumesnapshotcontents.yaml crds:
# Toggle installation for all CRDs. A 'false' disables installation for all.
enabled: true
# Toggle installation for Kubernetes CSI VolumeSnapshot CRDs.
volumeSnapshots: true
# Toggle installation for Jaeger CRD(s).
jaeger: true WDYT @cmontemuino @tiagolobocastro? Is the |
Hi @niladrih! What you proposed could work for this repo.
That said, I don't really know what could happen in the operator is consuming some of the CRDs, especially in the case of an upgrade when removing/adding APIs. There is also the option to use chart hooks, but they don't come free of troubles during upgrades. The following comes from helm best practices around CRDs:
**This is why I've filed issue openebs/mayastor/issues/1586 ** https://helm.sh/docs/chart_best_practices/custom_resource_definitions/#method-2-separate-charts:
This PR is a convenient shortcut if you will. A completely separate chart for CRDs might make more sense. |
@cmontemuino -- Hmm... let me try this out once. The doc seems convincing, I'll spin up a cluster later today. |
@cmontemuino -- Changes look good to me, could you also add a switch for the volumeSnapshot CRDs? crds:
# -- Install CRDs
enabled: true
jaeger:
# -- Install Jaeger CRDs
enabled: false
volumeSnapshots:
enabled: true |
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.
Left few comments.
3117120
to
846d869
Compare
Hi @niladrih, I've addressed all the comments already. |
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.
Left one comment
@cmontemuino -- I see one issue. I've highlighted that above. Otherwise, changes look good to me. I think I'll approve and queue for a merge when you make the change. Thanks! |
I see it now. Thanks! |
5ecab24
to
b11cfe5
Compare
@niladrih -- the PR is ready to go now |
bors merge |
👎 Rejected by too few approved reviews |
bors merge |
414: refactor(chart): provide CRDs in a subchart r=niladrih a=cmontemuino ## Description This changeset is mainly intended to skip Jaeger CRDs if it is not enabled. It is especially relevant when Jaeger tracing is installed separately from OpenEBS Mayastor. Moving CRDs to a chart solves several issues: clean uninstall, possibility for upgrades, templating. ## Motivation and Context Helm 3 does not manage CRDs (see https://helm.sh/docs/chart_best_practices/custom_resource_definitions/). `helm uninstall` won't remove CRDs, and `helm updgrade` won't upgrade them. Manual intervention is required with the current setup. - CRDs installed from `crds` folder **are not included into the helm release**. Additionally, it is not possible to template CRDs in Helm 3 in the `crds` folder. ## Regression <!-- Is this PR fixing a regression? (Yes / No) --> No <!-- If Yes, optionally please include version or commit id or PR# that caused this regression, if you have these details. --> ## How Has This Been Tested? <! Co-authored-by: cmontemuino <1761056+cmontemuino@users.noreply.github.com>
Build failed: |
105e441
to
7571cd6
Compare
@niladrih -- could you please issue |
It failed because of an issue with the helm-doc script. |
This requires #435. |
bors merge |
414: refactor(chart): provide CRDs in a subchart r=niladrih a=cmontemuino ## Description This changeset is mainly intended to skip Jaeger CRDs if it is not enabled. It is especially relevant when Jaeger tracing is installed separately from OpenEBS Mayastor. Moving CRDs to a chart solves several issues: clean uninstall, possibility for upgrades, templating. ## Motivation and Context Helm 3 does not manage CRDs (see https://helm.sh/docs/chart_best_practices/custom_resource_definitions/). `helm uninstall` won't remove CRDs, and `helm updgrade` won't upgrade them. Manual intervention is required with the current setup. - CRDs installed from `crds` folder **are not included into the helm release**. Additionally, it is not possible to template CRDs in Helm 3 in the `crds` folder. ## Regression <!-- Is this PR fixing a regression? (Yes / No) --> No <!-- If Yes, optionally please include version or commit id or PR# that caused this regression, if you have these details. --> ## How Has This Been Tested? <! Co-authored-by: cmontemuino <1761056+cmontemuino@users.noreply.github.com>
Build failed: |
@cmontemuino -- could you rebase your PR and run this helm-docs script against your changes:
Add the changes...
And then push to this branch..? |
7571cd6
to
1891c92
Compare
This changeset is mainly intended to skip Jaeger CRDs if it is not enabled. This is especially relevant when Jaeger tracing is installed separately from OpenEBS Mayastor. Helm 3 does not manage CRDs. - https://helm.sh/docs/chart_best_practices/custom_resource_definitions `helm uninstall` won't remove CRDs, and `helm updgrade` won't upgrade them. Manual intervention is required with the current setup. - CRDs installed from `crds` folder are not included into the helm release. Additionally, it is not possible to template CRDs in Helm 3 in the `crds` folder. Moving CRDs to a chart solves several issues: clean uninstall, possibility for upgrades, templating. Also make volumeSnapshots CRD optional Signed-off-by: cmontemuino <1761056+cmontemuino@users.noreply.github.com>
Signed-off-by: cmontemuino <1761056+cmontemuino@users.noreply.github.com>
Signed-off-by: cmontemuino <1761056+cmontemuino@users.noreply.github.com>
1891c92
to
92e2c38
Compare
@niladrih -- all done |
bors merge |
Build succeeded: |
454: fix(upgrade-job): look for crds in charts dir r=niladrih a=niladrih The upgrade-job validates the chart that it's got by checking if all the right directories are where they're supposed to be. Recent changes to the CRD installation method (ref: #414) has resulted in the upgrade-job failing, because things aren't how it expects. This PR changes the CRDs directory path to that of the subchart which encapsulates the CRDs now. Co-authored-by: Niladri Halder <niladri.halder26@gmail.com>
@cmontemuino a side effect we're finding from this is that if we uninstall when there are CRs present then as the CRD is removed then the CRs are also removed... this essentially means you lose the snapshots! I think we should add |
I think you didn't notice the situation before because Would you like me to draft a PR to handle this scenario + documentation? Something like the following: # CRD code here ...
metadata:
{{- if .Values.crds.keep }}
annotations:
helm.sh/resource-policy: keep
{{- if .Capabilities.APIVersions.Has "argoproj.io/v1alpha1" }}
argocd.argoproj.io/sync-options: Prune=false
{{- end }}
{{- end }} Of course it means tight-coupling to Argo CD (i.e., more maintenance, etc.), which might be non desirable....thus, something like the following might be a better fit: # CRD code here ...
metadata:
{{- if or (.Values.crds.keep) (.Values.crds.annotations }}
annotations:
{{- if .Values.crds.keep }}
helm.sh/resource-policy: keep
{{- end }}
{{- range $key, $value := .Values.crds.annotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }} With good documentation everything should be super clear. Just let me know if you want me to do it and I'll prepare the PR this week. |
That sounds good @cmontemuino, we'd like to take that PR if you can make it, otherwise we can look into adding it ourselves, let us know :) Also, do we need to keep the crd presence check on the template? This seems to be required only if upgrading from v2.5.0 which packed the yaml in the crd folder. In case case we could simply document that one needs to use --set crds.enabled=false rather than keep the crd presence check? |
Working on it already. Let me draft a PR and we discuss based on it. |
Can we move the conversation here? #458 I need a bit of help to write the PR description too... not sure if this is a feature or regression for example. |
Description
This changeset is mainly intended to skip Jaeger CRDs if it is not enabled. It is especially relevant when Jaeger tracing is installed separately from OpenEBS Mayastor.
Moving CRDs to a chart solves several issues: clean uninstall, possibility for upgrades, templating.
Motivation and Context
Helm 3 does not manage CRDs (see https://helm.sh/docs/chart_best_practices/custom_resource_definitions/).
helm uninstall
won't remove CRDs, andhelm updgrade
won't upgrade them. Manual intervention is required with the current setup.crds
folder are not included into the helm release.Additionally, it is not possible to template CRDs in Helm 3 in the
crds
folder.Regression
No
How Has This Been Tested?
Same results as before this MR:
helm install --set crds.jaeger.enabled=true mayastor
Skip the installation of Jaeger CRDs:
helm install mayastor
Types of changes
Checklist:
I have added unit tests to cover my changes.helm-unittest