From 5bda0b536d253debfbdc311ab53de13594831ddf Mon Sep 17 00:00:00 2001 From: Jonathan Reveille Date: Thu, 22 Aug 2024 10:54:08 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7(tray)=20add=20cronjob=20for=20send?= =?UTF-8?q?=5Fmail=5Fupcoming=5Fdebit=20management=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have to add a cronjob in the tray to manage the `send_mail_upcoming_debit` management command. --- .../cronjob_send_mail_upcoming_debit.yml.j2 | 81 +++++++++++++++++++ src/tray/vars/all/main.yml | 5 +- 2 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 src/tray/templates/services/app/cronjob_send_mail_upcoming_debit.yml.j2 diff --git a/src/tray/templates/services/app/cronjob_send_mail_upcoming_debit.yml.j2 b/src/tray/templates/services/app/cronjob_send_mail_upcoming_debit.yml.j2 new file mode 100644 index 000000000..e435c669d --- /dev/null +++ b/src/tray/templates/services/app/cronjob_send_mail_upcoming_debit.yml.j2 @@ -0,0 +1,81 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + labels: + app: joanie + service: app + version: "{{ joanie_image_tag }}" + deployment_stamp: "{{ deployment_stamp }}" + name: "joanie-send-mail-upcoming-debit-{{ deployment_stamp }}" + namespace: "{{ namespace_name }}" +spec: + schedule: "{{ joanie_send_mail_upcoming_debit_cronjob_schedule }}" + successfulJobsHistoryLimit: 2 + failedJobsHistoryLimit: 1 + concurrencyPolicy: Forbid + suspend: {{ suspend_cronjob | default(false) }} + jobTemplate: + spec: + template: + metadata: + name: "joanie-send-mail-upcoming-debit-{{ deployment_stamp }}" + labels: + app: joanie + service: app + version: "{{ joanie_image_tag }}" + deployment_stamp: "{{ deployment_stamp }}" + spec: +{% set image_pull_secret_name = joanie_image_pull_secret_name | default(none) or default_image_pull_secret_name %} +{% if image_pull_secret_name is not none %} + imagePullSecrets: + - name: "{{ image_pull_secret_name }}" +{% endif %} + containers: + - name: "joanie-send-mail-upcoming-debit" + image: "{{ joanie_image_name }}:{{ joanie_image_tag }}" + imagePullPolicy: Always + command: + - "/bin/bash" + - "-c" + - python manage.py send_mail_upcoming_debit + env: + - name: DB_HOST + value: "joanie-{{ joanie_database_host }}-{{ deployment_stamp }}" + - name: DB_NAME + value: "{{ joanie_database_name }}" + - name: DB_PORT + value: "{{ joanie_database_port }}" + - name: DJANGO_ALLOWED_HOSTS + value: "{{ joanie_host | blue_green_hosts }},{{ joanie_admin_host | blue_green_hosts }}" + - name: DJANGO_CSRF_TRUSTED_ORIGINS + value: "{{ joanie_host | blue_green_hosts | split(',') | map('regex_replace', '^(.*)$', 'https://\\1') | join(',') }},{{ joanie_admin_host | blue_green_hosts | split(',') | map('regex_replace', '^(.*)$', 'https://\\1') | join(',') }}" + - name: DJANGO_CONFIGURATION + value: "{{ joanie_django_configuration }}" + - name: DJANGO_CORS_ALLOWED_ORIGINS + value: "{{ richie_host | blue_green_hosts | split(',') | map('regex_replace', '^(.*)$', 'https://\\1') | join(',') }},{{ joanie_admin_host | blue_green_hosts | split(',') | map('regex_replace', '^(.*)$', 'https://\\1') | join(',') }}" + - name: DJANGO_CSRF_COOKIE_DOMAIN + value: ".{{ joanie_host }}" + - name: DJANGO_SETTINGS_MODULE + value: joanie.configs.settings + - name: JOANIE_BACKOFFICE_BASE_URL + value: "https://{{ joanie_admin_host }}" + - name: DJANGO_CELERY_DEFAULT_QUEUE + value: "default-queue-{{ deployment_stamp }}" + envFrom: + - secretRef: + name: "{{ joanie_secret_name }}" + - configMapRef: + name: "joanie-app-dotenv-{{ deployment_stamp }}" + resources: {{ joanie_send_mail_upcoming_debit_cronjob_resources }} + volumeMounts: + - name: joanie-configmap + mountPath: /app/joanie/configs + restartPolicy: Never + securityContext: + runAsUser: {{ container_uid }} + runAsGroup: {{ container_gid }} + volumes: + - name: joanie-configmap + configMap: + defaultMode: 420 + name: joanie-app-{{ deployment_stamp }} diff --git a/src/tray/vars/all/main.yml b/src/tray/vars/all/main.yml index b473e2b4d..7e1af98f8 100644 --- a/src/tray/vars/all/main.yml +++ b/src/tray/vars/all/main.yml @@ -54,7 +54,7 @@ joanie_activate_http_basic_auth: false # -- joanie celery joanie_celery_replicas: 1 -joanie_celery_command: +joanie_celery_command: - celery - -A - joanie.celery_app @@ -84,7 +84,7 @@ joanie_celery_readynessprobe: # Joanie cronjobs joanie_process_payment_schedules_cronjob_schedule: "0 3 * * *" - +joanie_send_mail_upcoming_debit_cronjob_schedule: "0 3 * * *" # -- resources {% set app_resources = { @@ -97,6 +97,7 @@ joanie_process_payment_schedules_cronjob_schedule: "0 3 * * *" joanie_app_resources: "{{ app_resources }}" joanie_app_job_db_migrate_resources: "{{ app_resources }}" joanie_process_payment_schedules_cronjob_resources: "{{ app_resources }}" +joanie_send_mail_upcoming_debit_cronjob_resources: "{{ app_resources }}" joanie_nginx_resources: requests: