@@ -3,56 +3,41 @@ This template serves as a blueprint for horizontal pod autoscaler objects that a
3
3
using the common library.
4
4
*/} }
5
5
{ {- define " tc.v1.common.class.hpa" -} }
6
- { {- $targetName := include " tc.v1.common.lib.chart.names.fullname" . -} }
7
- { {- $fullName := include " tc.v1.common.lib.chart.names.fullname" . -} }
8
- { {- $hpaName := $fullName -} }
9
- { {- $values := .Values.hpa -} }
6
+ { {- $rootCtx := .rootCtx -} }
7
+ { {- $objectData := .objectData -} }
10
8
11
- { {- if hasKey . " ObjectValues" -} }
12
- { {- with .ObjectValues.hpa -} }
13
- { {- $values = . -} }
14
- { {- end -} }
15
- { {- end -} }
16
- { {- $hpaLabels := $values .labels -} }
17
- { {- $hpaAnnotations := $values .annotations -} }
18
-
19
- { {- if and (hasKey $values " nameOverride" ) $values .nameOverride -} }
20
- { {- $hpaName = printf " %v-%v" $hpaName $values .nameOverride -} }
21
- { {- end } }
9
+ { {- $_ := set $objectData " updatePolicy" ($objectData .updatePolicy | default dict) -} }
10
+ { {- $_ := set $objectData " resourcePolicy" ($objectData .resourcePolicy | default dict) } }
22
11
---
23
12
apiVersion: { { include " tc.v1.common.capabilities.hpa.apiVersion" $ } }
24
13
kind: HorizontalPodAutoscaler
25
14
metadata:
26
- name: { { $hpaName } }
27
- namespace: { { $.Values.namespace | default $.Values.global .namespace | default $.Release.Namespace } }
28
- { {- $labels := (mustMerge ($hpaLabels | default dict) (include " tc.v1.common.lib.metadata.allLabels" $ | fromYaml)) -} }
29
- { {- with (include " tc.v1.common.lib.metadata.render" (dict " rootCtx" $ " labels" $labels ) | trim) } }
15
+ name: { { $objectData .name } }
16
+ namespace: { { include " tc.v1.common.lib.metadata .namespace" (dict " rootCtx " $ rootCtx " objectData " $ objectData " caller " " hpa " ) } }
17
+ { {- $labels := (mustMerge ($objectData .labels | default dict) (include " tc.v1.common.lib.metadata.allLabels" $rootCtx | fromYaml)) -} }
18
+ { {- with (include " tc.v1.common.lib.metadata.render" (dict " rootCtx" $rootCtx " labels" $labels ) | trim) } }
30
19
labels:
31
20
{ {- . | nindent 4 } }
32
21
{ {- end -} }
33
- { {- $annotations := (mustMerge ($hpaAnnotations | default dict) (include " tc.v1.common.lib.metadata.allAnnotations" $ | fromYaml)) -} }
34
- { {- with (include " tc.v1.common.lib.metadata.render" (dict " rootCtx" $ " annotations" $annotations ) | trim) } }
22
+ { {- $annotations := (mustMerge ($objectData .annotations | default dict) (include " tc.v1.common.lib.metadata.allAnnotations" $rootCtx | fromYaml)) -} }
23
+ { {- with (include " tc.v1.common.lib.metadata.render" (dict " rootCtx" $rootCtx " annotations" $annotations ) | trim) } }
35
24
annotations:
36
25
{ {- . | nindent 4 } }
37
- { {- end - } }
26
+ { {- end } }
38
27
spec:
39
28
scaleTargetRef:
40
29
apiVersion: apps/v1
41
- kind: { { $values .targetKind | default ( include " tc.v1.common.names.controllerType" . ) } }
42
- name: { { $values .target | default $targetName } }
43
- minReplicas: { { $values .minReplicas | default 1 } }
44
- maxReplicas: { { $values .maxReplicas | default 3 } }
30
+ kind: { { $objectData .workload.type } }
31
+ name: { { $objectData .name } }
32
+ minReplicas: { { $objectData .minReplicas | default 1 } }
33
+ maxReplicas: { { $objectData .maxReplicas | default 3 } }
34
+ { {- with $objectData .metrics } }
45
35
metrics:
46
- { {- if $values .targetCPUUtilizationPercentage } }
47
- - type: Resource
48
- resource:
49
- name: cpu
50
- targetAverageUtilization: { { $values .targetCPUUtilizationPercentage } }
51
- { {- end -} }
52
- { {- if $values .targetMemoryUtilizationPercentage } }
53
- - type: Resource
54
- resource:
55
- name: memory
56
- targetAverageUtilization: { { $values .targetMemoryUtilizationPercentage } }
57
- { {- end -} }
36
+ { {- $objectData .metrics | toYaml | nindent 4 } }
37
+ { {- end -} }
38
+
39
+ { {- with $objectData .behavior } }
40
+ behavior:
41
+ { {- $objectData .behavior | toYaml | nindent 4 } }
42
+ { {- end -} }
58
43
{ {- end -} }
0 commit comments