Skip to content

Commit

Permalink
K8s: Deployment scale metricType should be Value instead of AverageVa…
Browse files Browse the repository at this point in the history
…lue (#2465)

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
  • Loading branch information
VietND96 authored Nov 14, 2024
1 parent bf73ae9 commit 33471fe
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NodeChromium/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ USER root
# Install Chromium
ARG CHROMIUM_VERSION="latest"
ARG CHROMIUM_DEB_SITE="http://deb.debian.org/debian"
RUN echo "deb ${CHROMIUM_DEB_SITE}/ sid main" >> /etc/apt/sources.list \
RUN echo "deb ${CHROMIUM_DEB_SITE}/ stable main" >> /etc/apt/sources.list \
&& wget -qO- https://ftp-master.debian.org/keys/archive-key-12.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/debian-archive-keyring.gpg \
&& wget -qO- https://ftp-master.debian.org/keys/archive-key-12-security.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/debian-archive-security-keyring.gpg \
&& apt-get update -qqy \
Expand Down
2 changes: 2 additions & 0 deletions charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| autoscaling.enableWithExistingKEDA | bool | `false` | Enable autoscaling without automatically installing KEDA |
| autoscaling.scalingType | string | `"job"` | Which type of KEDA scaling to use: job or deployment |
| 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 |
| autoscaling.useCachedMetrics | bool | `true` | Enables caching of metric values during polling interval (as specified in .spec.pollingInterval). |
| autoscaling.metricType | string | `"Value"` | The type of metric that should be used (Override the default: AverageValue in KEDA) |
| autoscaling.annotations | object | `{"helm.sh/hook":"post-install,post-upgrade,post-rollback","helm.sh/hook-weight":"1"}` | Annotations for KEDA resources: ScaledObject and ScaledJob |
| autoscaling.patchObjectFinalizers.nameOverride | string | `nil` | Override the name of the patch job |
| autoscaling.patchObjectFinalizers.enabled | bool | `true` | Enable patching finalizers for KEDA scaled resources. Workaround for Hook post-upgrade selenium-grid/templates/x-node-hpa.yaml failed: object is being deleted: scaledobjects.keda.sh "x" already exists |
Expand Down
12 changes: 7 additions & 5 deletions charts/selenium-grid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,16 @@ Common autoscaling spec template
triggers:
- type: selenium-grid
metadata:
{{- with .node.hpa }}
{{- tpl (toYaml .) $ | nindent 6 }}
{{- if not .nodeMaxSessions }}
nodeMaxSessions: {{ $nodeMaxSessions | quote }}
{{- with .node.hpa }}
{{- tpl (toYaml .) $ | nindent 6 }}
{{- end }}
{{- if not .node.hpa.authenticationRef }}
{{- end }}
{{- end }}
authenticationRef:
name: {{ template "seleniumGrid.autoscaling.authenticationRef.fullname" $ }}
{{- end }}
useCachedMetrics: {{ $.Values.autoscaling.useCachedMetrics }}
metricType: {{ $.Values.autoscaling.metricType }}
{{- end }}
{{- end -}}

Expand Down
5 changes: 5 additions & 0 deletions charts/selenium-grid/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,11 @@ autoscaling:
annotations:
"helm.sh/hook": post-install,post-upgrade,post-rollback
"helm.sh/hook-weight": "-2"
# Configuration for ScaledObject triggers https://keda.sh/docs/latest/reference/scaledobject-spec/#triggers
# -- Enables caching of metric values during polling interval (as specified in .spec.pollingInterval).
useCachedMetrics: true
# -- The type of metric that should be used (Override the default: AverageValue in KEDA)
metricType: Value
# -- Annotations for KEDA resources: ScaledObject and ScaledJob
annotations:
"helm.sh/hook": post-install,post-upgrade,post-rollback
Expand Down
6 changes: 5 additions & 1 deletion tests/SmokeTests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@
SELENIUM_GRID_PORT = os.environ.get('SELENIUM_GRID_PORT', '4444')
SELENIUM_GRID_USERNAME = os.environ.get('SELENIUM_GRID_USERNAME', '')
SELENIUM_GRID_PASSWORD = os.environ.get('SELENIUM_GRID_PASSWORD', '')
CHART_CERT_PATH = os.environ.get('CHART_CERT_PATH', None)
SELENIUM_GRID_AUTOSCALING = os.environ.get('SELENIUM_GRID_AUTOSCALING', 'false')
SELENIUM_GRID_AUTOSCALING_MIN_REPLICA = os.environ.get('SELENIUM_GRID_AUTOSCALING_MIN_REPLICA', 0)
HUB_CHECKS_MAX_ATTEMPTS = os.environ.get('HUB_CHECKS_MAX_ATTEMPTS', 3)
HUB_CHECKS_INTERVAL = os.environ.get('HUB_CHECKS_INTERVAL', 10)

if CHART_CERT_PATH:
os.environ['REQUESTS_CA_BUNDLE'] = CHART_CERT_PATH

class SmokeTests(unittest.TestCase):
def smoke_test_container(self, port):
current_attempts = 0
Expand Down Expand Up @@ -53,7 +57,7 @@ def smoke_test_container(self, port):
def client_verify_cert(self, port):
grid_url_status = '%s://%s:%s/status' % (SELENIUM_GRID_PROTOCOL, SELENIUM_GRID_HOST, port)
cert_path = os.environ.get("REQUESTS_CA_BUNDLE")
response = requests.get(grid_url_status, verify=cert_path)
response = requests.get(grid_url_status, verify=cert_path, auth=HTTPBasicAuth(SELENIUM_GRID_USERNAME, SELENIUM_GRID_PASSWORD))

class GridTest(SmokeTests):
def test_grid_is_up(self):
Expand Down

0 comments on commit 33471fe

Please sign in to comment.