Quick start with kind

This article will show you how to install Airflow using Helm Chart on Kind

Install kind, and create a cluster

We recommend testing with Kubernetes 1.16+, example:

kind create cluster --image kindest/node:v1.18.15

Confirm it’s up:

kubectl cluster-info --context kind-kind

Add Airflow Helm Stable Repo

helm repo add apache-airflow https://airflow.apache.org
helm repo update

Create namespace

export NAMESPACE=example-namespace
kubectl create namespace $NAMESPACE

Install the chart

export RELEASE_NAME=example-release
helm install $RELEASE_NAME apache-airflow/airflow --namespace $NAMESPACE

Use the following code to install the chart with Example DAGs:

export NAMESPACE=example-namespace
helm install $RELEASE_NAME apache-airflow/airflow \
  --namespace $NAMESPACE \
  --set 'env[0].name=AIRFLOW__CORE__LOAD_EXAMPLES,env[0].value=True'

It may take a few minutes. Confirm the pods are up:

kubectl get pods --namespace $NAMESPACE
helm list --namespace $NAMESPACE

Run the following command to port-forward the Airflow UI to http://localhost:8080/ to confirm Airflow is working.

kubectl port-forward svc/$RELEASE_NAME-webserver 8080:8080 --namespace $NAMESPACE

Extending Airflow Image

The Apache Airflow community, releases Docker Images which are reference images for Apache Airflow. However when you try it out you want to add your own DAGs, custom dependencies, packages or even custom providers.

The best way to achieve it, is to build your own, custom image.

Adding DAGs to your image

  1. Create a project

    mkdir my-airflow-project && cd my-airflow-project
    mkdir dags  # put dags here
    cat <<EOM > Dockerfile
    FROM apache/airflow
    COPY . .
    EOM
    
  2. Then build the image:

    docker build --tag my-dags:0.0.1 .
    
  3. Load the image into kind:

    kind load docker-image my-dags:0.0.1
    
  4. Upgrade Helm deployment:

    helm upgrade $RELEASE_NAME apache-airflow/airflow --namespace $NAMESPACE \
        --set images.airflow.repository=my-dags \
        --set images.airflow.tag=0.0.1
    

Adding apt packages to your image

Example below adds vim apt package.

  1. Create a project

    mkdir my-airflow-project && cd my-airflow-project
    cat <<EOM > Dockerfile
    FROM apache/airflow
    USER root
    RUN apt-get update \
      && apt-get install -y --no-install-recommends \
             vim \
      && apt-get autoremove -yqq --purge \
      && apt-get clean \
      && rm -rf /var/lib/apt/lists/*
    USER airflow
    EOM
    
  2. Then build the image:

    docker build --tag my-image:0.0.1 .
    
  3. Load the image into kind:

    kind load docker-image my-image:0.0.1
    
  4. Upgrade Helm deployment:

    helm upgrade $RELEASE_NAME apache-airflow/airflow --namespace $NAMESPACE \
        --set images.airflow.repository=my-image \
        --set images.airflow.tag=0.0.1
    

Adding PyPI packages to your image

Example below adds lxml PyPI package.

  1. Create a project

    mkdir my-airflow-project && cd my-airflow-project
    cat <<EOM > Dockerfile
    FROM apache/airflow
    RUN pip install --no-cache-dir lxml
    EOM
    
  2. Then build the image:

    docker build --tag my-image:0.0.1 .
    
  3. Load the image into kind:

    kind load docker-image my-image:0.0.1
    
  4. Upgrade Helm deployment:

    helm upgrade $RELEASE_NAME apache-airflow/airflow --namespace $NAMESPACE \
        --set images.airflow.repository=my-image \
        --set images.airflow.tag=0.0.1
    

Further extending and customizing the image

See Building the image for more details on how you can extend and customize the Airflow image.

Was this entry helpful?