mkdir airflow_project && cd airflow_project
~/airflow-local$ curl -LfO 'https://airflow.apache.org/docs/apache-airflow/2.9.3/docker-compose.yaml'
Docker-compose 파일 구성
airflow-scheduler
Task를 일정 주기마다 실행 할 수 있도록 DAG 파일을 모니터링 및 관리
airflow-worker
Scheduler의 Queue에 등록된 Task가 실행 단계로 전달 될 시 실행
airflow-webserver
UI Dashboard, realtime-log, click-to-run 등 웹 서버에서 모니터링 및 단발성 이벤트 실행 또는 삭제 가능
airflow-trigger
특정 스케줄러에 의해 동작 하지 않고 이벤트를 감지 하여 실행
airflow-init
에어플로우 프로젝트 초기 설정
postgres
로컬에서 airflow db는 sqlite3를 사용 하지만 docker 환경에서는 postgres 사용
redis
스케줄러에서 워커로 메세지 전송 하는 브로커
common environment
airflow.cfg에 설정 하는 내용
Create airflow refference directory
도커 환경에서 참조 할 추가 디렉터리 생성
mkdir -p ./dags ./logs ./plugins ./config
dags : DAG 파일 보관
logs : Task 실행 시, 혹은 Scheduler의 로그 보관
config : 커스텀 log parser를 추가하거나 Cluster 정책을 위한 airflow_local_settings.py를 추가할 수 있음
plugins : 커스텀 Plugin 보관
Set up .env
환경 변수 관리
echo -e "AIRFLOW_UID=$(id -u)" > .env
Airflow docker compose guide to can modify values in the environment
# Basic Airflow cluster configuration for CeleryExecutor with Redis and PostgreSQL.
#
# WARNING: This configuration is for local development. Do not use it in a production deployment.
#
# This configuration supports basic configuration using environment variables or an .env file
# The following variables are supported:
#
# AIRFLOW_IMAGE_NAME - Docker image name used to run Airflow.
# Default: apache/airflow:2.9.3
# AIRFLOW_UID - User ID in Airflow containers
# Default: 50000
# AIRFLOW_PROJ_DIR - Base path to which all the files will be volumed.
# Default: .
# Those configurations are useful mostly in case of standalone testing/running Airflow in test/try-out mode
#
# _AIRFLOW_WWW_USER_USERNAME - Username for the administrator account (if requested).
# Default: airflow
# _AIRFLOW_WWW_USER_PASSWORD - Password for the administrator account (if requested).
# Default: airflow
# _PIP_ADDITIONAL_REQUIREMENTS - Additional PIP requirements to add when starting all containers.
# Use this option ONLY for quick checks. Installing requirements at container
# startup is done EVERY TIME the service is started.
# A better way is to build a custom image or extend the official image
# as described in https://airflow.apache.org/docs/docker-stack/build.html.
# Default: ''
#
# Feel free to modify this file to suit your needs.