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

Automatically fill in .Capabilities in Helm Charts #2155

Conversation

yann-soubeyrand
Copy link
Contributor

@yann-soubeyrand yann-soubeyrand commented Aug 27, 2022

Proposed changes

This PR tries to add automatic filling of Helm capabilities (Kubernetes version and API versions) in Chart resource. I’ve successfully built and tested this PR with a simple chart, but I’m not familiar with development on this repository (on Pulumi providers in general), so I may need some help to bring this PR to proper releasable state.

Related issues (optional)

Fix #196
Fix #2141
Fix #753

@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@yann-soubeyrand yann-soubeyrand force-pushed the automatically-fill-capabilities-in-helm-charts branch from 4e1b595 to fada353 Compare August 27, 2022 12:20
@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@yann-soubeyrand yann-soubeyrand force-pushed the automatically-fill-capabilities-in-helm-charts branch from fada353 to 00049f3 Compare August 27, 2022 12:22
@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@lblackstone
Copy link
Member

/run-acceptance-tests

@pulumi-bot
Copy link
Contributor

Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

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

This looks great; thanks for the PR @yann-soubeyrand! Just one minor suggestion, and then LGTM if the tests pass.

Comment on lines 277 to 280
// Preserve backward compatibility
if len(c.opts.APIVersions) > 0 {
installAction.APIVersions = c.opts.APIVersions
}
Copy link
Member

Choose a reason for hiding this comment

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

I'd check this first, and skip the discovery client calls to the apiserver if 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.

Hello @lblackstone, thanks for the review 😉

I followed your suggestion and modified the code, but now I’m wondering if we really want to disable Kubernetes version discovery when APIVersions are provided. What do you think?

Regarding the tests, it seems they haven’t run, do I have to fix something on my side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I posted a message in Slack (https://pulumi-community.slack.com/archives/CRFURDVQB/p1661613221358179) to get some directions on how to develop on this provider, maybe you have the answers to my questions?

Copy link
Member

Choose a reason for hiding this comment

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

I followed your suggestion and modified the code, but now I’m wondering if we really want to disable Kubernetes version discovery when APIVersions are provided. What do you think?

Ah, I didn't notice that the DefaultCapabilities was setting the kube version before, and defaulted to v1.20. Maybe we should set that explicitly here? The problem is that the cluster may not be available yet when this code is running (i.e., if it's a preview in a stack where the cluster hasn't been created yet), so we need a fallback value set.

Regarding the tests, it seems they haven’t run, do I have to fix something on my side?

For external contributors, a maintainer has to run the tests with the /run-acceptance-tests comment, and then the bot will respond with a link to the test run that you can check: #2155 (comment)

It looks like everything passed, so this should be good once we handle the default k8s version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I followed your suggestion and modified the code, but now I’m wondering if we really want to disable Kubernetes version discovery when APIVersions are provided. What do you think?

Ah, I didn't notice that the DefaultCapabilities was setting the kube version before, and defaulted to v1.20. Maybe we should set that explicitly here? The problem is that the cluster may not be available yet when this code is running (i.e., if it's a preview in a stack where the cluster hasn't been created yet), so we need a fallback value set.

The default KubeVersion seems to still be set here https://github.com/helm/helm/blob/dbc6d8e20fe1d58d50e6ed30f09a04a77e4c68db/pkg/action/install.go#L216.

My concern was about the fact that people having APIVersions manually set won’t benefit from the discovery of the KubeVersion. But it’s not a regression. We could also add the ability to manually set the KubeVersion (as for the APIVersions), but that’d be a fairly different PR 😉

Regarding the tests, it seems they haven’t run, do I have to fix something on my side?

For external contributors, a maintainer has to run the tests with the /run-acceptance-tests comment, and then the bot will respond with a link to the test run that you can check: #2155 (comment)

It looks like everything passed, so this should be good once we handle the default k8s version.

Ha OK, I had a notification with this link https://github.com/pulumi/pulumi-kubernetes/actions/runs/2939221543 which made me think the tests didn’t run, I didn’t see https://github.com/pulumi/pulumi-kubernetes/actions/runs/2952219436, so that’s OK 😉

Closes pulumi#196
Closes pulumi#753

Signed-off-by: Yann Soubeyrand <yann.soubeyrand@gmx.fr>
@yann-soubeyrand yann-soubeyrand force-pushed the automatically-fill-capabilities-in-helm-charts branch from 00049f3 to 40e4b7a Compare August 30, 2022 08:11
@github-actions
Copy link

PR is now waiting for a maintainer to run the acceptance tests.
Note for the maintainer: To run the acceptance tests, please comment /run-acceptance-tests on the PR

@lblackstone
Copy link
Member

/run-acceptance-tests

@pulumi-bot
Copy link
Contributor

Copy link
Member

@lblackstone lblackstone left a comment

Choose a reason for hiding this comment

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

LGTM -- thanks for a great PR!

@LambArchie
Copy link

Thank you @yann-soubeyrand for doing this PR as it fixes the issue I had in #2141 (I've tested locally to check it does everything my issue needed it to do)

@lblackstone lblackstone merged commit 0c9dea0 into pulumi:master Aug 31, 2022
@yann-soubeyrand
Copy link
Contributor Author

Thanks @lblackstone for the prompt review 😉

@LucasBrazi06
Copy link

@yann-soubeyrand I see only apiVersions in the Chart's options but I would have expected also kubeVersions to solve the issue you had in the first place and that I'm currently having: #2249
What did you do to fixed it?
Thanks in advance!

@yann-soubeyrand
Copy link
Contributor Author

@LucasBrazi06 to solve this issue, I added the ability to automatically fill in .Capabilities (which contains Kubernetes version) in Helm Charts to this provider. Therefore, the (existing) apiVersions attribute should not be needed nor the (non-existing) kubeVersion attribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants