Helm built-in object, `Capabilities.KubeVersion`, has wrong value
Description:
Since version 3.15.4-1 helm built-in object, Capabilities.KubeVersion
, has wrong value i.e. it shows kubernetes version 1.20
. This affects some helm charts in the way that they "choose" wrong/deprecated API's i.e. for old k8s releases.
Additional info:
- package version(s): 3.15.4-1, 3.15.4-2, 3.16.1-1
Steps to reproduce:
Create chart with simple "version" template:
templates/version.yaml
kubeversion:
- {{.Capabilities.KubeVersion}}
- {{.Capabilities.KubeVersion.Version}}
helmversion:
- {{.Capabilities.HelmVersion.Version}}
- {{.Capabilities.HelmVersion}}
helm
Archlinux
helm
3.16.1-1:
Test with $ helm template test test
---
# Source: test/templates/version.yaml
kubeversion:
- v1.20.0
- v1.20.0
helmversion:
- v3.16.1
- {v3.16.1 5a5449dc42be07001fd5771d56429132984ab3ab go1.23.1}
$
helm
3.15.4-1:
Test with $ helm template test test
---
# Source: test/templates/version.yaml
kubeversion:
- v1.20.0
- v1.20.0
helmversion:
- 3.15.4
- {3.15.4 fa9efb07d9d8debbb4306d72af76a383895aa8c4 go1.23.0}
$
helm
3.15.3-1 (kubernetes version is right here):
Test with $ helm template test test
---
# Source: test/templates/version.yaml
kubeversion:
- v1.30.0
- v1.30.0
helmversion:
- v3.15.3
- {v3.15.3 3bb50bbbdd9c946ba9989fbe4fb4104766302a64 clean go1.22.5}
$
binaries
Compared with released Helm$ ./helm-v3.15.3-linux-amd64/linux-amd64/helm template test test
---
# Source: test/templates/version.yaml
kubeversion:
- v1.30.0
- v1.30.0
helmversion:
- v3.15.3
- {v3.15.3 3bb50bbbdd9c946ba9989fbe4fb4104766302a64 clean go1.22.5}
$
$ ./helm-v3.15.4-linux-amd64/linux-amd64/helm template test test
---
# Source: test/templates/version.yaml
kubeversion:
- v1.30.0
- v1.30.0
helmversion:
- v3.15.4
- {v3.15.4 fa9efb07d9d8debbb4306d72af76a383895aa8c4 clean go1.22.6}
$
$ ./helm-v3.16.1-linux-amd64/linux-amd64/helm template test test
---
# Source: test/templates/version.yaml
kubeversion:
- v1.31.0
- v1.31.0
helmversion:
- v3.16.1
- {v3.16.1 5a5449dc42be07001fd5771d56429132984ab3ab clean go1.22.7}
$
Solution
When release, 3.15.4-1, was created there ware some changes to PKGBUID when it comes to go build
's ldflags. My guess is that ldflags for k8s version ware forgotten:
-X helm.sh/helm/v3/pkg/lint/rules.k8sVersionMajor=
-X helm.sh/helm/v3/pkg/lint/rules.k8sVersionMinor=
-X helm.sh/helm/v3/pkg/chartutil.k8sVersionMajor=
-X helm.sh/helm/v3/pkg/chartutil.k8sVersionMinor=
You can see that when Helm creates their own releases, in their Makefile. Helm source here and here.