airflow

by ScriptonBasestar

Helm chartv0.3.0App 2.8.1

Opinionated Apache Airflow chart with KubernetesExecutor for workflow orchestration

About this chart

Apache Airflow

Opinionated Apache Airflow chart with KubernetesExecutor for workflow orchestration and data pipeline automation.

TL;DR

# Add Helm repository
helm repo add sb-charts https://scriptonbasestar-container/sb-helm-charts
helm repo update

# Install chart with default values (KubernetesExecutor)
helm install airflow sb-charts/airflow \
  --set airflow.admin.password=your-secure-password \
  --set postgresql.external.password=pg-password

# Install with production settings
helm install airflow sb-charts/airflow \
  -f https://raw.githubusercontent.com/scriptonbasestar-container/sb-helm-charts/master/charts/airflow/values-small-prod.yaml \
  --set airflow.admin.password=your-secure-password \
  --set postgresql.external.password=pg-password

Introduction

This chart bootstraps an Apache Airflow deployment on a Kubernetes cluster using the Helm package manager.

Key Features:

  • ✅ KubernetesExecutor for scalable task execution
  • ✅ LocalExecutor support for simple deployments
  • ✅ Webserver, Scheduler, and Triggerer components
  • ✅ PostgreSQL integration (external database)
  • ✅ Git-sync for DAG synchronization
  • ✅ Persistent logs and DAG storage
  • ✅ Auto-generated Fernet and secret keys
  • ✅ Remote logging support (S3/MinIO)
  • ✅ Production-ready with HA support

Prerequisites

  • Kubernetes 1.24+
  • Helm 3.8+
  • PersistentVolume provisioner support in the underlying infrastructure

External Dependencies

Required:

  • PostgreSQL: External PostgreSQL database (recommended 13+)

Optional:

  • S3/MinIO: For remote logging and DAG storage
  • Git Repository: For DAG synchronization via git-sync

Installing the Chart

Quick Start

# Install with default values (KubernetesExecutor, requires PostgreSQL and admin password)
helm install my-airflow sb-charts/airflow \
  --set airflow.admin.password=admin123 \
  --set postgresql.external.password=pgpass

Deployment Scenarios

This chart includes pre-configured values for different deployment scenarios:

Development Environment

helm install my-airflow sb-charts/airflow \
  -f https://raw.githubusercontent.com/scriptonbasestar-container/sb-helm-charts/master/charts/airflow/values-dev.yaml

Configuration:

  • LocalExecutor (simple single-scheduler setup)
  • Example DAGs enabled for learning
  • Minimal resources (250m-1000m CPU, 256Mi-1Gi RAM)
  • PVC for DAGs (manual upload)
  • Smaller log storage (5Gi)
  • Simple admin credentials (change for your environment)

Use Case: Local development, testing, learning Airflow

Small Production Deployment

helm install my-airflow sb-charts/airflow \
  -f https://raw.githubusercontent.com/scriptonbasestar-container/sb-helm-charts/master/charts/airflow/values-small-prod.yaml \
  --set airflow.admin.password=your-secure-password \
  --set postgresql.external.password=pg-password

Configuration:

  • KubernetesExecutor (scalable task execution)
  • HA: 2 webserver + 2 scheduler + 1 triggerer replicas
  • Git-sync for DAG synchronization
  • Remote logging to S3/MinIO
  • Production resources (1-2 CPU, 1-2Gi RAM per component)
  • Ingress with TLS support
  • Pod anti-affinity for HA
  • Production annotations (Prometheus scrape)

Use Case: Small production deployments, data pipelines, workflow automation

Configuration

Deployment Executors

Airflow supports different executors for task execution:

LocalExecutor:

  • Single scheduler process
  • Tasks run on the scheduler machine
  • Suitable for development/testing
  • Lower resource requirements
  • No task distribution

KubernetesExecutor:

  • Tasks run as Kubernetes pods
  • Scalable and isolated task execution
  • Each task gets its own pod
  • Recommended for production
  • Better resource utilization
airflow:
  executor: KubernetesExecutor  # or LocalExecutor

Common Configuration Options

