Skip to content

Commit

Permalink
[prometheus-statsd-exporter] - add conditional for hpa apiVersion (#3635
Browse files Browse the repository at this point in the history
)

* add k8s verison condiitonal to hpa template apiVerison mapping

Signed-off-by: Tylen Wells <[email protected]>

* bump chart version

Signed-off-by: Tylen Wells <[email protected]>

* Add template for setting HPA API version

Signed-off-by: zeritti <[email protected]>

---------

Signed-off-by: Tylen Wells <[email protected]>
Signed-off-by: zeritti <[email protected]>
Co-authored-by: Tylen Wells <[email protected]>
Co-authored-by: zeritti <[email protected]>
Co-authored-by: MH <[email protected]>
  • Loading branch information
4 people authored Aug 4, 2023
1 parent aba4760 commit 7932a53
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion charts/prometheus-statsd-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
13 changes: 13 additions & 0 deletions charts/prometheus-statsd-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
2 changes: 1 addition & 1 deletion charts/prometheus-statsd-exporter/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -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" . }}
Expand Down

0 comments on commit 7932a53

Please sign in to comment.