Skip to content

Commit 34ef16b

Browse files
committed
K8s: Update ScaledJob scaling strategy to eager as default
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 33471fe commit 34ef16b

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

charts/selenium-grid/templates/_helpers.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ triggers:
249249
authenticationRef:
250250
name: {{ template "seleniumGrid.autoscaling.authenticationRef.fullname" $ }}
251251
useCachedMetrics: {{ $.Values.autoscaling.useCachedMetrics }}
252+
{{- if eq $.Values.autoscaling.scalingType "deployment" -}}
252253
metricType: {{ $.Values.autoscaling.metricType }}
254+
{{- end -}}
253255
{{- end }}
254256
{{- end -}}
255257

charts/selenium-grid/templates/patch-keda/patch-keda-objects-job.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ spec:
3535
- |
3636
echo "Cleaning up ScaledObjects, ScaledJobs and HPAs for {{ .Release.Name }} when upgrading or disabling autoscaling."
3737
kubectl get ScaledObjects,ScaledJobs,TriggerAuthentication -n {{ .Release.Namespace }} -l component.autoscaling={{ .Release.Name }} -o=json | jq '.metadata.finalizers = null' | kubectl apply -f - || true ;
38-
kubectl delete ScaledObjects,ScaledJobs,TriggerAuthentication -n {{ .Release.Namespace }} -l component.autoscaling={{ .Release.Name }} --wait || true ;
39-
kubectl delete hpa -n {{ .Release.Namespace }} -l component.autoscaling={{ .Release.Name }} --wait || true ;
38+
kubectl delete ScaledObjects,ScaledJobs,TriggerAuthentication -n {{ .Release.Namespace }} -l component.autoscaling={{ .Release.Name }} --wait false || true ;
39+
kubectl delete hpa -n {{ .Release.Namespace }} -l component.autoscaling={{ .Release.Name }} --wait false || true ;
4040
{{- with $.Values.autoscaling.patchObjectFinalizers.resources }}
4141
resources: {{ toYaml . | nindent 12 }}
4242
{{- end }}

charts/selenium-grid/values.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ rbacRole:
156156
- apiGroups:
157157
- keda.sh
158158
resources:
159-
- triggerauthentication
159+
- triggerauthentications
160160
verbs: [get, list, patch, update, delete]
161161
- apiGroups:
162162
- autoscaling
@@ -835,15 +835,17 @@ autoscaling:
835835
name: ""
836836
annotations:
837837
"helm.sh/hook": post-install,post-upgrade,post-rollback
838-
"helm.sh/hook-weight": "-2"
838+
# TriggerAuthentication is used by ScaledObject/ScaledJob, hence weight should be less than those hooks
839+
"helm.sh/hook-weight": "0"
839840
# Configuration for ScaledObject triggers https://keda.sh/docs/latest/reference/scaledobject-spec/#triggers
840841
# -- Enables caching of metric values during polling interval (as specified in .spec.pollingInterval).
841-
useCachedMetrics: true
842+
useCachedMetrics: false
842843
# -- The type of metric that should be used (Override the default: AverageValue in KEDA)
843844
metricType: Value
844845
# -- Annotations for KEDA resources: ScaledObject and ScaledJob
845846
annotations:
846847
"helm.sh/hook": post-install,post-upgrade,post-rollback
848+
# Ensure the weight should be higher than TriggerAuthentication hook
847849
"helm.sh/hook-weight": "1"
848850
patchObjectFinalizers:
849851
# -- Override the name of the patch job
@@ -856,6 +858,7 @@ autoscaling:
856858
annotations:
857859
"helm.sh/hook": post-install,post-upgrade,post-rollback,pre-delete
858860
"helm.sh/hook-delete-policy": hook-succeeded,before-hook-creation
861+
# This should be run before all other hooks (since delete action is called), so use a negative weight
859862
"helm.sh/hook-weight": "-1"
860863
# -- Define an external service account name contains permissions to patch KEDA scaled resources
861864
serviceAccount: ""
@@ -882,9 +885,9 @@ autoscaling:
882885
# Options for KEDA ScaledJobs (only used when scalingType is set to "job"). See https://keda.sh/docs/latest/concepts/scaling-jobs/#scaledjob-spec
883886
scaledJobOptions:
884887
scalingStrategy:
885-
# Offer the strategy default with scaler calculation updated in https://github.com/SeleniumHQ/docker-selenium/tree/trunk/.keda/README.md
886-
# -- Scaling strategy for KEDA ScaledJob
887-
strategy: accurate
888+
# Use `eager` strategy for utilizing all available slots up to the maxReplicaCount, ensuring that waiting request are processed as quickly as possible.
889+
# -- Scaling strategy for KEDA ScaledJob - https://keda.sh/docs/latest/reference/scaledjob-spec/#scalingstrategy
890+
strategy: eager
888891
# -- Number of Completed jobs should be kept
889892
successfulJobsHistoryLimit: 0
890893
# -- Number of Failed jobs should be kept (for troubleshooting purposes)

0 commit comments

Comments
 (0)