ParameterDescriptionDefault
airflow.executorExecutor type (KubernetesExecutor/LocalExecutor)KubernetesExecutor
airflow.loadExamplesLoad example DAGsfalse
airflow.parallelismMax number of task instances running concurrently32
airflow.admin.usernameAdmin usernameadmin
airflow.admin.passwordAdmin password (required)""
airflow.fernetKeyFernet key for encryption (auto-generated if empty)""
airflow.webserverSecretKeyWebserver secret key (auto-generated if empty)""
postgresql.external.enabledUse external PostgreSQLtrue
postgresql.external.hostPostgreSQL hostpostgresql.default.svc.cluster.local
postgresql.external.databasePostgreSQL database nameairflow
postgresql.external.usernamePostgreSQL usernameairflow
postgresql.external.passwordPostgreSQL password (required)""
dags.persistence.enabledEnable DAG PVCfalse
dags.gitSync.enabledEnable git-sync for DAGsfalse
logs.persistence.enabledEnable log PVCtrue
logs.persistence.sizeLog storage size10Gi
webserver.replicaCountNumber of webserver replicas1
scheduler.replicaCountNumber of scheduler replicas1
triggerer.enabledEnable triggerer componenttrue
ingress.enabledEnable ingressfalse

See values.yaml for all available options.

Fernet Key and Secret Key

Airflow requires Fernet key for encrypting connections and webserver secret key for Flask sessions.

Auto-generate (development):

airflow:
  fernetKey: ""  # Auto-generated
  webserverSecretKey: ""  # Auto-generated

Manual generation (production):

# Generate Fernet key
python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

# Generate webserver secret key
openssl rand -hex 32

# Set in values
helm install airflow sb-charts/airflow \
  --set airflow.fernetKey=<fernet-key> \
  --set airflow.webserverSecretKey=<secret-key>

Using Existing Secrets

airflow:
  existingSecret: "my-airflow-secret"
  # Secret must contain keys:
  # - fernet-key
  # - webserver-secret-key
  # - admin-password (optional)
  # - postgresql-url

DAG Management

Option 1: Git-sync (Recommended for Production)

Automatically synchronize DAGs from a Git repository:

dags:
  gitSync:
    enabled: true
    repo: "https://github.com/your-org/airflow-dags.git"
    branch: "main"
    subPath: "dags"  # If DAGs are in subdirectory
    wait: 60  # Sync interval in seconds

For private repositories, add SSH key or token via secret.

Option 2: PersistentVolume

Manually upload DAGs to PVC:

dags:
  persistence:
    enabled: true
    accessMode: ReadWriteMany  # Required for multiple pods
    size: 1Gi

Upload DAGs:

kubectl cp my_dag.py airflow-webserver-0:/opt/airflow/dags/

Option 3: ConfigMap (Small DAGs)

For development with small DAGs:

extraVolumes:
  - name: dags-cm
    configMap:
      name: airflow-dags

extraVolumeMounts:
  - name: dags-cm
    mountPath: /opt/airflow/dags
    readOnly: true

Remote Logging (S3/MinIO)

Store logs in S3-compatible object storage:

airflow:
  remoteLogging:
    enabled: true
    remoteBaseLogFolder: "s3://airflow-logs"
    remoteLogConnId: "aws_default"

Create connection:

make -f make/ops/airflow.mk airflow-connections-add \
  CONN_ID=aws_default \
  CONN_TYPE=aws \
  CONN_URI='aws://access_key:secret_key@?host=http://minio:9000'

Persistence

The chart creates Persistent Volumes for logs and optionally for DAGs.

PVC Configuration:

logs:
  persistence:
    enabled: true
    storageClass: "fast-ssd"
    accessMode: ReadWriteOnce
    size: 50Gi

dags:
  persistence:
    enabled: true
    storageClass: ""
    accessMode: ReadWriteMany  # Required for multiple pods
    size: 1Gi

Networking

Service Configuration

Webserver service exposes the Airflow UI:

webserver:
  service:
    type: ClusterIP  # or LoadBalancer/NodePort
    port: 8080

Ingress Configuration

ingress:
  enabled: true
  className: nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/proxy-body-size: "0"
  hosts:
    - host: airflow.example.com
      paths:
        - path: /
          pathType: Prefix
  tls:
    - secretName: airflow-tls
      hosts:
        - airflow.example.com

Security

Admin User

Admin user is created automatically during database migrations:

airflow:
  admin:
    username: "admin"
    password: "your-secure-password"  # Required
    email: "[email protected]"

Retrieve password:

kubectl get secret airflow-secret -o jsonpath='{.data.admin-password}' | base64 -d

Pod Security Context

Airflow runs as non-root user (UID 50000):

podSecurityContext:
  fsGroup: 50000
  runAsUser: 50000
  runAsGroup: 50000

securityContext:
  runAsNonRoot: true
  runAsUser: 50000
  capabilities:
    drop:
      - ALL

