diff --git a/ansible/roles/antivirus_check_service/tasks/main.yml b/ansible/roles/antivirus_check_service/tasks/main.yml index bbb0326..962f087 100644 --- a/ansible/roles/antivirus_check_service/tasks/main.yml +++ b/ansible/roles/antivirus_check_service/tasks/main.yml @@ -22,4 +22,12 @@ 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 diff --git a/ansible/roles/antivirus_check_service/templates/scanfile-scaled-object.yml.j2 b/ansible/roles/antivirus_check_service/templates/scanfile-scaled-object.yml.j2 new file mode 100644 index 0000000..5a71034 --- /dev/null +++ b/ansible/roles/antivirus_check_service/templates/scanfile-scaled-object.yml.j2 @@ -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