Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions charts/retool/ci/test-js-executor-hpa-option.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
rr:

# Exercises the JS executor HPA (opt-in via rr.jsExecutor.autoscaling).
# Overlaid on top of test-install-values.yaml. Covers CPU, memory, extra
# metrics, and scale behavior branches; replicaCount must be omitted from
# the Deployment when the HPA is enabled.
jsExecutor:
enabled: true
replicaCount: 3
image:
repository: tryretool/js-executor-service
tag: 3.123.4
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 8
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
metrics:
- type: Pods
pods:
metric:
name: packets-per-second
target:
type: AverageValue
averageValue: 1k
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 50
periodSeconds: 60
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 15
52 changes: 52 additions & 0 deletions charts/retool/templates/deployment_js_executor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ metadata:
{{ toYaml .Values.deployment.annotations | indent 4 }}
{{- end }}
spec:
{{- if not ((.Values.rr.jsExecutor.autoscaling).enabled) }}
replicas: {{ .Values.rr.jsExecutor.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "retool.jsExecutor.selectorLabels" . | nindent 6 }}
Expand Down Expand Up @@ -258,4 +260,54 @@ spec:
matchLabels:
{{- include "retool.jsExecutor.selectorLabels" . | nindent 6 }}
{{- end }}
{{- if (.Values.rr.jsExecutor.autoscaling).enabled }}
{{- $hpa := .Values.rr.jsExecutor.autoscaling }}
{{- $requests := ((.Values.rr.jsExecutor.resources).requests | default dict) }}
{{- if and $hpa.targetCPUUtilizationPercentage (not $requests.cpu) }}
{{- fail "rr.jsExecutor.autoscaling.targetCPUUtilizationPercentage requires rr.jsExecutor.resources.requests.cpu. CPU utilization is unavailable without a CPU request, so the HPA cannot scale on CPU. Set a CPU request or unset targetCPUUtilizationPercentage." }}
{{- end }}
{{- if and $hpa.targetMemoryUtilizationPercentage (not $requests.memory) }}
{{- fail "rr.jsExecutor.autoscaling.targetMemoryUtilizationPercentage requires rr.jsExecutor.resources.requests.memory. Memory utilization is unavailable without a memory request, so the HPA cannot scale on memory. Set a memory request or unset targetMemoryUtilizationPercentage." }}
{{- end }}
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ template "retool.jsExecutor.name" . }}
labels:
{{- include "retool.jsExecutor.selectorLabels" . | nindent 4 }}
{{- include "retool.jsExecutor.labels" . | nindent 4 }}
{{- include "retool.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ template "retool.jsExecutor.name" . }}
minReplicas: {{ .Values.rr.jsExecutor.autoscaling.minReplicas }}
maxReplicas: {{ .Values.rr.jsExecutor.autoscaling.maxReplicas }}
metrics:
{{- if .Values.rr.jsExecutor.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.rr.jsExecutor.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.rr.jsExecutor.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
Comment thread
greptile-apps[bot] marked this conversation as resolved.
averageUtilization: {{ .Values.rr.jsExecutor.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- with .Values.rr.jsExecutor.autoscaling.metrics }}
{{- toYaml . | nindent 4 }}
{{- end }}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
{{- with .Values.rr.jsExecutor.autoscaling.behavior }}
behavior:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions charts/retool/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,25 @@ rr:

replicaCount: 1

# Horizontal Pod Autoscaler for the JS executor. Disabled by default;
# set enabled: true to opt in. When enabled, replicaCount is ignored
# and the HPA controls the replica count.
#
# CPU and memory Utilization targets require a matching container
# request (resources.requests.cpu / resources.requests.memory). A
# limits-only or partial resources override leaves those metrics
# unavailable and the HPA will not scale on the affected resource.
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 70
# Additional HPA metrics (Pods, Object, External, or extra Resource).
# metrics: []
# Scaling behavior (stabilization windows and policies).
# behavior: {}

seccompLocalhostProfile: profiles/nsjail-seccomp.json

# JS-executor-specific environment; not inherited from the top-level
Expand All @@ -887,6 +906,8 @@ rr:
# Resources for the JS executor. Memory request and limit are kept equal:
# JSE reads its memory limit and rejects requests at 80% of it, so the
# request must reserve the full amount to avoid premature rejections.
# HPA Utilization metrics (see autoscaling above) also require these
# requests; do not drop them if autoscaling is enabled.
resources:
limits:
cpu: '2'
Expand Down
21 changes: 21 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,25 @@ rr:

replicaCount: 1

# Horizontal Pod Autoscaler for the JS executor. Disabled by default;
# set enabled: true to opt in. When enabled, replicaCount is ignored
# and the HPA controls the replica count.
#
# CPU and memory Utilization targets require a matching container
# request (resources.requests.cpu / resources.requests.memory). A
# limits-only or partial resources override leaves those metrics
# unavailable and the HPA will not scale on the affected resource.
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 70
# Additional HPA metrics (Pods, Object, External, or extra Resource).
# metrics: []
# Scaling behavior (stabilization windows and policies).
# behavior: {}

seccompLocalhostProfile: profiles/nsjail-seccomp.json

# JS-executor-specific environment; not inherited from the top-level
Expand All @@ -887,6 +906,8 @@ rr:
# Resources for the JS executor. Memory request and limit are kept equal:
# JSE reads its memory limit and rejects requests at 80% of it, so the
# request must reserve the full amount to avoid premature rejections.
# HPA Utilization metrics (see autoscaling above) also require these
# requests; do not drop them if autoscaling is enabled.
resources:
limits:
cpu: '2'
Expand Down
Loading