-
Notifications
You must be signed in to change notification settings - Fork 522
/
Copy pathhpa.yaml
89 lines (89 loc) · 3.12 KB
/
hpa.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{{- if $.Values.autoscaling.enabled }}
{{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: autoscaling/v2
{{- else if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
apiVersion: autoscaling/v2beta2
{{- else }}
apiVersion: autoscaling/v2beta1
{{- end }}
kind: HorizontalPodAutoscaler
metadata:
name: {{ template ".Chart.Name .fullname" $ }}-hpa
{{- if .Values.autoscaling.annotations }}
annotations:
{{ toYaml .Values.autoscaling.annotations | indent 4 }}
{{- end }}
labels:
appId: {{ $.Values.app | quote }}
envId: {{ $.Values.env | quote }}
app: {{ template ".Chart.Name .name" $ }}
chart: {{ template ".Chart.Name .chart" $ }}
release: {{ $.Release.Name }}
{{- if .Values.autoscaling.labels }}
{{ toYaml .Values.autoscaling.labels | indent 4 }}
{{- end }}
{{- if $.Values.appLabels }}
{{ toYaml $.Values.appLabels | indent 4 }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: argoproj.io/v1alpha1
kind: Rollout
name: {{ include ".Chart.Name .fullname" $ }}
minReplicas: {{ $.Values.autoscaling.MinReplicas }}
maxReplicas: {{ $.Values.autoscaling.MaxReplicas }}
metrics:
{{- if $.Values.autoscaling.containerResource.enabled }}
{{- with $.Values.autoscaling.containerResource }}
{{- if .TargetCPUUtilizationPercentage }}
- type: ContainerResource
containerResource:
name: cpu
container: {{ $.Chart.Name }}
target:
type: Utilization
averageUtilization: {{ .TargetCPUUtilizationPercentage }}
{{- end}}
{{- if .TargetMemoryUtilizationPercentage }}
- type: ContainerResource
containerResource:
name: memory
container: {{ $.Chart.Name }}
target:
type: Utilization
averageUtilization: {{ .TargetMemoryUtilizationPercentage }}
{{- end}}
{{- end }}
{{- end }}
{{- if $.Values.autoscaling.TargetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }}
{{- else }}
targetAverageUtilization: {{ $.Values.autoscaling.TargetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if $.Values.autoscaling.TargetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
{{- if semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion }}
target:
type: Utilization
averageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }}
{{- else }}
targetAverageUtilization: {{ $.Values.autoscaling.TargetCPUUtilizationPercentage }}
{{- end }}
{{- end }}
{{- if and $.Values.autoscaling.extraMetrics (semverCompare ">=1.16-0" .Capabilities.KubeVersion.GitVersion) }}
{{- toYaml $.Values.autoscaling.extraMetrics | nindent 2 }}
{{- end}}
{{- if and $.Values.autoscaling.behavior (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
behavior:
{{- toYaml $.Values.autoscaling.behavior | nindent 4 }}
{{- end }}
{{- end }}