Skip to content

Allow customization of API Versions when using Helm Template - #5392

Merged
thomastaylor312 merged 1 commit into
helm:masterfrom
bnookala:add-template-api-versioning
Oct 4, 2019
Merged

thomastaylor312 merged 1 commit into
helm:masterfrom
bnookala:add-template-api-versioning

Conversation

@bnookala

@bnookala bnookala commented Mar 4, 2019

Copy link
Copy Markdown

Signed-off-by: Bhargav Nookala [email protected]

What this PR does / why we need it:

Resolves #3377 for helm template.
This PR adds --api-version (or -a) to add custom API versions to Capabilites.APIVersion, allowing a user to correctly render templates that depend on certain API versions.

Special notes for your reviewer:

If applicable:

  • this PR contains unit tests
  • this PR contains documentation

@helm-bot helm-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 4, 2019
@bnookala
bnookala force-pushed the add-template-api-versioning branch from 3a4e23c to 2361b74 Compare March 4, 2019 07:56
@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 4, 2019
@bnookala

bnookala commented Mar 6, 2019

Copy link
Copy Markdown
Author

hi @bacongobbler - would you be able to take a look at this addition to helm template?

@kramvan1

Copy link
Copy Markdown

+1

@alexmt

alexmt commented Apr 29, 2019

Copy link
Copy Markdown

This would be very useful!

@basvandenbrink

Copy link
Copy Markdown

Agree, would be nice if this is going to be merged!

@sundag

sundag commented Aug 23, 2019

Copy link
Copy Markdown

Pending on this feature to be available.

@alexec

alexec commented Sep 10, 2019

Copy link
Copy Markdown

+1

@waveywaves

waveywaves commented Sep 13, 2019 •

Copy link
Copy Markdown
Contributor

@bnookala This is awesome, and the addition of the missing flags is just great !

A few things:
Would it be possible for the helm template command to check if the CRD folder exists and then pick up the api versions from there. This way there would be no need to explicitly pass arguments.
@technosophos would need your input on this as well
Can you rebase and push the commits again ?

@bnookala

bnookala commented Sep 13, 2019 •

Copy link
Copy Markdown
Author

@waveywaves I may be wrong, but I think presently helm doesn't make any assumptions about the structure of a chart (beyond certain expectations), so it seems like having a feature look for a certain directory (ie CRDs) might be out of the scope of what I was thinking for this.

