Describe the bug
When making use of the 'autoscaling' in a Helm chart for a Kubernetes deployment, the output is incorrect.
Version of Helm and Kubernetes:
Helm Version:
$ helm version
version.BuildInfo{Version:"v3.12.3", GitCommit:"3a31588ad33fe3b89af5a2a54ee1d25bfe6eaa5e", GitTreeState:"clean", GoVersion:"go1.20.7"}
Kubernetes Version:
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"27", GitVersion:"v1.27.1", GitCommit:"4c9411232e10168d7b050c49a1b59f6df9d7ea4b", GitTreeState:"clean", BuildDate:"202
3-04-14T13:14:41Z", GoVersion:"go1.20.3", Compiler:"gc", Platform:"darwin/arm64"}
Kustomize Version: v5.0.1
Server Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.6", GitCommit:"b39bf148cd654599a52e867485c02c4f9d28b312", GitTreeState:"clean", BuildDate:"202
2-09-22T05:53:51Z", GoVersion:"go1.18.6", Compiler:"gc", Platform:"linux/arm64"}
Which version of the chart:
latest centrifugo-11.0.2
What happened:
When using the chart with autoscaling enabled.
helm template cent ./charts/centrifugo --set autoscaling.enabled=true \
--set autoscaling.minReplicas=1 \
--set autoscaling.maxReplicas=3 \
--set autoscaling.cpu.enabled=true \
--set autoscaling.cpu.targetCPUUtilizationPercentage=80 \
--set autoscaling.memory.enabled=true \
--set autoscaling.memory.targetMemoryUtilizationPercentage=80 \
-a autoscaling/v1 \
--debug --dry-run
The resulting HorizontalPodAutoscaler is like this
apiVersion: "autoscaling/v1"
kind: HorizontalPodAutoscaler
metadata:
name: cent-centrifugo
namespace: default
labels:
helm.sh/chart: centrifugo-11.0.1
app.kubernetes.io/name: centrifugo
app.kubernetes.io/instance: cent
app.kubernetes.io/version: "5.0.2"
app.kubernetes.io/managed-by: Helm
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: cent-centrifugo
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
test: |
[autoscaling/v2beta2]
name: cpu
targetAverageUtilization:
- type: Resource
resource:
name: memory
targetAverageUtilization:
helm template cent ./charts/centrifugo --set autoscaling.enabled=true \
--set autoscaling.minReplicas=1 \
--set autoscaling.maxReplicas=3 \
--set autoscaling.cpu.enabled=true \
--set autoscaling.cpu.targetCPUUtilizationPercentage=80 \
--set autoscaling.memory.enabled=true \
--set autoscaling.memory.targetMemoryUtilizationPercentage=80 \
-a autoscaling/v2 \
--debug --dry-run
apiVersion: "autoscaling/v2"
kind: HorizontalPodAutoscaler
metadata:
name: cent-centrifugo
namespace: default
labels:
helm.sh/chart: centrifugo-11.0.1
app.kubernetes.io/name: centrifugo
app.kubernetes.io/instance: cent
app.kubernetes.io/version: "5.0.2"
app.kubernetes.io/managed-by: Helm
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: cent-centrifugo
minReplicas: 1
maxReplicas: 3
metrics:
- type: Resource
resource:
test: |
[autoscaling/v2]
name: cpu
target:
type: Utilization
averageUtilization:
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization:
As you can notived the missing utlization values in both api version (autoscaling/v2 and autoscaling/v2beta1)
How to reproduce it:
See above
Anything else we need to know:
The issue introduced by the PR #64
Which changes the utilization values position in values.yaml but not in the actual template.
As it still referring to Values.autoscaling.targetCPUUtilizationPercentage
instead of Values.autoscaling.cpu.targetCPUUtilizationPercentage
.
Another Issue the template uses targetCPUUtilizationPercentage
for the memory target utilization
{{- if .Values.autoscaling.memory.enabled }}
- type: Resource
resource:
name: memory
{{- if .Capabilities.APIVersions.Has "autoscaling/v2" }}
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- else }}
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- end }}