Skip to content
This repository was archived by the owner on Sep 25, 2025. It is now read-only.

Commit e71df5c

Browse files
committed
feat(hpa): add Horizontal Pod Autoscaler configuration with customizable replicas and metrics
On-behalf-of: @SAP [email protected] Signed-off-by: Angel Kafazov <[email protected]>
1 parent f8b4e82 commit e71df5c

File tree

10 files changed

+87
-36
lines changed

10 files changed

+87
-36
lines changed
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
{{- if .Values.hpa.enabled }}
12
apiVersion: autoscaling/v2
23
kind: HorizontalPodAutoscaler
34
metadata:
45
name: {{ include "common.entity.name" . }}
56
namespace: {{ .Release.Namespace }}
67
spec:
7-
maxReplicas: 5
8+
minReplicas: {{ .Values.hpa.minReplicas }}
9+
maxReplicas: {{ .Values.hpa.maxReplicas }}
810
metrics:
9-
- resource:
10-
name: cpu
11-
target:
12-
averageUtilization: 50
13-
type: Utilization
14-
type: Resource
15-
minReplicas: 1
11+
{{- range .Values.hpa.metrics }}
12+
- type: {{ .type }}
13+
resource:
14+
name: {{ .resource.name }}
15+
target:
16+
type: {{ .resource.target.type }}
17+
averageUtilization: {{ .resource.target.averageUtilization }}
18+
{{- end }}
1619
scaleTargetRef:
1720
apiVersion: apps/v1
1821
kind: Deployment
1922
name: {{ include "common.entity.name" . }}
23+
{{- end }}

charts/example-content/tests/__snapshot__/snapshot_test.yaml.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,12 @@ matches the snapshot:
106106
name: RELEASE-NAME-example-content
107107
namespace: NAMESPACE
108108
spec:
109-
maxReplicas: 5
109+
maxReplicas: 10
110110
metrics:
111111
- resource:
112112
name: cpu
113113
target:
114-
averageUtilization: 50
114+
averageUtilization: 80
115115
type: Utilization
116116
type: Resource
117117
minReplicas: 1
@@ -269,12 +269,12 @@ matches the snapshot (internalUrl):
269269
name: RELEASE-NAME-example-content
270270
namespace: NAMESPACE
271271
spec:
272-
maxReplicas: 5
272+
maxReplicas: 10
273273
metrics:
274274
- resource:
275275
name: cpu
276276
target:
277-
averageUtilization: 50
277+
averageUtilization: 80
278278
type: Utilization
279279
type: Resource
280280
minReplicas: 1

charts/example-content/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ contentConfigurations:
3333
# internalUrl: null
3434

3535
contentProtocolDomain: https://example-content.some-domain.com
36+
37+
hpa:
38+
# Horizontal Pod Autoscaler configuration
39+
enabled: true
40+
minReplicas: 1
41+
maxReplicas: 10
42+
metrics:
43+
- type: Resource
44+
resource:
45+
name: cpu
46+
target:
47+
type: Utilization
48+
averageUtilization: 80
Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
{{- if .Values.hpa.enabled }}
12
apiVersion: autoscaling/v2
23
kind: HorizontalPodAutoscaler
34
metadata:
45
name: {{ include "common.entity.name" . }}
56
namespace: {{ .Release.Namespace }}
67
spec:
7-
maxReplicas: 5
8+
minReplicas: {{ .Values.hpa.minReplicas }}
9+
maxReplicas: {{ .Values.hpa.maxReplicas }}
810
metrics:
9-
- resource:
10-
name: cpu
11-
target:
12-
averageUtilization: 50
13-
type: Utilization
14-
type: Resource
15-
minReplicas: 1
11+
{{- range .Values.hpa.metrics }}
12+
- type: {{ .type }}
13+
resource:
14+
name: {{ .resource.name }}
15+
target:
16+
type: {{ .resource.target.type }}
17+
averageUtilization: {{ .resource.target.averageUtilization }}
18+
{{- end }}
1619
scaleTargetRef:
1720
apiVersion: apps/v1
1821
kind: Deployment
1922
name: {{ include "common.entity.name" . }}
23+
{{- end }}

