From 7932a53a444f8f7617536936f07ef80722e5c4cc Mon Sep 17 00:00:00 2001 From: tylenwells <47961949+tylenwells@users.noreply.github.com> Date: Fri, 4 Aug 2023 00:23:06 -0700 Subject: [PATCH] [prometheus-statsd-exporter] - add conditional for hpa apiVersion (#3635) * add k8s verison condiitonal to hpa template apiVerison mapping Signed-off-by: Tylen Wells * bump chart version Signed-off-by: Tylen Wells * Add template for setting HPA API version Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com> --------- Signed-off-by: Tylen Wells Signed-off-by: zeritti <47476160+zeritti@users.noreply.github.com> Co-authored-by: Tylen Wells Co-authored-by: zeritti <47476160+zeritti@users.noreply.github.com> Co-authored-by: MH --- charts/prometheus-statsd-exporter/Chart.yaml | 2 +- .../templates/_helpers.tpl | 13 +++++++++++++ .../prometheus-statsd-exporter/templates/hpa.yaml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) 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: 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 ae5d0f1d7516..4d04994993dc 100644 --- a/charts/prometheus-statsd-exporter/templates/hpa.yaml +++ b/charts/prometheus-statsd-exporter/templates/hpa.yaml @@ -1,5 +1,5 @@ {{- if .Values.autoscaling.enabled }} -apiVersion: autoscaling/v2beta1 +apiVersion: {{ include "prometheus-statsd-exporter.hpa.apiVersion" . }} kind: HorizontalPodAutoscaler metadata: name: {{ include "prometheus-statsd-exporter.fullname" . }}