Skip to content

Commit 3dddb7d

Browse files
authored
K8s: Update ScaledJob scaling strategy to eager as default (#2466)
1 parent 33471fe commit 3dddb7d

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

Diff for: charts/selenium-grid/CONFIGURATION.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
7979
| serviceAccount.create | bool | `true` | Create a service account for all components. If using an external service account, set to false and provide its name in `nameOverride` below |
8080
| serviceAccount.nameOverride | string | `nil` | Override to use an external service account |
8181
| serviceAccount.annotations | object | `{}` | Annotations for the service account |
82-
| rbacRole | object | `{"annotations":{},"create":true,"nameOverride":null,"rules":[{"apiGroups":["keda.sh"],"resources":["scaledjobs"],"verbs":["get","list","patch","update","delete"]},{"apiGroups":["keda.sh"],"resources":["scaledobjects"],"verbs":["get","list","patch","update","delete"]},{"apiGroups":["keda.sh"],"resources":["triggerauthentication"],"verbs":["get","list","patch","update","delete"]},{"apiGroups":["autoscaling"],"resources":["horizontalpodautoscalers"],"verbs":["get","list","patch","update","delete"]}]}` | RBAC settings for patching finalizers KEDA scaled resources |
82+
| rbacRole | object | `{"annotations":{},"create":true,"nameOverride":null,"rules":[{"apiGroups":["keda.sh"],"resources":["scaledjobs"],"verbs":["get","list","patch","update","delete"]},{"apiGroups":["keda.sh"],"resources":["scaledobjects"],"verbs":["get","list","patch","update","delete"]},{"apiGroups":["keda.sh"],"resources":["triggerauthentications"],"verbs":["get","list","patch","update","delete"]},{"apiGroups":["autoscaling"],"resources":["horizontalpodautoscalers"],"verbs":["get","list","patch","update","delete"]}]}` | RBAC settings for patching finalizers KEDA scaled resources |
8383
| rbacRole.create | bool | `true` | Enable to create RBAC role to access few KEDA resources. If using an external role, set to false and provide its name in `nameOverride` below |
8484
| rbacRole.nameOverride | string | `nil` | Override resource name or provide an external role name |
8585
| rbacRoleBinding | object | `{"annotations":{},"create":true,"nameOverride":null,"roleRef":{"apiGroup":"rbac.authorization.k8s.io","kind":"Role"},"subjects":[{"kind":"ServiceAccount"}]}` | RBAC role binding settings for patching finalizers KEDA scaled resources |
@@ -326,8 +326,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
326326
| autoscaling.enabled | bool | `false` | Enable autoscaling. Implies installing KEDA |
327327
| autoscaling.enableWithExistingKEDA | bool | `false` | Enable autoscaling without automatically installing KEDA |
328328
| autoscaling.scalingType | string | `"job"` | Which type of KEDA scaling to use: job or deployment |
329-
| autoscaling.authenticationRef | object | `{"annotations":{"helm.sh/hook":"post-install,post-upgrade,post-rollback","helm.sh/hook-weight":"-2"},"name":""}` | Specify an external KEDA TriggerAuthentication resource is used for scaler triggers config. Apply for all browser nodes |
330-
| autoscaling.useCachedMetrics | bool | `true` | Enables caching of metric values during polling interval (as specified in .spec.pollingInterval). |
329+
| autoscaling.authenticationRef | object | `{"annotations":{"helm.sh/hook":"post-install,post-upgrade,post-rollback","helm.sh/hook-weight":"0"},"name":""}` | Specify an external KEDA TriggerAuthentication resource is used for scaler triggers config. Apply for all browser nodes |
330+
| autoscaling.useCachedMetrics | bool | `false` | Enables caching of metric values during polling interval (as specified in .spec.pollingInterval). |
331331
| autoscaling.metricType | string | `"Value"` | The type of metric that should be used (Override the default: AverageValue in KEDA) |
332332
| autoscaling.annotations | object | `{"helm.sh/hook":"post-install,post-upgrade,post-rollback","helm.sh/hook-weight":"1"}` | Annotations for KEDA resources: ScaledObject and ScaledJob |
333333
| autoscaling.patchObjectFinalizers.nameOverride | string | `nil` | Override the name of the patch job |
@@ -341,7 +341,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
341341
| autoscaling.scaledOptions.minReplicaCount | int | `0` | Minimum number of replicas |
342342
| autoscaling.scaledOptions.maxReplicaCount | int | `8` | Maximum number of replicas |
343343
| autoscaling.scaledOptions.pollingInterval | int | `10` | Polling interval in seconds |
344-
| autoscaling.scaledJobOptions.scalingStrategy.strategy | string | `"accurate"` | Scaling strategy for KEDA ScaledJob |
344+
| autoscaling.scaledJobOptions.scalingStrategy.strategy | string | `"eager"` | Scaling strategy for KEDA ScaledJob - https://keda.sh/docs/latest/reference/scaledjob-spec/#scalingstrategy |
345345
| autoscaling.scaledJobOptions.successfulJobsHistoryLimit | int | `0` | Number of Completed jobs should be kept |
346346
| autoscaling.scaledJobOptions.failedJobsHistoryLimit | int | `0` | Number of Failed jobs should be kept (for troubleshooting purposes) |
347347
| autoscaling.scaledJobOptions.jobTargetRef | object | `{"backoffLimit":0,"completions":1,"parallelism":1}` | Specify job target ref for KEDA ScaledJob |

Diff for: charts/selenium-grid/templates/_helpers.tpl

+2
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

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

+2-2
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 }}

Diff for: charts/selenium-grid/values.yaml

+9-6
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)