High Availability

Multiple Schedulers

Airflow 2.x supports multiple schedulers for HA:

scheduler:
  replicaCount: 2  # HA
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
        - weight: 100
          podAffinityTerm:
            labelSelector:
              matchExpressions:
                - key: app.kubernetes.io/component
                  operator: In
                  values:
                    - scheduler
            topologyKey: kubernetes.io/hostname

Multiple Webservers

Scale webserver for HA:

webserver:
  replicaCount: 2  # HA

Triggerer

For deferrable operators (Airflow 2.2+):

triggerer:
  enabled: true
  replicaCount: 1

Monitoring

Health Probes

Chart includes comprehensive health checks:

livenessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 60
  periodSeconds: 30

readinessProbe:
  httpGet:
    path: /health
    port: 8080
  initialDelaySeconds: 30
  periodSeconds: 10

Prometheus Integration

Enable Prometheus scraping:

webserver:
  podAnnotations:
    prometheus.io/scrape: "true"
    prometheus.io/port: "8080"

Airflow Setup

Accessing Web UI

Port Forward:

kubectl port-forward svc/airflow-webserver 8080:8080
# Access at http://localhost:8080

Ingress:

ingress:
  enabled: true
  hosts:
    - host: airflow.example.com
# Access at https://airflow.example.com

Login:

  • Username: admin (or configured value)
  • Password: (retrieve with make -f make/ops/airflow.mk airflow-get-password)

Managing DAGs

List DAGs:

make -f make/ops/airflow.mk airflow-dag-list

Trigger a DAG:

make -f make/ops/airflow.mk airflow-dag-trigger DAG=example_dag

Pause/Unpause DAG:

make -f make/ops/airflow.mk airflow-dag-pause DAG=example_dag
make -f make/ops/airflow.mk airflow-dag-unpause DAG=example_dag

Managing Connections

List connections:

make -f make/ops/airflow.mk airflow-connections-list

Add connection:

make -f make/ops/airflow.mk airflow-connections-add \
  CONN_ID=my_postgres \
  CONN_TYPE=postgres \
  CONN_URI='postgresql://user:pass@host:5432/db'

Managing Variables

List variables:

make -f make/ops/airflow.mk airflow-variables-list

Set variable:

make -f make/ops/airflow.mk airflow-variables-set KEY=my_var VALUE=my_value

Managing Users

List users:

make -f make/ops/airflow.mk airflow-users-list

Create user:

make -f make/ops/airflow.mk airflow-users-create \
  USERNAME=john \
  PASSWORD=secret \
  [email protected] \
  ROLE=Admin

Operational Commands

Using Makefile (make/ops/airflow.mk):

Access and Credentials

# Get admin password
make -f make/ops/airflow.mk airflow-get-password

# Port forward webserver
make -f make/ops/airflow.mk airflow-port-forward

# Check health
make -f make/ops/airflow.mk airflow-health

# Show version
make -f make/ops/airflow.mk airflow-version

DAG Management

# List all DAGs
make -f make/ops/airflow.mk airflow-dag-list

# Trigger a DAG
make -f make/ops/airflow.mk airflow-dag-trigger DAG=example_dag

# Trigger with config
make -f make/ops/airflow.mk airflow-dag-trigger DAG=example_dag CONF='{"key":"value"}'

# Pause/unpause DAG
make -f make/ops/airflow.mk airflow-dag-pause DAG=example_dag
make -f make/ops/airflow.mk airflow-dag-unpause DAG=example_dag

# Show DAG state
make -f make/ops/airflow.mk airflow-dag-state DAG=example_dag

# List tasks in DAG
make -f make/ops/airflow.mk airflow-task-list DAG=example_dag

Connections and Variables

# List connections
make -f make/ops/airflow.mk airflow-connections-list

# Add connection
make -f make/ops/airflow.mk airflow-connections-add \
  CONN_ID=my_db \
  CONN_TYPE=postgres \
  CONN_URI='postgresql://user:pass@host:5432/db'

# List variables
make -f make/ops/airflow.mk airflow-variables-list

# Set variable
make -f make/ops/airflow.mk airflow-variables-set KEY=api_key VALUE=secret

User Management

# List users
make -f make/ops/airflow.mk airflow-users-list

# Create user
make -f make/ops/airflow.mk airflow-users-create \
  USERNAME=developer \
  PASSWORD=devpa

Deploy airflow with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has airflow on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartairflow is pinned at v0.3.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply