-
Notifications
You must be signed in to change notification settings - Fork 36
/
pod-autoscaling.yaml
77 lines (76 loc) · 2.46 KB
/
pod-autoscaling.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
{{- if $.Values.autoScaling}}
{{- if $.Values.autoScaling.horizontal }}
{{- if gt $.Values.autoScaling.horizontal.maxReplicas $.Values.replicas }}
{{- $kind := "Deployment" }}
{{- range $containerIndex, $container := $.Values.containers }}
{{- range $volumeMountIndex, $volumeMount := $container.volumeMounts }}
{{- if $volumeMount.volume.readOnly }}
{{- else }}
{{- range $volumeIndex, $volume := $.Values.volumes }}
{{- if eq $volumeMount.volume.name $volume.name }}
{{- $kind = "StatefulSet" }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ $.Release.Name | quote }}
labels:
"app.kubernetes.io/name": "devspace-app"
"app.kubernetes.io/component": {{ $.Release.Name | quote }}
"app.kubernetes.io/managed-by": {{ $.Release.Service | quote }}
{{- range $labelName, $labelValue := $.Values.labels }}
{{ $labelName | quote }}: {{ $labelValue | quote }}
{{- end }}
annotations:
"helm.sh/chart": "{{ $.Chart.Name }}-{{ $.Chart.Version }}"
{{- range $annotationName, $annotationValue := $.Values.annotations }}
{{ $annotationName | quote }}: {{ $annotationValue | quote }}
{{- end }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: {{ $kind }}
name: {{ $.Release.Name | quote }}
minReplicas: {{ $.Values.replicas }}
maxReplicas: {{ $.Values.autoScaling.horizontal.maxReplicas }}
metrics:
{{- if $.Values.autoScaling.horizontal.averageCPU }}
- type: Resource
resource:
name: cpu
target:
type: AverageValue
averageValue: {{ $.Values.autoScaling.horizontal.averageCPU }}
{{- end }}
{{- if $.Values.autoScaling.horizontal.averageRelativeCPU }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ $.Values.autoScaling.horizontal.averageRelativeCPU | int }}
{{- end }}
{{- if $.Values.autoScaling.horizontal.averageMemory }}
- type: Resource
resource:
name: memory
target:
type: AverageValue
averageValue: {{ $.Values.autoScaling.horizontal.averageMemory | quote }}
{{- end }}
{{- if $.Values.autoScaling.horizontal.averageRelativeMemory }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ $.Values.autoScaling.horizontal.averageRelativeMemory | int }}
{{- end }}
---
{{- end }}
{{- end }}
{{- end }}