Skip to content

Commit 5a656c9

Browse files
tlongwell-blocknpub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf
andauthored
fix(chart): support CPU-only relay autoscaling (#2086)
Signed-off-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub1jh9wn95s0472h86ahapupaf7m6kx4v9sx2n0atj2hltcfer8k06s5n3pyf <95cae996907d7cab9f5dbf43c0f53edeac6ab0b032a6feae4abfd784e467b3f5@sprout-oss.stage.blox.sqprod.co>
1 parent f584bbd commit 5a656c9

6 files changed

Lines changed: 35 additions & 14 deletions

File tree

‎deploy/charts/buzz/Chart.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ description: |
77
PostgreSQL and Redis. Configurable for single-node evaluation
88
(subcharts on) and HA production (external services, existingSecret).
99
type: application
10-
version: 0.1.4
10+
version: 0.1.5
1111
appVersion: "0.1.0"
1212
home: https://github.com/block/buzz
1313
sources:
@@ -23,8 +23,8 @@ maintainers:
2323
url: https://github.com/block
2424
annotations:
2525
artifacthub.io/changes: |
26-
- kind: added
27-
description: Optional CPU and per-pod WebSocket horizontal autoscaling for relay pods.
26+
- kind: changed
27+
description: Allow CPU-only relay autoscaling when no custom-metrics adapter is installed.
2828
artifacthub.io/license: Apache-2.0
2929

3030
# Optional eval-only subcharts. Production deploys disable both and point

‎deploy/charts/buzz/README.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,18 @@ autoscaling:
8989
minReplicas: 5
9090
maxReplicas: 15
9191
targetCPUUtilizationPercentage: 65
92+
websocketMetricEnabled: true
9293
websocketMetricName: buzz_ws_connections_active
9394
targetWebsocketConnections: 5000
9495
```
9596

96-
CPU scaling requires Kubernetes Metrics Server. WebSocket scaling additionally
97-
requires a custom-metrics adapter (for example Prometheus Adapter) configured to
98-
expose the relay's `buzz_ws_connections_active` gauge as a pod metric with the
99-
name in `websocketMetricName`. The chart creates the HPA but deliberately does
100-
not install or configure a cluster-wide metrics adapter. Scale-down is gradual
101-
by default so long-lived WebSocket connections have time to drain.
97+
CPU scaling requires Kubernetes Metrics Server. Set `websocketMetricEnabled: false`
98+
for a CPU-only HPA. WebSocket scaling additionally requires a custom-metrics
99+
adapter (for example Prometheus Adapter) configured to expose the relay's
100+
`buzz_ws_connections_active` gauge as a pod metric with the name in
101+
`websocketMetricName`. The chart creates the HPA but deliberately does not
102+
install or configure a cluster-wide metrics adapter. Scale-down is gradual by
103+
default so long-lived WebSocket connections have time to drain.
102104

103105
## Upgrades
104106

‎deploy/charts/buzz/templates/_validate.tpl‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ surface at template time regardless of which manifest helm renders first.
4141
{{- if lt (.Values.autoscaling.maxReplicas | int) (.Values.autoscaling.minReplicas | int) -}}
4242
{{- fail "autoscaling.maxReplicas must be greater than or equal to autoscaling.minReplicas" -}}
4343
{{- end -}}
44-
{{- if not .Values.autoscaling.websocketMetricName -}}
45-
{{- fail "autoscaling.websocketMetricName is required when autoscaling.enabled=true" -}}
44+
{{- if and .Values.autoscaling.websocketMetricEnabled (not .Values.autoscaling.websocketMetricName) -}}
45+
{{- fail "autoscaling.websocketMetricName is required when WebSocket scaling is enabled" -}}
4646
{{- end -}}
4747
{{- end -}}
4848

‎deploy/charts/buzz/templates/hpa.yaml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ spec:
2222
target:
2323
type: Utilization
2424
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
25+
{{- if .Values.autoscaling.websocketMetricEnabled }}
2526
- type: Pods
2627
pods:
2728
metric:
2829
name: {{ .Values.autoscaling.websocketMetricName }}
2930
target:
3031
type: AverageValue
3132
averageValue: {{ .Values.autoscaling.targetWebsocketConnections | quote }}
33+
{{- end }}
3234
{{- end }}

‎deploy/charts/buzz/tests/hpa_test.yaml‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,22 @@ tests:
4949
path: spec.behavior.scaleDown.stabilizationWindowSeconds
5050
value: 600
5151

52+
- it: supports CPU-only autoscaling without a custom metrics adapter
53+
template: templates/hpa.yaml
54+
set:
55+
autoscaling.enabled: true
56+
autoscaling.websocketMetricEnabled: false
57+
asserts:
58+
- lengthEqual:
59+
path: spec.metrics
60+
count: 1
61+
- equal:
62+
path: spec.metrics[0].type
63+
value: Resource
64+
- equal:
65+
path: spec.metrics[0].resource.name
66+
value: cpu
67+
5268
- it: leaves Deployment replicas to the HPA and disables in-process huddle audio
5369
template: templates/deployment.yaml
5470
set:

‎deploy/charts/buzz/values.yaml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,15 @@ image:
3737
replicaCount: 1
3838

3939
# ── Autoscaling ──────────────────────────────────────────────────────────────
40-
# Requires Metrics Server for CPU and a custom-metrics adapter exposing the
41-
# pod-level Prometheus gauge named by websocketMetricName. Kubernetes HPA uses
42-
# the larger replica recommendation, so either CPU or WebSocket load scales out.
40+
# Requires Metrics Server for CPU. Optional WebSocket scaling additionally
41+
# requires a custom-metrics adapter exposing its pod-level Prometheus gauge.
42+
# Kubernetes HPA uses the larger replica recommendation from enabled metrics.
4343
autoscaling:
4444
enabled: false
4545
minReplicas: 5
4646
maxReplicas: 15
4747
targetCPUUtilizationPercentage: 65
48+
websocketMetricEnabled: true
4849
websocketMetricName: buzz_ws_connections_active
4950
targetWebsocketConnections: 5000
5051
behavior:

0 commit comments

Comments
 (0)