Skip to content

Commit 9ea815d

Browse files
BrianPark314BrianPark314
andauthored
feat: add hpa for router (#568)
* feat: add hpa for router Signed-off-by: BrianPark314 <[email protected]> * feat: add hpa for router Signed-off-by: BrianPark314 <[email protected]> * fix: correct memory request Signed-off-by: BrianPark314 <[email protected]> * fix: correct resource management Signed-off-by: BrianPark314 <[email protected]> --------- Signed-off-by: BrianPark314 <[email protected]> Co-authored-by: BrianPark314 <[email protected]>
1 parent 13f5281 commit 9ea815d

File tree

4 files changed

+50
-4
lines changed

4 files changed

+50
-4
lines changed

helm/templates/deployment-router.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ metadata:
77
labels:
88
{{- include "chart.routerLabels" . | nindent 4 }}
99
spec:
10+
{{- if .Values.routerSpec.autoscaling.enabled }}
11+
replicas: {{ .Values.routerSpec.autoscaling.minReplicas }}
12+
{{- else }}
1013
replicas: {{ .Values.routerSpec.replicaCount }}
14+
{{- end }}
1115
{{- include "chart.routerStrategy" . | nindent 2 }}
1216
selector:
1317
matchLabels:
@@ -118,8 +122,12 @@ spec:
118122
{{- end }}
119123
{{- if .Values.routerSpec.resources.limits }}
120124
limits:
125+
{{- if .Values.routerSpec.resources.limits.cpu }}
121126
cpu: "{{ .Values.routerSpec.resources.limits.cpu }}"
127+
{{- end }}
128+
{{- if .Values.routerSpec.resources.limits.memory }}
122129
memory: "{{ .Values.routerSpec.resources.limits.memory }}"
130+
{{- end }}
123131
{{- end }}
124132
{{- end }}
125133
ports:

helm/templates/hpa-router.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- if .Values.routerSpec.autoscaling.enabled -}}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: "{{ .Release.Name }}-router-hpa"
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "chart.routerLabels" . | nindent 4 }}
9+
spec:
10+
scaleTargetRef:
11+
apiVersion: apps/v1
12+
kind: Deployment
13+
name: "{{ .Release.Name }}-deployment-router"
14+
minReplicas: {{ .Values.routerSpec.autoscaling.minReplicas }}
15+
maxReplicas: {{ .Values.routerSpec.autoscaling.maxReplicas }}
16+
metrics:
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.routerSpec.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end -}}

helm/values.schema.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,15 @@
398398
"replicaCount": {
399399
"type": "integer"
400400
},
401+
"autoscaling": {
402+
"type": "object",
403+
"properties": {
404+
"enabled": {"type": "boolean"},
405+
"minReplicas": {"type": "integer"},
406+
"maxReplicas": {"type": "integer"},
407+
"targetCPUUtilizationPercentage": {"type": "integer"}
408+
}
409+
},
401410
"containerPort": {
402411
"type": "integer"
403412
},

helm/values.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,13 @@ routerSpec:
268268
# -- Number of replicas
269269
replicaCount: 1
270270

271+
# -- autoscaling configuration
272+
autoscaling:
273+
enabled: false
274+
minReplicas: 1
275+
maxReplicas: 3
276+
targetCPUUtilizationPercentage: 80
277+
271278
# -- Priority Class
272279
priorityClassName: ""
273280

@@ -314,11 +321,10 @@ routerSpec:
314321
# -- router resource requests and limits
315322
resources:
316323
requests:
317-
cpu: "4"
318-
memory: "16G"
324+
cpu: 400m
325+
memory: 500Mi
319326
limits:
320-
cpu: "8"
321-
memory: "32G"
327+
memory: 500Mi
322328

323329
# -- Customized labels for the router deployment
324330
labels:

0 commit comments

Comments
 (0)