diff --git a/ansible/roles/schulcloud-server-core/tasks/main.yml b/ansible/roles/schulcloud-server-core/tasks/main.yml index 957be25f770..fdda78688a1 100644 --- a/ansible/roles/schulcloud-server-core/tasks/main.yml +++ b/ansible/roles/schulcloud-server-core/tasks/main.yml @@ -103,3 +103,9 @@ namespace: "{{ NAMESPACE }}" template: preview-generator-onepassword.yml.j2 when: ONEPASSWORD_OPERATOR is defined and ONEPASSWORD_OPERATOR|bool + + - name: PreviewGeneratorScaledObject + kubernetes.core.k8s: + kubeconfig: ~/.kube/config + namespace: "{{ NAMESPACE }}" + template: preview-generator-scaled-object.yml.j2 diff --git a/ansible/roles/schulcloud-server-core/templates/preview-generator-scaled-object.yml.j2 b/ansible/roles/schulcloud-server-core/templates/preview-generator-scaled-object.yml.j2 new file mode 100644 index 00000000000..b0c2db8108f --- /dev/null +++ b/ansible/roles/schulcloud-server-core/templates/preview-generator-scaled-object.yml.j2 @@ -0,0 +1,43 @@ +apiVersion: onepassword.com/v1 +kind: OnePasswordItem +metadata: + name: keda-secret + namespace: {{ NAMESPACE }} + labels: + app: keda +spec: + itemPath: "vaults/{{ ONEPASSWORD_OPERATOR_VAULT }}/items/keda" +--- +apiVersion: keda.sh/v1alpha1 +kind: TriggerAuthentication +metadata: + name: keda-trigger-auth-rabbitmq-conn + namespace: {{ NAMESPACE }} +spec: + secretTargetRef: + - parameter: host + name: keda-secret + key: amqp-url +--- +apiVersion: keda.sh/v1alpha1 +kind: ScaledObject +metadata: + name: rabbitmq-scaledobject + namespace: {{ NAMESPACE }} +spec: + scaleTargetRef: + name: preview-generator-deployment + pollingInterval: 1 + cooldownPeriod: 300 + idleReplicaCount: 0 + minReplicaCount: 0 + maxReplicaCount: 1 + triggers: + - type: rabbitmq + metadata: + protocol: amqp + queueName: generate-preview + mode: QueueLength + value: "1" + authenticationRef: + name: keda-trigger-auth-rabbitmq-conn \ No newline at end of file