When using AWS EKS the reported K8s version always has a SemVer pre-release specifier that AWS use for their own versioning on top of the standard K8s version.
The SemVer comparison library that Helm uses ignored pre-release versions unless the format of the comparator specifically includes a pre-release specifier.
This has already been done for the ingress template where the API version is selected with:
{{- if semverCompare ">=1.19-0" $top.Capabilities.KubeVersion.Version }}
apiVersion: networking.k8s.io/v1
{{- else }}
apiVersion: networking.k8s.io/v1beta1
{{- end }}
For our case this also need to be done for the HPA template to support EKS, but should probably also be done for all SemVer comparisons against the K8s version:
In the HPA template:
{{- if semverCompare ">1.22-0" $top.Capabilities.KubeVersion.Version }}
apiVersion: autoscaling/v2
{{- else }}
apiVersion: autoscaling/v2beta2
{{- end }}
In the cronjob template:
{{- if semverCompare "<1.25-0" $top.Capabilities.KubeVersion.Version }}
apiVersion: batch/v1beta1
{{- else }}
apiVersion: batch/v1
{{- end }}
When using AWS EKS the reported K8s version always has a SemVer pre-release specifier that AWS use for their own versioning on top of the standard K8s version.
The SemVer comparison library that Helm uses ignored pre-release versions unless the format of the comparator specifically includes a pre-release specifier.
This has already been done for the ingress template where the API version is selected with:
For our case this also need to be done for the HPA template to support EKS, but should probably also be done for all SemVer comparisons against the K8s version:
In the HPA template:
In the cronjob template:
For reference: https://helm.sh/docs/chart_template_guide/function_list/#working-with-prerelease-versions