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

Commit a45e637

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 285b1fe commit a45e637

File tree

9 files changed

+84
-34
lines changed

9 files changed

+84
-34
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
@@ -124,12 +124,12 @@ matches the snapshot:
124124
name: RELEASE-NAME-example-content
125125
namespace: NAMESPACE
126126
spec:
127-
maxReplicas: 5
127+
maxReplicas: 10
128128
metrics:
129129
- resource:
130130
name: cpu
131131
target:
132-
averageUtilization: 50
132+
averageUtilization: 80
133133
type: Utilization
134134
type: Resource
135135
minReplicas: 1
@@ -305,12 +305,12 @@ matches the snapshot (internalUrl):
305305
name: RELEASE-NAME-example-content
306306
namespace: NAMESPACE
307307
spec:
308-
maxReplicas: 5
308+
maxReplicas: 10
309309
metrics:
310310
- resource:
311311
name: cpu
312312
target:
313-
averageUtilization: 50
313+
averageUtilization: 80
314314
type: Utilization
315315
type: Resource
316316
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__/test_values_test.yaml.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ match the Snapshot:
181181
name: openmfp-kubernetes-graphql-gateway
182182
namespace: openmfp-system
183183
spec:
184-
maxReplicas: 5
184+
maxReplicas: 10
185185
metrics:
186186
- resource:
187187
name: cpu
188188
target:
189-
averageUtilization: 50
189+
averageUtilization: 80
190190
type: Utilization
191191
type: Resource
192192
minReplicas: 1

charts/kubernetes-graphql-gateway/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,15 @@ health:
111111
path: "/readyz"
112112
failureThreshold: 30
113113
periodSeconds: 10
114+
hpa:
115+
# Horizontal Pod Autoscaler configuration
116+
enabled: true
117+
minReplicas: 1
118+
maxReplicas: 10
119+
metrics:
120+
- type: Resource
121+
resource:
122+
name: cpu
123+
target:
124+
type: Utilization
125+
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
@@ -141,12 +141,12 @@ matches the snapshot:
141141
name: portal
142142
namespace: NAMESPACE
143143
spec:
144-
maxReplicas: 5
144+
maxReplicas: 10
145145
metrics:
146146
- resource:
147147
name: cpu
148148
target:
149-
averageUtilization: 50
149+
averageUtilization: 80
150150
type: Utilization
151151
type: Resource
152152
minReplicas: 1
@@ -344,12 +344,12 @@ matches the snapshot with istio disabled:
344344
name: portal
345345
namespace: NAMESPACE
346346
spec:
347-
maxReplicas: 5
347+
maxReplicas: 10
348348
metrics:
349349
- resource:
350350
name: cpu
351351
target:
352-
averageUtilization: 50
352+
averageUtilization: 80
353353
type: Utilization
354354
type: Resource
355355
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)