Skip to content

Latest commit

Β 

History

History
95 lines (74 loc) Β· 4.55 KB

File metadata and controls

95 lines (74 loc) Β· 4.55 KB

πŸš€ Airflow Stack with Keycloak & PostgreSQL πŸš€

This project provides a robust, containerized Apache Airflow environment, integrated with Keycloak for secure authentication and PostgreSQL as its metadata database. Designed for easy deployment and management, this stack is ideal for orchestrating data pipelines and workflows with enterprise-grade authentication.

✨ Features

  • Apache Airflow: A platform to programmatically author, schedule, and monitor workflows.
  • Keycloak Integration: Secure user authentication and authorization via Keycloak Identity and Access Management.
  • PostgreSQL Backend: Reliable and scalable database for Airflow metadata.
  • Dockerized Environment: All components are containerized using Docker for consistency and isolation.
  • Docker Compose Orchestration: Easily manage and run the entire stack with a single command.
  • Automated Setup Scripts: Scripts for initial Airflow setup and Keycloak client creation.

πŸ› οΈ Technologies Used

  • Apache Airflow
  • Keycloak
  • PostgreSQL
  • Docker
  • Docker Compose
  • Bash Scripting

πŸ“‚ Project Structure

.
β”œβ”€β”€ docker-compose.yml       # Defines the services for the Airflow stack
β”œβ”€β”€ .env                     # Environment variables for the stack (e.g., database credentials)
β”œβ”€β”€ README.md                # Project documentation (this file!)
β”œβ”€β”€ airflow                  # Airflow service configuration and DAGs
β”‚   β”œβ”€β”€ Dockerfile           # Builds the custom Airflow image
β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies for Airflow and DAGs
β”‚   β”œβ”€β”€ config/              # Airflow configuration files
β”‚   β”‚   └── webserver_config.py # Web server custom configuration (e.g., OAuth setup)
β”‚   β”œβ”€β”€ dags/                # Your Airflow Directed Acyclic Graphs (DAGs)
β”‚   β”‚   └── example_dag.py   # Example DAG to get you started
β”‚   β”œβ”€β”€ logs/                # Airflow runtime logs
β”‚   └── plugins/             # Custom Airflow plugins, operators, hooks
β”œβ”€β”€ configs                  # Global configuration files for the stack
β”‚   └── airflow.cfg          # Main Airflow configuration file
β”œβ”€β”€ keycloak                 # Keycloak service configuration
β”‚   β”œβ”€β”€ Dockerfile           # Builds the custom Keycloak image
β”‚   └── realm-export.json    # Keycloak realm configuration for initial setup
β”œβ”€β”€ postgres                 # PostgreSQL service configuration
β”‚   └── init.sql             # SQL script for initial database setup
└── scripts                  # Helper scripts for setup and management
    β”œβ”€β”€ init_airflow.sh      # Initializes Airflow (e.g., database, admin user)
    └── create_keycloak_client.sh # Automates Keycloak client creation for Airflow

πŸš€ Quick Start

Follow these steps to get your Airflow stack up and running:

  1. Clone the Repository:

    git clone https://github.com/AkashBhadana/Airflow-Stack.git
    cd Airflow-Stack
  2. Environment Variables: Create a .env file in the root directory (if not already present) and populate it with necessary environment variables, such as database credentials or Keycloak client secrets. A .env.example might be provided (not currently, but good practice).

  3. Build and Run the Stack:

    docker-compose up --build -d

    The -d flag runs the containers in detached mode.

  4. Access Airflow UI: Once all services are up and running, access the Airflow UI in your web browser: http://localhost:8080

  5. Access Keycloak Admin Console: The Keycloak admin console will be available at: http://localhost:8081 (You may need to refer to Keycloak setup documentation for initial admin credentials.)

πŸ“– Usage

  • Airflow: Develop and deploy your data pipelines by adding DAG files to the airflow/dags directory. Manage and monitor them via the Airflow UI.
  • Keycloak: Use the Keycloak admin console to manage users, roles, and clients for authenticating into Airflow.

πŸ“ Notes

  • Ensure Docker and Docker Compose are installed on your system.
  • The first user will be auto-created in Airflow upon their initial OAuth login via Keycloak.
  • Remember to secure your .env file and any sensitive configurations.

🀝 Contributing

Feel free to fork this repository, open issues, or submit pull requests to improve this Airflow stack.


Built with ❀️ for robust data orchestration.