Given that a number of projects incorrectly generate manifests (argocd, fluent-bit, I'm sure others…) via helm template, I'd still love to have this, however I can imagine the Helm team to be a bit busy with Helm 3 at the moment.

@sbose78

sbose78 commented Sep 13, 2019

Copy link
Copy Markdown
Contributor

I like this @bnookala !

Could we have this feature in helm3 / "dev-v3" branch as well, please?

@bacongobbler bacongobbler added this to the 2.15.0 milestone Oct 2, 2019
@bacongobbler bacongobbler added the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Oct 2, 2019

@thomastaylor312 thomastaylor312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is looking great! Just need a super small change on the flag name and this will be good to go

Comment thread cmd/helm/template.go Resolved
@bnookala
bnookala force-pushed the add-template-api-versioning branch from 2361b74 to 69b1964 Compare October 3, 2019 21:15
Comment thread cmd/helm/template_test.go Resolved
@bacongobbler

Copy link
Copy Markdown
Member

might also be worth to rebase against master once more now that #6577 has been merged. It includes a fix where coreutils was bumped underneath us, causing CI to fail :) thanks @bnookala!

@bnookala
bnookala force-pushed the add-template-api-versioning branch from 69b1964 to 300aa76 Compare October 4, 2019 18:28

@bacongobbler bacongobbler left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I know it's sorta last minute here, but I would LOVE to see some documentation on how users can consume this flag, where it's useful, etc.

Regardless thank you for the PR! Looking forward to seeing this in 2.15. I'll leave it for @thomastaylor312 to review and merge since he kicked off the review process.

@bnookala

bnookala commented Oct 4, 2019

Copy link
Copy Markdown
Author

@bacongobbler oh for sure, can totally do that - do you have a suggestion on where the docs should live? at a quick glance, thinking the "thinking about charts" section might be a good option: https://helm.sh/docs/using_helm/#thinking-about-charts

@thomastaylor312

Copy link
Copy Markdown
Contributor

@bnookala I would actually suggest somewhere here: https://helm.sh/docs/chart_template_guide/#debugging-templates

Info on the template command was never added there and would be useful to have

@thomastaylor312 thomastaylor312 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for all the hard work here

@thomastaylor312
thomastaylor312 merged commit 730e8f3 into helm:master Oct 4, 2019
thomastaylor312 added a commit to thomastaylor312/helm that referenced this pull request Oct 7, 2019
This is a port of helm#5392. It also takes care of the small chore to update the default k8s
version to 1.16, which is the latest supported version

Signed-off-by: Taylor Thomas <[email protected]>
@thomastaylor312 thomastaylor312 added the v3 port complete For completed v2->v3 ports label Oct 7, 2019
thomastaylor312 added a commit to thomastaylor312/helm that referenced this pull request Oct 7, 2019
This is a port of helm#5392. It also takes care of the small chore to update the default k8s
version to 1.16, which is the latest supported version

Signed-off-by: Taylor Thomas <[email protected]>
@bnookala
bnookala deleted the add-template-api-versioning branch March 22, 2020 02:19
learnitall added a commit to learnitall/cilium-cli that referenced this pull request Oct 26, 2022
The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
learnitall added a commit to learnitall/cilium-cli that referenced this pull request Oct 27, 2022
The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
learnitall added a commit to learnitall/cilium-cli that referenced this pull request Oct 28, 2022
The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
learnitall added a commit to learnitall/cilium-cli that referenced this pull request Oct 28, 2022
The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
michi-covalent pushed a commit to cilium/cilium-cli that referenced this pull request Oct 29, 2022
The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: #1107

Signed-off-by: Ryan Drew <[email protected]>
michi-covalent pushed a commit to michi-covalent/cilium that referenced this pull request May 30, 2023
The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
@gjenkins8 gjenkins8 removed the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Dec 27, 2024
jeefy pushed a commit to jeefy/cilium that referenced this pull request Sep 23, 2026
[ cherry-picked from cilium/cilium-cli repository ]

The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
sypakine pushed a commit to sypakine/cilium that referenced this pull request Sep 25, 2026
[ cherry-picked from cilium/cilium-cli repository ]

The commit introduces the `--api-versions` parameter for the `install`
sub-command, which allows for users to set helm's
Capabilities.APIVersions as needed for Cilium chart validation. If
a user does not provide a value or set of values for `--api-versions`,
then a discovery client will be used to auto-fill this value based
on the available api versions in a cluster (see install/helm.go#L271).

This change is needed because helm will not contact the k8s api server
to determine what CRDs are installed into a cluster, leading to chart
validation to fail anytime a CRD is required. For this reason, the
`--api-versions` CLI argument was introduced to `helm template` (see
pr [helm/helm#5392]). The cilium-cli does not allow for users to specify
this argument to helm, therefore users can face a similar issue when
installing cilium with certain features. For instance, enabling the use
of prometheus ServiceMonitors will trigger a check for
`monitoring.coreos.com/v1` while performing chart validation (by
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]), but
since helm does not adjust Capabilties.APIVersions based on the CRDs
installed in a cluster, helm will _always_ believe that
`monitoring.coreos.com/v1` is not available.

[helm/helm#5392]: helm/helm#5392
[cilium/install/kubernetes/cilium/templates/validate.yaml#L21]: https://github.com/cilium/cilium/blob/v1.12.2/install/kubernetes/cilium/templates/validate.yaml#L21

Fixes: cilium#1107

Signed-off-by: Ryan Drew <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature size/M Denotes a PR that changes 30-99 lines, ignoring generated files. v3 port complete For completed v2->v3 ports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to pass Capabilities.APIVersions to template and lint