Deployment Overview of Apache Airflow on Server¶
Prerequisites and Basic Requirements¶
The deployment requires a Debian-based operating system, specifically Debian Bookworm or Ubuntu. The system must have root privileges to install packages and configure services. The following system dependencies are required for the environment:
apt-utilsca-certificatescurldumb-initfreetds-binkrb5-userlibgeos-devldap-utilslibsasl2-2libsasl2-moduleslibxmlsec1localeslibffi-devlibldap-2.5-0libssl-devnetcat-openbsdlsb-releaseopenssh-clientpython3-selinuxrsyncsasl2-binsqlite3sudounixodbcpipxpython3-pippostgresqlfindutils
The application utilizes port 8080 for the webserver interface.
File and Directory Structure¶
Configuration and data files are organized in the following locations:
- Systemd Service Files: Located in
/etc/systemd/system/. airflow-webserver.serviceairflow-scheduler.service- Nginx Configuration: Located in
/root/nginx/. compose.yml- Nginx Data and Secrets:
- Let's Encrypt secrets are stored in the
nginx_secretsvolume mounted at/etc/letsencrypt. - User configuration files are stored in
/data/nginx/user_conf.d. - Environment Variables: Nginx environment variables are defined in
/data/nginx/nginx-certbot.env. - Pipx Installation: If using Debian Bookworm, the
pipxhome directory is set to/opt/pipxand binaries are installed to/usr/local/bin.
Application Installation Process¶
Apache Airflow is installed using Python package managers. The installation method depends on the operating system version:
-
Debian Bookworm: Airflow is installed using
The environment variablespipxwith theceleryextra. The command executed is:PIPX_HOMEandPIPX_BIN_DIRare configured to/opt/pipxand/usr/local/binrespectively. -
Ubuntu or Debian Bullseye: Airflow is installed using
pipwith specific constraints and flags to handle system packages:
After installation, the Airflow binary location is detected using the find command across /usr/local/bin, /usr/bin, and /root/.local/bin. The database is initialized by running:
An administrative user is created with the following parameters: - Username: admin - First Name: admin - Last Name: admin - Role: Admin - Email: [email protected] - Password: Set to the SSH password used for the server connection.
Docker Containers and Their Deployment¶
Docker is installed on the server to manage the reverse proxy and SSL certificate management. The deployment uses Docker Compose to orchestrate the Nginx container.
The compose.yml file is generated in /root/nginx/ and defines the following service:
- Service Name:
nginx - Image:
jonasal/nginx-certbot:latest - Restart Policy:
unless-stopped - Network Mode:
host - Environment:
CERTBOT_EMAIL: Set to[email protected]- Additional variables are loaded from
/data/nginx/nginx-certbot.env - Volumes:
nginx_secrets(external volume) mounted to/etc/letsencrypt/data/nginx/user_conf.dmounted to/etc/nginx/user_conf.d
The container is started using the command:
executed from the/root/nginx directory. Proxy Servers¶
The server utilizes Nginx as a reverse proxy with integrated Let's Encrypt certificate management via the jonasal/nginx-certbot container.
- Domain Configuration: Custom domains and SSL certificates are managed through the Nginx container.
- Certificate Management: Certificates are requested and renewed automatically by the container using the email
[email protected]. - Configuration Path: Custom Nginx configurations are placed in
/data/nginx/user_conf.dand mounted into the container. - Secrets Storage: SSL certificates and keys are stored in the external Docker volume
nginx_secretsat/etc/letsencrypt.
Starting, Stopping, and Updating¶
Apache Airflow services are managed via systemd. The following services are configured:
airflow-webserver: Runs the web interface on port8080.airflow-scheduler: Runs the background scheduler.
To manage these services, use the following commands:
- Start Services:
- Stop Services:
- Enable Services on Boot:
- Reload Systemd Daemon:
- Check Service Status:
The Docker-based Nginx proxy is managed via Docker Compose commands in the /root/nginx directory: - Start/Restart: docker compose up -d - Stop: docker compose down