Skip to content

Commit

Permalink
feat: KEDA autoscaling for qRPC services.
Browse files Browse the repository at this point in the history
  • Loading branch information
tadeusz-delphai authored and anton-delphai committed Dec 22, 2023
1 parent 0a8d772 commit f9039f0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/delphai-deployment/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: "v2"
name: "delphai-deployment"
version: "0.2.20"
version: "0.2.21"
description: "Standard service deployment"
type: "application"
dependencies:
Expand Down
10 changes: 10 additions & 0 deletions charts/delphai-deployment/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ metadata:
helm.sh/chart: "{{ $.Chart.Name }}-{{ $.Chart.Version | replace "+" "_" }}"

spec:
{{ if not $.Values.rabbitmq.enabled }}
replicas: {{ $.Values.replicas }}
{{ end }} {{/* if not $.Values.rabbitmq.enabled */}}
selector:
matchLabels:
app: "{{ $.Release.Name }}"
Expand Down Expand Up @@ -149,6 +151,14 @@ spec:
value: "{{ $.Release.Name }}-redis-master.{{ $.Release.Namespace }}"
{{ end }}

{{ if $.Values.rabbitmq.enabled }}
- name: RABBITMQ_CONNECTION_STRING
valueFrom:
secretKeyRef:
name: rabbitmq
key: connection-string
{{ end }} {{/* if $.Values.rabbitmq.enabled */}}

{{ range $name, $value := $.Values.env }}
- name: {{ $name | quote }}
value: {{ $value | quote }}
Expand Down
22 changes: 22 additions & 0 deletions charts/delphai-deployment/templates/scaled-object.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ if $.Values.rabbitmq.enabled }}

{{ $rabbitmqSecret := (lookup "v1" "Secret" .Release.Namespace "rabbitmq") }}

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
namespace: {{ $.Release.Namespace | quote }}
name: {{ $.Release.Name | quote }}
spec:
minReplicaCount: 1
scaleTargetRef:
name: {{ $.Release.Name | quote }}
triggers:
- type: rabbitmq
metadata:
host: {{ index $rabbitmqSecret.data "connection-string" | b64dec }}
queueName: {{ $.Values.rabbitmq.queueName | quote }}
mode: QueueLength
value: {{ $.Values.rabbitmq.scaleOnQueueLength | quote}}

{{ end }} {{/* if $.Values.rabbitmq.enabled */}}
9 changes: 9 additions & 0 deletions charts/delphai-deployment/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ ingress:
# Run Cloudflare purge_cache after deployment
purgeCloudflareCache: false

rabbitmq:
enable: false

# The name of the RabbitMQ queue that this service consumes
queueName: "service.{{ $.Release.Namespace }}"

# Message backlog length to trigger autoscaling
scaleOnQueueLength: 20

redis:
enabled: false

Expand Down

0 comments on commit f9039f0

Please sign in to comment.