Skip to content

Commit

Permalink
🔧(tray) add cronjob for send_mail_upcoming_debit management command
Browse files Browse the repository at this point in the history
We have to add a cronjob in the tray to manage the
`send_mail_upcoming_debit` management command.
  • Loading branch information
jonathanreveille authored and kernicPanel committed Sep 19, 2024
1 parent 6f8cc2e commit 5bda0b5
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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 }}
5 changes: 3 additions & 2 deletions src/tray/vars/all/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand All @@ -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:
Expand Down

0 comments on commit 5bda0b5

Please sign in to comment.