CSCfi / airflow-openshift

Run Apache Airflow on OpenShift
13 stars 10 forks source link

airflow-openshift

The purpose of this template is to easily deploy Apache Airflow on Openshift.

Airflow container image

The used Airflow container image is built using the official image source codes distributed by Airflow, built with the additional providers packages by Apache Spark, Papermill and Mongo. It should also be possible to build your own image and deploy the template using that image, as long as the image is built using the official sources.

Useful variables

The template can be imported via the Openshift web UI or added via the command line interface (oc)

The required variables which need to be present in order to run the template are:

Rest of the variables are optional and have a value by default which can be changed, if needed.

Some of the useful variables to you as the user could be:

How to upload DAGs on the Airflow webserver

The current template deploys a Jupyter pod for writing the python code for DAGs. The password will be the one you set in JUPYTER_PASSWORD variable. Note When accessing Jupyter, you need to click on Upload to upload an existing python code (.py extension) of the Airflow DAG or you could click on New->Text File and then write the python code in the text file itself, but remember to save it with the .py extension

It can take up to 5 minutes for the DAGs to show up in the web UI, so be patient!

How to install custom Python libraries

Setting configuration variables

If you want to change the Airflow configuration, the best way to do it is to add new environment variables in the deployment configs of the pods. Be aware that some variables have to be set in the worker pods, while some have to be set in the webserver pod for the effect to take place! For more information about configuring Airflow with environment variables, check the official documentation here. For a list of all available Airflow configurations, see here.

Configuring email host

Airflow can be configured to send emails: you can both send custom emails through Airflow as a task, or receive alert emails yourself if one of your DAG runs have failed. For the email system to work the following configuration variables have to be set in the deployment config of worker:

And, if the smtp host requires it:

If you need CSC specific configuration, contact servicedesk@csc.fi.

To use a Google Gmail account as the email host, you first have to create an App Password to your account. To set up an App Password, follow instructions in https://support.google.com/accounts/answer/185833?hl=en.

When you have the password, enter these as environment variables in the worker deployment config:

How to create a connection to a custom S3 object Store

Create a connection via the Airflow web UI by clicking on Admin->Connections , then fill the following fields: