Skip to content

Support for custom cronjobs #34399

@kimminw00

Description

@kimminw00

Description

airflow/chart/values.yaml

Lines 2167 to 2180 in 3854264

# This runs as a CronJob to cleanup old pods.
cleanup:
enabled: false
# Run every 15 minutes (templated).
schedule: "*/15 * * * *"
# To select a random-ish, deterministic starting minute between 3 and 12 inclusive for each release:
# '{{- add 3 (regexFind ".$" (adler32sum .Release.Name)) -}}-59/15 * * * *'
# To select the last digit of unix epoch time as the starting minute on each deploy:
# '{{- now | unixEpoch | trunc -1 -}}-59/* * * * *'
# Command to use when running the cleanup cronjob (templated).
command: ~
# Args to use when running the cleanup cronjob (templated).
args: ["bash", "-c", "exec airflow kubernetes cleanup-pods --namespace={{ .Release.Namespace }}"]

Since airflow helm chart only supports cleanup cronjob, users have to modify templates to add additional maintenance cronjobs

Use case/motivation

For example, we can create multiple custom cronjobs using values.yaml ​​below

cronJobs:
  cleanPods:
    image: apache/airflow
    schedule: "*/15 * * * *"
    command: ~
    args: ["bash", "-c", "exec airflow kubernetes cleanup-pods --namespace={{ .Release.Namespace }}"]
    ...
  cleanDB:
    image: apache/airflow
    schedule: "30 3 1 * *"
    command: ~
    args: ["bash", "-c", "exec airflow db clean"]
    ...
  backupDB:
    image: CUSTOM_IMAGE
    schedule: "0 1 1 * *"
    command: ~
    args: ["bash", "-c", "pg_dump -h HOST -U USER_NAME -Fc DATABASE_NAME | aws s3 cp - s3://<bucket_name>/<database_name>.dump"]
    ...

By providing custom cronjobs, we can flexibly respond to additional maintenance tasks as needed.

Related issues

No response

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions