Skip to content

Commit bd94f3f

Browse files
Mohamadamin Karamigzigzigzeo
authored andcommitted
feat: add independent scale-up and scale-down HPA behaviors
1 parent 798754e commit bd94f3f

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

imgproxy/templates/horizontal-pod-autoscaler.yaml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,25 @@ spec:
2525
apiVersion: apps/v1
2626
behavior:
2727
scaleDown:
28+
{{- $scaleDown := .scaleDownBehavior | default dict }}
2829
policies:
2930
- type: Pods
30-
value: {{ .stepCount | default 1 | max 1 }}
31-
periodSeconds: {{ .stepSeconds | default 60 | max 1 | min 1800 }}
32-
stabilizationWindowSeconds: {{ .stabilizationInterval | default 300 | max 0 | min 3600 }}
31+
value: {{ $scaleDown.stepCount | default .stepCount | default 1 | max 1 }}
32+
periodSeconds: {{ $scaleDown.stepSeconds | default .stepSeconds | default 60 | max 1 | min 1800 }}
33+
stabilizationWindowSeconds: {{ $scaleDown.stabilizationInterval | default .stabilizationInterval | default 300 | max 0 | min 3600 }}
34+
{{- if $scaleDown.selectPolicy }}
35+
selectPolicy: {{ $scaleDown.selectPolicy }}
36+
{{- end }}
3337
scaleUp:
38+
{{- $scaleUp := .scaleUpBehavior | default dict }}
3439
policies:
3540
- type: Pods
36-
value: {{ .stepCount | default 1 | max 1 }}
37-
periodSeconds: {{ .stepSeconds | default 60 | max 1 | min 1800 }}
38-
stabilizationWindowSeconds: {{ .stabilizationInterval | default 300 | max 0 | min 3600 }}
41+
value: {{ $scaleUp.stepCount | default .stepCount | default 1 | max 1 }}
42+
periodSeconds: {{ $scaleUp.stepSeconds | default .stepSeconds | default 60 | max 1 | min 1800 }}
43+
stabilizationWindowSeconds: {{ $scaleUp.stabilizationInterval | default .stabilizationInterval | default 300 | max 0 | min 3600 }}
44+
{{- if $scaleUp.selectPolicy }}
45+
selectPolicy: {{ $scaleUp.selectPolicy }}
46+
{{- end }}
3947
metrics:
4048
- type: Resource
4149
resource:

imgproxy/values.yaml

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ resources:
7878

7979
# The number of seconds for which past recommendations
8080
# should be considered while scaling up or scaling down (0 - 3600).
81-
# The period will be the same for both up- and downscaling.
81+
# This is used as the default for both directions unless overridden by
82+
# scaleUpBehavior.stabilizationInterval or scaleDownBehavior.stabilizationInterval.
8283
#
8384
# The setting is used if `minCount < maxCount` only (default 300 seconds).
8485
stabilizationInterval: 300
@@ -90,6 +91,28 @@ resources:
9091
# The setting MUST be set if `minCount < maxCount` only.
9192
cpuUtilization: 80
9293

94+
# Optional: Independent scale-up behavior configuration.
95+
# When specified, these settings override the shared settings above for scaling UP only.
96+
# If not specified, the shared settings (stepCount, stepSeconds, stabilizationInterval) are used.
97+
#
98+
# All fields are optional - you can override only specific settings.
99+
scaleUpBehavior:
100+
# stepCount: 6 # Number of pods to add per scaling step (overrides shared stepCount)
101+
# stepSeconds: 30 # Period between scaling steps in seconds (overrides shared stepSeconds)
102+
# stabilizationInterval: 60 # Stabilization window in seconds (overrides shared stabilizationInterval)
103+
# selectPolicy: Max # Policy for selecting which recommendation to use (Min, Max, Disabled)
104+
105+
# Optional: Independent scale-down behavior configuration.
106+
# When specified, these settings override the shared settings above for scaling DOWN only.
107+
# If not specified, the shared settings (stepCount, stepSeconds, stabilizationInterval) are used.
108+
#
109+
# All fields are optional - you can override only specific settings.
110+
scaleDownBehavior:
111+
# stepCount: 1 # Number of pods to remove per scaling step (overrides shared stepCount)
112+
# stepSeconds: 300 # Period between scaling steps in seconds (overrides shared stepSeconds)
113+
# stabilizationInterval: 600 # Stabilization window in seconds (overrides shared stabilizationInterval)
114+
# selectPolicy: Min # Policy for selecting which recommendation to use (Min, Max, Disabled)
115+
93116
# See https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy
94117
strategy:
95118
rollingUpdate:

0 commit comments

Comments
 (0)