Skip to content

Commit

Permalink
fix: rely on api rather than on k8s version (#3366)
Browse files Browse the repository at this point in the history
* use autoscaling/v2 if available on the cluster

* add changelog entry

* Rename 3315.fixed.txt to 3366.fixed.txt

---------

Co-authored-by: Christopher Montoro <[email protected]>
  • Loading branch information
sumo-drosiek and montmanu authored Oct 31, 2023
1 parent a1605ac commit a6fb970
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
1 change: 1 addition & 0 deletions .changelog/3366.fixed.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use autoscaling/v2 if available on the cluster
15 changes: 15 additions & 0 deletions deploy/helm/sumologic/templates/_helpers/_api_versions.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@ policy/v1
policy/v1beta1
{{- end -}}
{{- end -}}

{{/*
Use HorizontalPodAutoscaler apiVersion that is available on the cluster
Example Usage:
apiVersion: {{ include "apiVersion.horizontalPodAutoscaler" . }}

*/}}
{{- define "apiVersion.horizontalPodAutoscaler" -}}
{{- if .Capabilities.APIVersions.Has "autoscaling/v2" -}}
autoscaling/v2
{{- else -}}
autoscaling/v2beta2
{{- end -}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{{ $otelcolInstrumentation := .Values.otelcolInstrumentation }}
{{ $tracesEnabled := .Values.sumologic.traces.enabled }}
{{- if and $tracesEnabled $otelcolInstrumentation.enabled (eq (include "otelcolInstrumentation.autoscaling.enabled" .) "true") }}
{{- if and (eq .Capabilities.KubeVersion.Major "1") (lt (int (include "kubernetes.minor" .)) 23) }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2
{{- end }}
apiVersion: {{ include "apiVersion.horizontalPodAutoscaler" . }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "sumologic.metadata.name.otelcolinstrumentation.hpa" . }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{{ $tracesGateway := .Values.tracesGateway }}
{{ $tracesEnabled := .Values.sumologic.traces.enabled }}
{{- if and $tracesEnabled $tracesGateway.enabled (eq (include "tracesGateway.autoscaling.enabled" .) "true") }}
{{- if and (eq .Capabilities.KubeVersion.Major "1") (lt (int (include "kubernetes.minor" .)) 23) }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2
{{- end }}
apiVersion: {{ include "apiVersion.horizontalPodAutoscaler" . }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "sumologic.metadata.name.tracesgateway.hpa" . }}
Expand Down
6 changes: 1 addition & 5 deletions deploy/helm/sumologic/templates/logs/common/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{{- if and (eq (include "logs.otelcol.enabled" .) "true") (eq (include "metadata.logs.autoscaling.enabled" .) "true") }}
{{- if and (eq .Capabilities.KubeVersion.Major "1") (lt (int (include "kubernetes.minor" .)) 23) }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2
{{- end }}
apiVersion: {{ include "apiVersion.horizontalPodAutoscaler" . }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "sumologic.metadata.name.logs.hpa" . }}
Expand Down
6 changes: 1 addition & 5 deletions deploy/helm/sumologic/templates/metrics/common/hpa.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{{- if and (eq (include "metrics.otelcol.enabled" .) "true") (eq (include "metadata.metrics.autoscaling.enabled" .) "true") }}
{{- if and (eq .Capabilities.KubeVersion.Major "1") (lt (int (include "kubernetes.minor" .)) 23) }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2
{{- end }}
apiVersion: {{ include "apiVersion.horizontalPodAutoscaler" . }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "sumologic.metadata.name.metrics.hpa" . }}
Expand Down

0 comments on commit a6fb970

Please sign in to comment.