HPA API version may not fit with Kubernetes version
Summary
The chart may no longer work depending on the apiVersion getting updated or deprecated with a release of Kubernetes.
Steps to reproduce
Can't reproduce at this time as the latest Kubernetes version (1.20 as I write) marked autoscaling/v2beta1 as deprecated not removed.
Configuration used
The concerned block can be found in several files :
It looks like this :
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "fullname" . }}
namespace: {{ $.Release.Namespace }}
labels:
{{- include "gitlab.standardLabels" . | nindent 4 }}
{{- include "gitlab.commonLabels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "fullname" . }}
minReplicas: {{ .Values.minReplicas }}
maxReplicas: {{ .Values.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
targetAverageValue: {{ .Values.hpa.targetAverageValue }}
Current behavior
This issue seems highly related to #2569 (closed) (should I close the issue and comment on the already opened discussion ?)
The apiVersion can't be changed without forking the chart. But, even if It had been possible, the spec could have changed between two versions. Some services permit metric spec overrides via .Values.hpa.customMetrics but not all.
metrics:
{{- if not .Values.hpa.customMetrics }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.hpa.cpu.targetAverageUtilization }}
{{- else -}}
{{- toYaml .Values.hpa.customMetrics | nindent 4 -}}
{{- end -}}
Expected behavior
The chart should continue to work when upgrading Kubernetes or, at least, allows the operator to configure the chart to make It work on several Kubernetes versions.
Versions
- Kubernetes: 1.20