Database architecture
- PostgreSQL
- MySQL
Each Deployment has a single PostgreSQL database containing two schemas:
Retrieve the connection string
Each Deployment stores its database connection string in a Kubernetes secret named<release-name>-metadata. Run the following command to retrieve it:
- PostgreSQL
- MySQL
Connect to the database
Use kubectl exec
Run the following command to open an Airflow metadata database shell from the scheduler pod:Connect from your local computer
If the database is accessible as a Kubernetes service, you can usekubectl port-forward to connect from your local computer. Identify the database service and namespace from the <host> field in the connection string, then forward the port:
- PostgreSQL
- MySQL
If PgBouncer is enabled, forward port 6543 from the PgBouncer service in the
Deployment namespace instead.
Common queries
After you connect to the database, use the following queries to inspect Airflow metadata.Dag information
- Airflow 2.x
- Airflow 3.x
Task instance status
Task failures
- PostgreSQL
- MySQL
External database configuration
To use an external database instead of the APC-managed database, create the Deployment using theupsertDeployment APC API mutation with the following fields:
skipAirflowDatabaseProvisioning: Set totrueso the deployment orchestrator doesn’t provision a database for this Deployment.metadataConnectionormetadataConnectionJson: The connection string or JSON object pointing to your external database.resultBackendConnectionorresultBackendConnectionJson: The connection string or JSON object for the Celery result backend.
upsertDeployment mutation payload with external database configuration, see Bring your own Airflow database.
Back up and restore
Before you run a backup, estimate the database size and confirm that your local computer has enough free disk space.- PostgreSQL
- MySQL
Back up the database
- PostgreSQL
- MySQL
Restore the database
- PostgreSQL
- MySQL
Security best practices
- Use read-only access for monitoring.
- Never expose database ports publicly.
- Use SSL for all connections.
- Rotate credentials regularly.