Airflow Helm Charts (User-Community)

repository·main·Indexed 20 days ago

https://github.com/airflow-helm/charts

User-Community Helm charts for deploying Apache Airflow on Kubernetes. Supports Airflow versions 1.10 through 2.10 and executors including CeleryExecutor, KubernetesExecutor, and CeleryKubernetesExecutor. Features include declarative management of users and connections, DAG loading via Git-Sync or PVCs, and production-ready deployment examples for Google Kubernetes Engine (GKE) and local environments like Minikube, Kind, or K3D.

Tokens
35.6K
Snippets
109
Records
136
Agent score
69%

What's inside airflow-helm-charts

  1. Overview of the Airflow Helm Chart (User Community)

    main

    The User-Community Airflow Helm Chart is a standard tool for deploying Apache Airflow on Kubernetes using Helm. It is designed to be production-ready and supports various Airflow versions, executors, and GitOps workflows (such as ArgoCD).

    Note: This chart is independent of the official chart found in the apache/airflow repository.

  2. Use the PgBouncer Docker Image with Airflow Helm Chart

    main

    The Apache Airflow helm chart located at charts/airflow utilizes this specific PgBouncer Docker image to provide PgBouncer support. This allows for efficient connection pooling for the Airflow metadata database.

    To use this image in your own custom deployments or to inspect its construction, you can refer to the official Dockerfile and changelog.

  3. Deploy Apache Airflow on Kubernetes using the User-Community Helm Chart

    main
    The User-Community Airflow Helm Chart is the standard method for deploying Apache Airflow on Kubernetes clusters using Helm. It is designed to facilitate production-ready deployments and is maintained by the community.
  4. Access Airflow FAQ Guides

    main

    The Helm chart provides detailed documentation for common configuration tasks. Key categories include:

    • Configuration: Setting Airflow versions, managing configs, plugins, extra Python packages, and Celery worker autoscaling.
    • DAGs: Loading DAG definitions, managing connections, variables, and pools.
    • Security: Managing users, LDAP/OAUTH integration, and setting Fernet or Webserver secret keys.
    • Monitoring: Log persistence, log cleanup, scheduler liveness probes, and Prometheus integration.
    • Databases: Configuring embedded or external Postgres/Redis, and PgBouncer.
    • Kubernetes: Ingress, mounting persistent volumes, mounting files/env vars from Secrets/ConfigMaps, pod affinity/tolerations, and extra manifests.
  5. Use Secret Templates for Connections

    main

    To avoid storing sensitive data in plain-text, use airflow.connectionsTemplates to inject values from Kubernetes Secrets or ConfigMaps into your connection fields (host, schema, login, password, and extra).

    Keys defined in airflow.connectionsTemplates are used as $-based templates (Python string templates) within the connection fields.

    airflow: 
      connections:
        - id: my_aws
          type: aws
          login: ${ACCESS_KEY_ID}
          password: ${SECRET_ACCESS_KEY}
    
      connectionsTemplates:
        ACCESS_KEY_ID:
          kind: secret
          name: my-aws-token
          key: AWS_ACCESS_KEY_ID
        SECRET_ACCESS_KEY:
          kind: secret
          name: my-aws-token
          key: AWS_SECRET_ACCESS_KEY
  6. Key features of the Airflow Helm Chart

    main

    The chart provides comprehensive support for managing an Airflow deployment on Kubernetes, including:

    • Airflow Version Support: Compatible with versions 1.10, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, and 2.10.
    • Executor Support: Supports CeleryExecutor, KubernetesExecutor, and CeleryKubernetesExecutor.
    • Database Connectivity: Options to connect to external Postgres or MySQL databases, and support for PgBouncer configuration.
    • Declarative Configuration: Manage Users, Connections, Variables, and Pools declaratively.
    • DAG Loading Methods: Load DAGs via Git-Sync sidecars, Persistent Volume Claims (Volumes), or by embedding them directly into the container image.
    • Log Management: Persist logs using Persistent Volume Claims or remote providers, with support for automatic log cleanup.
    • Python Package Management: Install extra Python packages using Init-Containers or by embedding them into the container image.
    • Scheduler Reliability: Automatically restart unhealthy schedulers using Heartbeat Check or Task Creation Check liveness probes.
  7. Set Airflow Webserver Secret Key using _CMD or _SECRET configs

    main

    You can use Airflow's _CMD or _SECRET environment variable patterns to set the secret key. This involves mounting a secret as a volume and then using a command to read that value.

    Important Requirements:

    1. You must set airflow.webserverSecretKey to an empty string (""), otherwise the direct value will take precedence and ignore your command/secret config.
    2. If your value is in a Kubernetes Secret, using extraEnv (Option 2) is generally preferred over this method.

    This approach uses AIRFLOW__WEBSERVER__SECRET_KEY_CMD to execute a command (like cat) to retrieve the key from a mounted volume.

    airflow:
      ## WARNING: you must set `webserverSecretKey` to "", otherwise it will take precedence
      webserverSecretKey: ""
    
      config:
        AIRFLOW__WEBSERVER__SECRET_KEY_CMD: "cat /opt/airflow/webserver-secret-key/value"
          
      extraVolumeMounts:
        - name: webserver-secret-key
          mountPath: /opt/airflow/webserver-secret-key
          readOnly: true
          
      extraVolumes:
        - name: webserver-secret-key
          secret:
            secretName: airflow-webserver-secret-key
  8. Configure AWS Connections (3 Options)

    main

    Depending on your security requirements and environment, you can configure AWS connections in three ways:

    1. Plain Text: Directly providing login (Access Key) and password (Secret Key) in the values. (Not recommended for production).
    2. Secret Templates: Referencing values from a Kubernetes Secret via airflow.connectionsTemplates.
    3. EKS IAM Roles for Service Accounts (IRSA): The recommended approach for EKS. You omit login and password and instead annotate the Airflow serviceAccount with the required IAM role ARN. This allows Airflow to use the pod's identity to access AWS services.
  9. Access the Airflow UI

    main

    Once the installation is complete and resources are ready, you can access the Airflow webserver UI by port-forwarding the service to your local machine.

    • URL: http://localhost:8080
    • Default Credentials: admin / admin
    ## port-forward the airflow webserver
    kubectl port-forward svc/${AIRFLOW_NAME}-web 8080:8080 --namespace $AIRFLOW_NAMESPACE
  10. Mount files from Secrets or ConfigMaps on all Airflow pods

    main

    To mount Kubernetes Secrets or ConfigMaps as files on every Airflow pod (Webserver, Scheduler, etc.), use the airflow.extraVolumeMounts and airflow.extraVolumes configuration keys.

    Follow the Kubernetes VolumeMount and Volume specifications. You must define a name in both extraVolumes and extraVolumeMounts to link them together.

    airflow:
      extraVolumeMounts:
        - name: redshift-creds
          mountPath: /opt/airflow/secrets/redshift-creds
          readOnly: true
    
      extraVolumes:
        - name: redshift-creds
          secret:
            secretName: redshift-creds
  11. Configure Airflow logs using an existing Persistent Volume Claim

    main

    If you want to manage the PVC yourself, create the PersistentVolumeClaim in your namespace and tell the chart to use it via the existingClaim key.

    Requirements:

    • The existing PVC must support ReadWriteMany access mode.
    • You must disable logCleanup for both the scheduler and workers.

    Configuration: Set logs.persistence.enabled: true and provide the name of your claim in logs.persistence.existingClaim.

    scheduler:
      logCleanup:
        enabled: false
    
    workers:
      logCleanup:
        enabled: false
    
    logs:
      path: /opt/airflow/logs
      persistence:
        enabled: true
        existingClaim: my-logs-pvc
        accessMode: ReadWriteMany