Skip to content

Commit

Permalink
#14 implemented HPA for magento pods
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenix-bjoern committed Feb 20, 2024
1 parent 9030e0c commit 0a65be2
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ci/kind-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
magento:
podDisruptionBudget:
enabled: true
horizontalPodAutoscaler:
enabled: true

opensearch:
extraEnvs:
Expand Down
27 changes: 27 additions & 0 deletions templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- if .Values.magento.horizontalPodAutoscaler.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "magento.name" . }}
labels:
{{- include "magento.labels" . | nindent 4 }}
{{- range $key, $val := ($.Values.magento.labels | default dict) }}
{{ $key }}: {{ $val | quote }}
{{- end }}
spec:
scaleTargetRef:
kind: Deployment
name: {{ include "magento.name" . }}
apiVersion: apps/v1
{{- with .Values.magento.horizontalPodAutoscaler }}
minReplicas: {{ .minCount | default 1 }}
maxReplicas: {{ .maxCount | default 3 }}
behavior:
scaleUp:
{{- toYaml .scaleUp | nindent 6 }}
scaleDown:
{{- toYaml .scaleDown | nindent 6 }}
metrics:
{{- toYaml .metrics | nindent 4 }}
{{- end }}
{{- end }}
29 changes: 29 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,40 @@ magento:
maxSurge: 100%
maxUnavailable: 0
type: RollingUpdate

podDisruptionBudget:
enabled: false
minAvailable: 0
maxUnavailable: 1

# HPA configuration, see https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/#configurable-scaling-behavior
horizontalPodAutoscaler:
enabled: false
minCount: 1
maxCount: 3

scaleUp:
policies:
- type: Pods
value: 1
periodSeconds: 60
stabilizationWindowSeconds: 300

scaleDown:
policies:
- type: Pods
value: 1
periodSeconds: 60
stabilizationWindowSeconds: 300

metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 80

podSecurityContext: {}
securityContext: {}
tolerations: []
Expand Down

0 comments on commit 0a65be2

Please sign in to comment.