Skip to content

Commit

Permalink
BC-6559 auto scale scanfile deployment on demand (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loki-Afro authored Feb 14, 2024
1 parent d62dc0d commit f1ec3d0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ansible/roles/antivirus_check_service/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: scanfile-deployment.yml.j2



- name: scanfile scaled object
kubernetes.core.k8s:
kubeconfig: ~/.kube/config
namespace: "{{ NAMESPACE }}"
template: scanfile-scaled-object.yml.j2
when:
- KEDA_ENABLED is defined and KEDA_ENABLED|bool
- SCALED_ANTIVIRUS_SCANFILE_WORKER_ENABLED is defined and SCALED_ANTIVIRUS_SCANFILE_WORKER_ENABLED|bool
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: scanfile-scaledobject
namespace: {{ NAMESPACE }}
labels:
app: antivirus
antivirus: scanfile
app.kubernetes.io/part-of: schulcloud-verbund
app.kubernetes.io/version: {{ ANTIVIRUS_CHECK_SERVICE_IMAGE_TAG }}
app.kubernetes.io/name: scanfile
app.kubernetes.io/component: antivirus
app.kubernetes.io/managed-by: ansible
git.branch: {{ ANTIVIRUS_CHECK_SERVICE_BRANCH_NAME }}
git.repo: {{ ANTIVIRUS_CHECK_SERVICE_REPO_NAME }}
spec:
scaleTargetRef:
name: api-worker-deployment
cooldownPeriod: 1800 #keep action for 15min
idleReplicaCount: 0
minReplicaCount: {{ ANTIVIRUS_SCANFILE_MIN_REPLICA_COUNT|default("0", true) }}
maxReplicaCount: {{ ANTIVIRUS_SCANFILE_MAX_REPLICA_COUNT|default("1", true) }}
triggers:
- type: rabbitmq
metadata:
protocol: amqp
queueName: scan_file
mode: QueueLength
value: "1"
authenticationRef:
name: rabbitmq-trigger-auth

0 comments on commit f1ec3d0

Please sign in to comment.