Skip to content

Commit

Permalink
Merge pull request #52 from mage-ai/xiaoyou/hpa
Browse files Browse the repository at this point in the history
[xy] Support horizontal pod scaler in deployment
  • Loading branch information
wangxiaoyou1993 committed May 22, 2024
2 parents 33220e1 + 600a923 commit 35e6f5e
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
46 changes: 46 additions & 0 deletions charts/mageai/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{{- if not .Values.standaloneScheduler }}

{{- if .Values.hpa -}}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "mageai.fullname" . }}-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "mageai.fullname" . }}
{{- toYaml .Values.hpa | nindent 2 }}
{{- end }}

{{- else }}

{{- if .Values.scheduler.hpa -}}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.scheduler.name }}-scheduler-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Values.scheduler.name }}
{{- toYaml .Values.scheduler.hpa | nindent 2 }}
{{- end }}

---

{{- if .Values.webServer.hpa -}}
apiVersion: autoscaling/v1
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.webServer.name }}-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Values.webServer.name }}
{{- toYaml .Values.webServer.hpa | nindent 2 }}
{{- end }}

{{- end }}
15 changes: 14 additions & 1 deletion charts/mageai/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ scheduler:
# requests:
# cpu: 100m
# memory: 128Mi

# hpa:
# minReplicas: 1
# maxReplicas: 10
# targetCPUUtilizationPercentage: 50

# Effective if standaloneScheduler is true
webServer:
Expand All @@ -37,6 +40,10 @@ webServer:
# requests:
# cpu: 100m
# memory: 128Mi
# hpa:
# minReplicas: 1
# maxReplicas: 10
# targetCPUUtilizationPercentage: 50

# Enable redis if you want more replica
redis:
Expand Down Expand Up @@ -117,6 +124,12 @@ customLivenessProbe: {}
# Custom readiness probe
customReadinessProbe: {}

# Horizontal pod autoscaler
# hpa:
# minReplicas: 1
# maxReplicas: 10
# targetCPUUtilizationPercentage: 50

# We recommend creating the ingress separately instead of creating it using this chart.
# There is a corresponding Mage-Ingress chart to create an ingress for Mage if needed.
# This section is kept here for backwards compatibility.
Expand Down

0 comments on commit 35e6f5e

Please sign in to comment.