Repository navigation
Description
What happened?
Helm 4's helm template command defaults to Kubernetes 1.20 instead of matching the client-go version (currently 1.34). This causes charts that use .Capabilities.KubeVersion to render old/deprecated API versions.
Charts using capability detection (like Bitnami's common library) render policy/v1beta1 instead of policy/v1 for PodDisruptionBudgets, batch/v1beta1 instead of batch/v1 for CronJobs, etc.
Root cause: The Makefile (lines 70-71) has incorrect LDFLAGS paths. They target helm.sh/helm/v4/pkg/chart/common/util.k8sVersionMajor but the variables are actually in pkg/chart/common/capabilities.go (package common, not common/util). The LDFLAGS silently fail, leaving the hardcoded 1.20 defaults instead of the client-go version.
This was introduced in commit 9dcc49c "Move lint pkg to be part of each chart version".
What did you expect to happen?
helm template should default to the Kubernetes version matching the bundled client-go library (v0.34.x = K8s 1.34), allowing charts to render current stable API versions when no cluster is available or --kube-version is not specified.
How can we reproduce it (as minimally and precisely as possible)?
# Create test chart
mkdir -p /tmp/testchart/templates
cat > /tmp/testchart/Chart.yaml << 'EOF'
apiVersion: v2
name: testchart
version: 0.1.0
EOF
cat > /tmp/testchart/templates/test.yaml << 'EOF'
KubeVersion: {{ .Capabilities.KubeVersion.Version }}
Major: {{ .Capabilities.KubeVersion.Major }}
Minor: {{ .Capabilities.KubeVersion.Minor }}
EOF
# Test with no cluster access to force default capabilities
KUBECONFIG=/dev/null helm template test /tmp/testchartExpected output:
KubeVersion: v1.34.0
Major: 1
Minor: 34Actual output:
KubeVersion: v1.20.0
Major: 1
Minor: 20Real-world impact test:
KUBECONFIG=/dev/null helm template test bitnami/keycloak --version 24.2.1 | grep -A2 "kind: PodDisruptionBudget"Shows apiVersion: policy/v1beta1 (deprecated in K8s 1.21) instead of policy/v1.
Verification of fix:
--- a/Makefile
+++ b/Makefile
@@ -67,8 +67,8 @@ LDFLAGS += -X helm.sh/helm/v4/pkg/chart/v2/lint/rules.k8sVersionMajor=$(K8S_MOD
LDFLAGS += -X helm.sh/helm/v4/pkg/chart/v2/lint/rules.k8sVersionMinor=$(K8S_MODULES_MINOR_VER)
LDFLAGS += -X helm.sh/helm/v4/pkg/internal/v3/lint/rules.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER)
LDFLAGS += -X helm.sh/helm/v4/pkg/internal/v3/lint/rules.k8sVersionMinor=$(K8S_MODULES_MINOR_VER)
-LDFLAGS += -X helm.sh/helm/v4/pkg/chart/common/util.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER)
-LDFLAGS += -X helm.sh/helm/v4/pkg/chart/common/util.k8sVersionMinor=$(K8S_MODULES_MINOR_VER)
+LDFLAGS += -X helm.sh/helm/v4/pkg/chart/common.k8sVersionMajor=$(K8S_MODULES_MAJOR_VER)
+LDFLAGS += -X helm.sh/helm/v4/pkg/chart/common.k8sVersionMinor=$(K8S_MODULES_MINOR_VER)
LDFLAGS += -X helm.sh/helm/v4/internal/version.kubeClientVersionMajor=$(K8S_MODULES_MAJOR_VER)
LDFLAGS += -X helm.sh/helm/v4/internal/version.kubeClientVersionMinor=$(K8S_MODULES_MINOR_VER)After applying the fix and rebuilding:
$ make build
$ KUBECONFIG=/dev/null ./bin/helm template test /tmp/testchart
---
# Source: testchart/templates/test.yaml
KubeVersion: v1.34.0
Major: 1
Minor: 34Helm version
Details
$ helm version
version.BuildInfo{Version:"v4.0.0+g99cd196", GitCommit:"99cd1964357c793351be481d55abbe21c6b2f4ec", GitTreeState:"clean", GoVersion:"go1.23.6"}Kubernetes version
Details
$ kubectl version
Client Version: v1.34.2
Kustomize Version: v5.6.0
Server Version: v1.34.0+k3s1
Activity
TerryHowe commentedon Nov 14, 2025
Nice detail in this issue, but I think dup of #31502
Fixed probably by #31501
Related probably #31296
rassie commentedon Nov 14, 2025
@TerryHowe While #31296 is more related to making the process less Makefile dependant, it raises an important issue where Brew might have been the culprit -- I'm also using Brew's version. I'll investigate locally. Thanks for the pointers!
rassie commentedon Nov 14, 2025
Re-checked with official Helm 4 binary -- same problem persists. I consider #31502 and #31501 somewhat related, but they are more concerned with errors/warnings when falling back to 1.20.x, but less concerned with always falling back without extra CLI arguments, as happening now.
benoittgt commentedon Nov 14, 2025
I agree that my proposal is really the lower effort and we could have a much more smarter way to choose the default version.
benoittgt commentedon Nov 14, 2025
@rassie with all the work in the initial PR, do you want to open a PR? Otherwise I can do it.
rassie commentedon Nov 14, 2025
Go ahead, I won't be at my machine for the next 18 hours.
fix: correct LDFLAGS path for default Kubernetes version
fix: correct LDFLAGS path for default Kubernetes version
benoittgt commentedon Nov 15, 2025
Thanks a lot @rassie for the quality of the issue and the patch suggestion.
eumel8 commentedon Nov 23, 2025
@gjenkins8 : can we have a 4.0.1 pre-release build with this fix? I think many people struggle on this error and don't want to wait until official release date in 3 weeks.
fix: correct LDFLAGS path for default Kubernetes version
eumel8 commentedon Nov 24, 2025
fixed and released 4.0.1 today, thanks to the Helm team