charts/kubernetes-graphql-gateway/tests/__snapshot__/snapshot_test.yaml.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ match the Snapshot:
130130
name: openmfp-kubernetes-graphql-gateway
131131
namespace: openmfp-system
132132
spec:
133-
maxReplicas: 5
133+
maxReplicas: 10
134134
metrics:
135135
- resource:
136136
name: cpu
137137
target:
138-
averageUtilization: 50
138+
averageUtilization: 80
139139
type: Utilization
140140
type: Resource
141141
minReplicas: 1

charts/kubernetes-graphql-gateway/tests/__snapshot__/test_values_test.yaml.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ match the Snapshot:
138138
name: openmfp-kubernetes-graphql-gateway
139139
namespace: openmfp-system
140140
spec:
141-
maxReplicas: 5
141+
maxReplicas: 10
142142
metrics:
143143
- resource:
144144
name: cpu
145145
target:
146-
averageUtilization: 50
146+
averageUtilization: 80
147147
type: Utilization
148148
type: Resource
149149
minReplicas: 1

charts/kubernetes-graphql-gateway/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,16 @@ extraVolumeMounts: []
8989

9090
tracing:
9191
enabled: true
92+
93+
hpa:
94+
# Horizontal Pod Autoscaler configuration
95+
enabled: true
96+
minReplicas: 1
97+
maxReplicas: 10
98+
metrics:
99+
- type: Resource
100+
resource:
101+
name: cpu
102+
target:
103+
type: Utilization
104+
averageUtilization: 80

charts/portal/templates/hpa.yaml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
{{- if .Values.hpa.enabled }}
12
apiVersion: autoscaling/v2
23
kind: HorizontalPodAutoscaler
34
metadata:
45
name: {{ include "common.entity.name" . }}
56
namespace: {{ .Release.Namespace }}
67
spec:
7-
maxReplicas: 5
8+
minReplicas: {{ .Values.hpa.minReplicas }}
9+
maxReplicas: {{ .Values.hpa.maxReplicas }}
810
metrics:
9-
- resource:
10-
name: cpu
11-
target:
12-
averageUtilization: 50
13-
type: Utilization
14-
type: Resource
15-
minReplicas: 1
11+
{{- range .Values.hpa.metrics }}
12+
- type: {{ .type }}
13+
resource:
14+
name: {{ .resource.name }}
15+
target:
16+
type: {{ .resource.target.type }}
17+
averageUtilization: {{ .resource.target.averageUtilization }}
18+
{{- end }}
1619
scaleTargetRef:
1720
apiVersion: apps/v1
1821
kind: Deployment
1922
name: {{ include "common.entity.name" . }}
23+
{{- end }}

charts/portal/tests/__snapshot__/istio_test.yaml.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ matches the snapshot:
123123
name: portal
124124
namespace: NAMESPACE
125125
spec:
126-
maxReplicas: 5
126+
maxReplicas: 10
127127
metrics:
128128
- resource:
129129
name: cpu
130130
target:
131-
averageUtilization: 50
131+
averageUtilization: 80
132132
type: Utilization
133133
type: Resource
134134
minReplicas: 1
@@ -308,12 +308,12 @@ matches the snapshot with istio disabled:
308308
name: portal
309309
namespace: NAMESPACE
310310
spec:
311-
maxReplicas: 5
311+
maxReplicas: 10
312312
metrics:
313313
- resource:
314314
name: cpu
315315
target:
316-
averageUtilization: 50
316+
averageUtilization: 80
317317
type: Utilization
318318
type: Resource
319319
minReplicas: 1

charts/portal/values.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,16 @@ health:
7777
startup:
7878
# -- path used for the startup probe
7979
path: /rest/health
80+
81+
hpa:
82+
# Horizontal Pod Autoscaler configuration
83+
enabled: true
84+
minReplicas: 1
85+
maxReplicas: 10
86+
metrics:
87+
- type: Resource
88+
resource:
89+
name: cpu
90+
target:
91+
type: Utilization
92+
averageUtilization: 80

0 commit comments

Comments
 (0)