From 9be1efccb9e863c447078d1f338b41a9cd6a971e Mon Sep 17 00:00:00 2001 From: Tylen Wells Date: Mon, 24 Jul 2023 15:55:27 -0700 Subject: [PATCH 1/3] add k8s verison condiitonal to hpa template apiVerison mapping Signed-off-by: Tylen Wells --- charts/prometheus-statsd-exporter/templates/hpa.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/charts/prometheus-statsd-exporter/templates/hpa.yaml b/charts/prometheus-statsd-exporter/templates/hpa.yaml index ae5d0f1d7516..b5249d9d1824 100644 --- a/charts/prometheus-statsd-exporter/templates/hpa.yaml +++ b/charts/prometheus-statsd-exporter/templates/hpa.yaml @@ -1,5 +1,9 @@ {{- if .Values.autoscaling.enabled }} +{{- if semverCompare ">=1.25-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: autoscaling/v2 +{{- else -}} apiVersion: autoscaling/v2beta1 +{{- end }} kind: HorizontalPodAutoscaler metadata: name: {{ include "prometheus-statsd-exporter.fullname" . }} From ff93a016d373b9e417db2bccfa87549d9d6f9c21 Mon Sep 17 00:00:00 2001 From: Tylen Wells Date: Mon, 24 Jul 2023 15:57:53 -0700 Subject: [PATCH 2/3] bump chart version Signed-off-by: Tylen Wells --- charts/prometheus-statsd-exporter/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/prometheus-statsd-exporter/Chart.yaml b/charts/prometheus-statsd-exporter/Chart.yaml index 97f5f91be7bc..4dd572251ff4 100644 --- a/charts/prometheus-statsd-exporter/Chart.yaml +++ b/charts/prometheus-statsd-exporter/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v2 name: prometheus-statsd-exporter description: A Helm chart for prometheus stats-exporter -version: 0.9.0 +version: 0.9.1 appVersion: v0.22.8 home: https://github.com/prometheus/statsd_exporter sources: From e1336346eae84e00608743258bd47c4745454cae Mon Sep 17 00:00:00 2001 From: zeritti <47476160+zeritti@users.noreply.github.com> Date: Wed, 2 Aug 2023 22:31:39 +0000 Subject: [PATCH 3/3] Add template for setting HPA API version Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com> --- .../templates/_helpers.tpl | 13 +++++++++++++ .../prometheus-statsd-exporter/templates/hpa.yaml | 6 +----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/charts/prometheus-statsd-exporter/templates/_helpers.tpl b/charts/prometheus-statsd-exporter/templates/_helpers.tpl index 613bb8628034..47ba46716f43 100644 --- a/charts/prometheus-statsd-exporter/templates/_helpers.tpl +++ b/charts/prometheus-statsd-exporter/templates/_helpers.tpl @@ -74,3 +74,16 @@ Check if there is any mappings available {{- template "prometheus-statsd-exporter.fullname" . -}} {{- end }} {{- end }} + +{{/* +Define apiVersion of HorizontalPodAutoscaler +*/}} +{{- define "prometheus-statsd-exporter.hpa.apiVersion" -}} +{{- if .Capabilities.APIVersions.Has "autoscaling/v2" -}} +{{- print "autoscaling/v2" -}} +{{- else if .Capabilities.APIVersions.Has "autoscaling/v2beta2" -}} +{{- print "autoscaling/v2beta2" -}} +{{- else -}} +{{- print "autoscaling/v2beta1" -}} +{{- end -}} +{{- end -}} diff --git a/charts/prometheus-statsd-exporter/templates/hpa.yaml b/charts/prometheus-statsd-exporter/templates/hpa.yaml index b5249d9d1824..4d04994993dc 100644 --- a/charts/prometheus-statsd-exporter/templates/hpa.yaml +++ b/charts/prometheus-statsd-exporter/templates/hpa.yaml @@ -1,9 +1,5 @@ {{- if .Values.autoscaling.enabled }} -{{- if semverCompare ">=1.25-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: autoscaling/v2 -{{- else -}} -apiVersion: autoscaling/v2beta1 -{{- end }} +apiVersion: {{ include "prometheus-statsd-exporter.hpa.apiVersion" . }} kind: HorizontalPodAutoscaler metadata: name: {{ include "prometheus-statsd-exporter.fullname" . }}