Setting up Airflow on your Minikube Cluster using Helm
Prerequisites
- Basic Understanding of Kubernetes and Helm
- Basic Understanding of Apache Airflow and its components
Set up the following on your local system
Why Helm
- Helm provides automated life cycle hooks such as installing, upgrading and rolling back applications.
- Ensures consistency between the local and live states which prevents users from having to manage an application and its dependencies manually.
- Helm alleviates the issues with Kubernetes static resource files that cannot be parameterized by introducing values and templates.
The ability to dynamically generate declarative resource files makes it simpler to create YAML-based resources while still ensuring that applications are created in an easily reproducible manner.
Helm Chart for Apache Airflow
To set up Airflow on your local Minikube Cluster, follow the steps below
Bake DAGs in Docker image
- Create an folder
dags
and add a file namedsimple-dag.py
with the code below
1 | from datetime import datetime |
- Create a
Dockerfile
and add the code below
1 | FROM apache/airflow:2.3.0 |
- Create an account on Docker Hub
- Create a new repository , I am going to name mine
airflow-dag
- Build and push the DAG Container
1 | docker login |
Start Minikube Server
- Create a file
custom-values.yml
and add the following code below
1 | images: |
- Run the following commands on your terminal
1 | minikube start |
Restart the Scheduler ( in order to pick up the DAG images)
1 | kubectl get pods -n airflow |
Output:
1 | NAME READY STATUS RESTARTS AGE |
Get a shell to the running webserver container and run the following command airflow scheduler
1 | kubectl exec --stdin --tty --namespace airflow local-airflow-webserver-59d6b54584-t8wpf -- /bin/bash |
Output
1 | airflow@local-airflow-webserver-59d6b54584-t8wpf:/opt/airflow$ airflow scheduler |
- Visit the following URL (
127.0.0.1:8080
) by running the bash command below
1 | kubectl port-forward svc/local-airflow-webserver 8080:8080 --namespace airflow |
- Use
airflow
as username and password