Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce autoscalers for inbox listener and stream service #18

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: batch/v1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all these moved out of the folders? Is there some problem with the folders?

kind: CronJob
metadata:
name: garbage-collector
name: {{ .Values.garbageCollector.name }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to template this?

labels:
app: garbage-collector
app: {{ .Values.garbageCollector.name }}
spec:
concurrencyPolicy: Forbid
schedule: "{{ .Values.garbageCollector.schedule }}"
Expand All @@ -19,7 +19,7 @@ spec:
secretName: gcp-cloud-credential
optional: true
containers:
- name: garbage-collector
- name: {{ .Values.garbageCollector.name }}
image: us-central1-docker.pkg.dev/foxglove-images/images/garbage-collector:{{ .Chart.AppVersion }}
volumeMounts:
- mountPath: /secrets
Expand All @@ -29,8 +29,6 @@ spec:
name: cloud-credentials
optional: true
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secrets/credentials.json
- name: FOXGLOVE_API_URL
value: "{{ .Values.globals.foxgloveApiUrl }}"
- name: FOXGLOVE_SITE_TOKEN
Expand All @@ -47,4 +45,8 @@ spec:
value: "{{ .Values.globals.azure.storageAccountName }}"
- name: STORAGE_AZURE_SERVICE_URL
value: "{{ .Values.globals.azure.serviceUrl }}"
{{- range $item := .Values.inboxListener.env }}
- name: {{ $item.value }}
value: {{ $item.value }}
{{- end }}
restartPolicy: OnFailure
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: inbox-listener
name: {{ .Values.inboxListener.name }}
labels:
app: inbox-listener
app: {{ .Values.inboxListener.name }}
spec:
selector:
matchLabels:
app: inbox-listener
app: {{ .Values.inboxListener.name }}
strategy:
rollingUpdate:
maxSurge: 25%
Expand All @@ -16,15 +16,15 @@ spec:
template:
metadata:
labels:
app: inbox-listener
app: {{ .Values.inboxListener.name }}
spec:
volumes:
- name: cloud-credentials
secret:
secretName: gcp-cloud-credential
optional: true
containers:
- name: inbox-listener
- name: {{ .Values.inboxListener.name }}
image: us-central1-docker.pkg.dev/foxglove-images/images/inbox-listener:{{ .Chart.AppVersion }}
resources:
requests:
Expand All @@ -41,8 +41,6 @@ spec:
name: cloud-credentials
optional: true
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secrets/credentials.json
- name: FOXGLOVE_API_URL
value: "{{ .Values.globals.foxgloveApiUrl }}"
- name: FOXGLOVE_SITE_TOKEN
Expand All @@ -65,3 +63,7 @@ spec:
value: "{{ .Values.globals.azure.storageAccountName }}"
- name: STORAGE_AZURE_SERVICE_URL
value: "{{ .Values.globals.azure.serviceUrl }}"
{{- range $item := .Values.inboxListener.env }}
- name: {{ $item.value }}
value: {{ $item.value }}
{{- end }}
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: {{ .Values.inboxListener.name }}
envSourceContainerName: {{ .Values.inboxListener.name }}
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: stream-service
name: {{ .Values.streamService.name }}
labels:
app: stream-service
app: {{ .Values.streamService.name }}
spec:
replicas: 1
selector:
matchLabels:
app: stream-service
app: {{ .Values.streamService.name }}
strategy:
rollingUpdate:
maxSurge: 25%
Expand All @@ -17,15 +17,15 @@ spec:
template:
metadata:
labels:
app: stream-service
app: {{ .Values.streamService.name }}
spec:
volumes:
- name: cloud-credentials
secret:
secretName: gcp-cloud-credential
optional: true
containers:
- name: stream-service
- name: {{ .Values.streamService.name }}
image: us-central1-docker.pkg.dev/foxglove-images/images/stream-service:{{ .Chart.AppVersion }}
resources:
requests:
Expand All @@ -44,8 +44,6 @@ spec:
name: cloud-credentials
optional: true
env:
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /secrets/credentials.json
- name: FOXGLOVE_API_URL
value: "{{ .Values.globals.foxgloveApiUrl }}"
- name: PORT
Expand All @@ -56,6 +54,10 @@ spec:
value: "{{ .Values.globals.azure.storageAccountName }}"
- name: STORAGE_AZURE_SERVICE_URL
value: "{{ .Values.globals.azure.serviceUrl }}"
{{- range $item := .Values.inboxListener.env }}
- name: {{ $item.value }}
value: {{ $item.value }}
{{- end }}
readinessProbe:
httpGet:
path: /liveness
Expand Down
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 }}

18 changes: 16 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,33 +10,48 @@ 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
memory: 1Gi
limits:
cpu: 1000m
memory: 1Gi
env:

streamService:
name: stream-service
deployment:
scaling:
minReplicas: 1
maxReplicas: 3
targetCPUUtilization: 80
resources:
requests:
cpu: 1000m
memory: 1Gi
limits:
cpu: 1000m
memory: 1Gi
env:

garbageCollector:
name: garbage-collector
schedule: "*/10 * * * *" # every 10 minutes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these three items (schedule, failedJobs, successfulJobs) be under a deployment section?

failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
env: