helm icon indicating copy to clipboard operation
helm copied to clipboard

helm create produces hpa that fails linting

Open b0n541 opened this issue 4 years ago • 5 comments

When I create a new Helm chart with helm create test-helm-chart the horizontal autoscaling manifest template gets created with apiVersion: autoscaling/v2beta1 in the hpa.yaml file. Strict linting works because autoscaling is not enabled by default in the values.yaml.

When I enable autoscaling by setting

autoscaling:
  enabled: true

in the values.yaml strict linting fails:

$ helm lint --strict test-helm-chart
==> Linting test-helm-chart
[INFO] Chart.yaml: icon is recommended
[WARNING] templates/hpa.yaml: autoscaling/v2beta1 HorizontalPodAutoscaler is deprecated in v1.22+, unavailable in v1.25+; use autoscaling/v2 HorizontalPodAutoscaler

Error: 1 chart(s) linted, 1 chart(s) failed

The linting should not fail here because my Kubernetes version still supports autoscaling/v2beta1 perfectly fine. It seems that Helm is not recognizing the Kubernetes versions returned by kubectl at all. I tried different setups with kubectl client version 1.20, 1.22 and 1.23 and Kubernetes server version 1.20 and 1.22. In all cases the strict linting fails. I think it should only fail if either the client or the server version returns v1.22+.

Output of helm version:

version.BuildInfo{Version:"v3.8.1", GitCommit:"5cb9af4b1b271d11d7a97a71df3ac337dd94ad37", GitTreeState:"clean", GoVersion:"go1.17.5"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.0", GitCommit:"af46c47ce925f4c4ad5cc8d1fca46c7b77d13b38", GitTreeState:"clean", BuildDate:"2020-12-08T17:59:43Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"20", GitVersion:"v1.20.9", GitCommit:"7a576bc3935a6b555e33346fd73ad77c925e9e4a", GitTreeState:"clean", BuildDate:"2021-07-15T20:56:38Z", GoVersion:"go1.15.14", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):

Minikube, AKS

b0n541 avatar Mar 31 '22 05:03 b0n541

Maybe you can think of introducing a new command line option to define the version for the target Kubernetes?

b0n541 avatar Mar 31 '22 08:03 b0n541

@b0n541 when helm lint. helm don't get k8s version form the k8s cluster. it from client-go's version in go.mod.
I thinks you idea is good. Welcome to create a PR for this.

yxxhero avatar Mar 31 '22 14:03 yxxhero

Just found this: https://github.com/helm/helm/pull/10677

This would exactly be the new feature I would like to see.

b0n541 avatar Mar 31 '22 15:03 b0n541

running into the same situation.

simo-markus-noerenberg avatar Apr 11 '22 16:04 simo-markus-noerenberg

This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

github-actions[bot] avatar Jul 11 '22 00:07 github-actions[bot]