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

feat: install CRDs from a subchart #1922

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

cmontemuino
Copy link
Contributor

ROBLEM: Helm 3 only install CRDs during the chart installation. Both deletes and upgrades are not handled by Helm 3. It requires manual intervention. Additionally, it is not possible to template CRDs. This is especially important when installing the chart with an Argo CD application.

SOLUTION: add the possibility to install the CRDs from a dependency subchart. This allows clean uninstall, possibility for automated upgrades, and templating. This feature comes disabled by default.

closes #1637

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Oct 22, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cmontemuino
Once this PR has been reviewed and has the lgtm label, please assign marquiz for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 22, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @cmontemuino. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 22, 2024
Copy link

netlify bot commented Oct 22, 2024

Deploy Preview for kubernetes-sigs-nfd ready!

Name Link
🔨 Latest commit 3f3ab44
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-nfd/deploys/6731f62f1bdb240008045216
😎 Deploy Preview https://deploy-preview-1922--kubernetes-sigs-nfd.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@TessaIO
Copy link
Member

TessaIO commented Oct 22, 2024

Thanks for the patch @cmontemuino. I saw, that you added the new CRD installation without removing the old CRDs manifests. Wouldn't that be an issue if we installed both Helm charts (the NFD and CRD) as it would try to create the same CRD twice and fail?

@cmontemuino
Copy link
Contributor Author

Thanks for the patch @cmontemuino. I saw, that you added the new CRD installation without removing the old CRDs manifests. Wouldn't that be an issue if we installed both Helm charts (the NFD and CRD) as it would try to create the same CRD twice and fail?

Thanks for raising this point @TessaIO, as it requires more clarification.

My initial take was to make this feature completely optional. The assumption here is that there could be a use case for using Helm 3 CRDs approach.

This is what I've added in the values.yaml:

# -- Toggle to install and upgrade CRDs from a subchart. Make sure to use it with `--skip-crds` to avoid conflicts.

And also reflected it in the helm.md file -- general parameters section.

I'd say a section in helm.md detailing this new addition makes sense. That's where I'm struggling about how the documentation is generated. For example, should I add a new section in the same lines as in https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/docs/deployment/helm.md#from-v014 ?

PROBLEM: Helm 3 only install CRDs during the chart installation. Both
deletes and upgrades are not handled by Helm 3. It requires manual
intervention. Additionally, it is not possible to template CRDs. This is
especially important when installing the chart with an Argo CD
application.

SOLUTION: add the possibility to install the CRDs from a dependency
subchart. This allows clean uninstall, possibility for automated
upgrades, and templating. This feature comes disabled by default.

closes kubernetes-sigs#1637

Signed-off-by: cmontemuino <[email protected]>
Copy link
Member

@TessaIO TessaIO left a comment

Choose a reason for hiding this comment

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

Thanks @cmontemuino for the clarifications. I put some comments, I'll review it one more time once this is ready.

@@ -13,3 +13,7 @@ keywords:
- node-labels
type: application
version: 0.2.1
dependencies:
- name: crds
version: 0.0.0
Copy link
Member

Choose a reason for hiding this comment

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

Probably we want to put a version here not 0.0.0

Copy link
Contributor Author

@cmontemuino cmontemuino Oct 23, 2024

Choose a reason for hiding this comment

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

There's a drawback to use a version here: you need bump the version and helm dependency update with every release.

The versioning usually makes sense when adding charts from other repos, with different lifecycles.

In our case, CRDs are always generated and copied under crds folder: https://github.com/kubernetes-sigs/node-feature-discovery/blob/master/hack/update_codegen.sh#L44-L46

There's a 1-1 match in the lifecycle for this chart. Thus, the version: 0.0.0 makes the trick to avoid extra steps.

@@ -0,0 +1,3 @@
apiVersion: v2
name: crds
version: 0.0.0
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@@ -0,0 +1,9 @@
# crds

![Version: 0.0.0](https://img.shields.io/badge/Version-0.0.0-informational?style=flat-square)
Copy link
Member

Choose a reason for hiding this comment

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

also here

@@ -149,6 +149,8 @@ Chart parameters are available.

| Name | Type | Default | Description |
| --------------------------------------------------- | ------ | --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `crds.install` | bool | false | Toggle to install and upgrade CRDs from a subchart. Make sure to use it with `--skip-crds` to avoid conflicts. [More info about limitations on CRDs in Helm 3](https://helm.sh/docs/topics/charts/#limitations-on-crds) |
Copy link
Member

Choose a reason for hiding this comment

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

If i'm not mistaken, I think the --skip-crds flag is used for the crds folder and not the separate helm chart. so I don't think that they're related. Please correct if I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right about the flag 👍

The problem happens only when the chart is installed by the first time. In that scenario: helm install xxxx --skip-crds --set crds.install=true

(apologies for the oversimplification above)

Otherwise, Helm will install CRDs from both places. Again, this only happens the first time. Helm won't care about the CRDs folder during upgrades (nor uninstall)

Copy link
Member

Choose a reason for hiding this comment

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

Are you keeping an additional copy of the CRD in the /crds directory only for the initial installation of the chart?
I'm wondering if it might be too strict to always require using --skip-crds --set crds.install=true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My take was make the new approach optional. That is, if you do nothing, then the CRDs get installed as they are now.
By the other hand, if you want to taste the new approach, then --skip-crds --set crds.install=true.

I wonder if this is a good compromise, or if we should go the sub-chart with CRDs approach in one single shot. WDYT @fmuyassarov

Regarding additional copies, all of them are automatically generated.

Copy link
Member

Choose a reason for hiding this comment

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

I was considering whether we should standardize on using only crds.install=true for all installations, including both first-time installs and upgrades. However, I'm concerned it might be too much to ask of users at this stage. For now, I think it’s better to keep it optional as you have it now.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 23, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 24, 2024
@k8s-ci-robot
Copy link
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • c60d355 helm: install CRDs from a subchart

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Install CRDs from a subchart instead of using Helm 3 crds directory
4 participants