Giter Site home page Giter Site logo

airflow-k8s-poc's Introduction

Deploying Airflow on kubernetes using official helm chart

Instructions

  1. create dedicated ns for airflow deployment
kubectl create namespace airflow
  1. Add helm repo:
helm repo add airflow-stable https://airflow-helm.github.io/charts
  1. Prepair values for the chart:

generate FERNET_KEY:

python3 -c "from cryptography.fernet import Fernet; FERNET_KEY = Fernet.generate_key().decode(); print(FERNET_KEY)"
  1. create secret and configmap putting appropriate values in the files in the repo.
kubectl apply -f  secrets.yaml
kubectl apply -f configmap.yaml 

  1. define connection ids in " connections: " , for example added spark on k8s connection.

  2. add extra packages that need to be installed to configure

  3. set appropriate s3 bucket name in config.AIRFLOW__LOGGING__REMOTE_BASE_LOG_FOLDER = "s3://qxmips-airflow-logs" and assign a role with access to s3 bucket that can be assumed by pod:

serviceAccount:
  create: true
  name: "airflow"
  annotations: 
    eks.amazonaws.com/role-arn: "arn:aws:iam::123456789123:role/airflow20211025170151352700000001"
  1. in gitSync spesify a repo with DAGs, and create secrets for git authentication:
gitSync:
    ## if the git-sync sidecar container is enabled
    ##
    enabled: true
    repo: "[email protected]:USERNAME/REPOSITORY.git"
    branch: "master"
    revision: "HEAD"
    syncWait: 60
    sshSecret: "airflow-ssh-git-secret"
  1. Configure ingress, for example:
ingress:
  enabled: true
  apiVersion: networking.k8s.io/v1
  web:
    annotations: 
        kubernetes.io/ingress.class: "nginx"
        kubernetes.io/tls-acme: "true"
        cert-manager.io/cluster-issuer: acme
    labels: {}
    path: ""
    host: "airflow.qxmips.com"
    tls:
      enabled: true
      secretName: "airflow-le-cert"
  1. Deploy helm chart using the resulting values file:
helm install airflow airflow-stable/airflow  -n airflow  --version "8.5.2"  --values ./values.yaml

Deploying new DAGs

You can use git-sync sidecar container to sync a repo with DAGs to airflow. This is the recommended way.Using this method complies with gitops approach. If you got multiple repos you can create a repository that consists of submodules, for more refer airflow-helm/charts#434

Other option would be to use peristant volume either existing or created by the chart. that method is less prefered bacause it adds aditional efforts to deliver DAGs inside the PV.

Persisting logs

For production, you should persist logs in a production deployment using object storage like s3 or PersistentVolumeClaim. Generally s3 or other object storage is prefered as it has higher availability and durability levels. By default, logs are stored within the container's filesystem, therefore any restart of the pod will wipe your DAG logs. See the instructions steps above explains how to configure s3 for storing the logs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.