Skip to content

Commit

Permalink
Add autoscalers for inbox-listener and stream service
Browse files Browse the repository at this point in the history
Adds autoscalers for the inbox-listener and stream service. The inbox
listener autoscaler relies on KEDA. The stream service autoscaler is a
standard HPA.

KEDA has some unfortunate friction with helm. It cannot be added as a
dependency to the chart and installed in a reasonable way, because it
relies on CRDs, which helm will not be responsible for updating or
installing in order.

Based on conversation in kedacore/charts#226,
there are two alternative approaches open to us:

* We can instruct users to install KEDA on their cluster prior to
  installing our deployment. The command for this is,
    helm install keda --version 2.9.1 --namespace keda kedacore/keda --create-namespace

* We can vendor KEDA's CRDs and put them into our chart, under a crd
  directory. This should enable a single-command install, but comes with
  the downsides that,
  1. Helm will not update or manage the keda CRDs for us
  2. If users already have KEDA installed (certainly possible) we will
     encounter a conflict.

  Mainly due to the second item, this PR takes the first approach.
  • Loading branch information
wkalt committed Jan 11, 2023
1 parent 9466608 commit 16f3804
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
34 changes: 34 additions & 0 deletions charts/primary-site/templates/inbox-listener-scaledobject.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: keda.sh/v1alpha1
kind: TriggerAuthentication
metadata:
name: keda-inbox-listener-auth
spec:
secretTargetRef:
- parameter: token
name: foxglove-site
key: token
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: inbox-listener-scaledobject
labels:
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: deployment
name: inbox-listener
envSourceContainerName: inbox-listener
pollingInterval: {{ .Values.inboxListener.deployment.autoscalePollingInterval }}
cooldownPeriod: {{ .Values.inboxListener.deployment.autoscaleCooldownPeriod }}
minReplicaCount: {{ .Values.inboxListener.deployment.minReplicas }}
maxReplicaCount: {{ .Values.inboxListener.deployment.maxReplicas }}
triggers:
- type: metrics-api
metadata:
targetValue: "{{ .Values.inboxListener.deployment.scaling.targetQueueDepth }}"
url: "{{ .Values.globals.foxgloveApiUrl }}/internal/platform/v1/pending-imports-stats"
valueLocation: 'unleased'
authMode: "bearer"
authenticationRef:
name: keda-inbox-listener-auth
19 changes: 19 additions & 0 deletions charts/primary-site/templates/stream-service-hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: {{ .Values.streamService.name }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ .Values.streamService.name }}
minReplicas: {{ .Values.streamService.deployment.scaling.minReplicas }}
maxReplicas: {{ .Values.streamService.deployment.scaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.streamService.deployment.scaling.targetCPUUtilization }}

14 changes: 12 additions & 2 deletions charts/primary-site/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
globals:
siteToken:
foxgloveApiUrl: https://api.foxglove.dev

## Supported storageProvider values are: `google_cloud` or `azure`
## If `azure` is used, then the `@azure.storageAccountName` and `@azure.serviceUrl` values
## are required.
Expand All @@ -11,14 +10,20 @@ globals:
inbox:
storageProvider: google_cloud
bucketName: foxglove-inbox

azure:
storageAccountName: ""
## For example: https://<resourcegroup>.blob.core.windows.net
serviceUrl: ""

inboxListener:
name: inbox-listener
deployment:
scaling:
autoscalePollingInterval: 10
autoscaleCooldownPeriod: 10
minReplicas: 1
maxReplicas: 10
targetQueueDepth: 2
resources:
requests:
cpu: 1000m
Expand All @@ -28,7 +33,12 @@ inboxListener:
memory: 1Gi

streamService:
name: stream-service
deployment:
scaling:
minReplicas: 1
maxReplicas: 3
targetCPUUtilization: 80
resources:
requests:
cpu: 1000m
Expand Down

0 comments on commit 16f3804

Please sign in to comment.