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: Option to pass kubeVersion to helm template #2002

Merged
merged 1 commit into from
Jan 7, 2022
Merged

feat: Option to pass kubeVersion to helm template #2002

merged 1 commit into from
Jan 7, 2022

Conversation

msvticket
Copy link
Contributor

To be able to use helmfile template to render helm charts for cluster with other than the default Kubernetes version in helm you might need to add the --kube-version flag to helm. This adds that functionality.

@44smkn
Copy link

44smkn commented Dec 13, 2021

Hi,

I found Datadog Chart use .Capabilities.KubeVersion.GitVersion.
https://github.com/DataDog/helm-charts/blob/de93d7c45467c2bf65a34afec0729f13341aed4f/charts/datadog/templates/_helpers.tpl#L521-L526

{{- define "enable-service-internal-traffic-policy" -}}
{{- if or (semverCompare "^1.22-0" .Capabilities.KubeVersion.GitVersion) .Values.agents.localService.forceLocalServiceEnabled -}}
true
{{- else -}}
false
{{- end -}}
{{- end -}}

If enable-service-internal-traffic-policy is true, the kind: Service resource manifest which contains internalTrafficPolicy will be generated.
internalTrafficPolicy feature can be used only on Kubernetes 1.22+.
The clusters we have are v1.19 and v1.21, so we're a little troubled.

This pull request may resolve our problem.
I would like to know the status of this.

@msvticket
Copy link
Contributor Author

The reason I need this feature myself is that I need to set pathType in the ingresses for prometheus. But the prometheus chart only allows setting the pathType in Kubernetes 1.19+

https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus/templates/_helpers.tpl#L200

@msvticket
Copy link
Contributor Author

What can I do to get this pull request merged?

#
# Configure a fixed list of api versions to pass to 'helm template' via the --api-versions flag:
apiVersions:
- example/v1

# Configure a Kubernetes version to pass to 'helm template' via the --kube-version flag:
kubeVersion: v1.21
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm still unsure this is the right level to where kubeVersion is defined, as Helmfile allows a different k8s cluster hence k8s version per release, by specifying releases[].kubecontext. But I do believe this is a good enough for a starter!

Copy link
Collaborator

@mumoshu mumoshu 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 your patience and contribution!

@mumoshu mumoshu merged commit fe8a176 into roboll:master Jan 7, 2022
@mumoshu
Copy link
Collaborator

mumoshu commented Jan 10, 2022

@msvticket @44smkn Hey! I recently learned that --kube-version is only present in helm2's helm template. So if your chart is relying solely on Capabilities.KubeVersion to detect the correct API version for a resource, this doesn't help.

But you're already using Helm 3, right? Then you should just list API versions available to helm template by specifying apiVersions in your helmfile.yaml.

mumoshu added a commit that referenced this pull request Jan 10, 2022
@mumoshu
Copy link
Collaborator

mumoshu commented Jan 10, 2022

Updated README to note the above info 91aa0ac

@msvticket
Copy link
Contributor Author

msvticket commented Jan 10, 2022

$ helm template --help | grep kube-version
--kube-version string Kubernetes version used for Capabilities.KubeVersion
$ helm version
version.BuildInfo{Version:"v3.6.3", GitCommit:"d506314abfb5d21419df8c7e7e68012379db2354", GitTreeState:"dirty", GoVersion:"go1.16.5"}

--kube-version was added again in version 3.6.0 with helm/helm#9040

@44smkn
Copy link

44smkn commented Jan 17, 2022

When I ran helmfile template using helm v3.7.2 and helmfile v0.143.0, I got the expected results.
I think the feature proposed in this PR is useful in helm3 as well.

@mumoshu
Copy link
Collaborator

mumoshu commented Jan 17, 2022

@msvticket @44smkn Good to know! Thank you so much for sharing ☺️

w33dw0r7d pushed a commit to w33dw0r7d/helmfile that referenced this pull request Mar 8, 2022
w33dw0r7d pushed a commit to w33dw0r7d/helmfile that referenced this pull request Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants