如何使用git sync使Airflow从一个git分支的dag文件夹中获取DAG。

8

我的公司使用 git-sync 将压缩的 DAG 同步到 Airflow 中。我们使用 Airflow Helm Charts 部署 Airflow。我想知道是否可以让 Airflow 只在 git 分支的特定文件夹(例如 dags-dev)中选择要运行的压缩的 DAG,而不是所有压缩的 DAG?

以下是一些有用的参考资料。

Airflow Helm Charts 的值文件。 https://github.com/helm/charts/blob/master/stable/airflow/values.yaml

我们的 DAG 代码如下:

dags:
      doNotPickle: true
      git:
        url: <git url>
        ref: master
        gitSync:
          enabled: true
          image:
            repository: <some repo>
            tag: 1.0.7
          refreshTime: 60
      initContainer:
        enabled: true
        image:
          repository: <some repo>
          tag: 1.0.7

Airflow的git同步配置如下:

AIRFLOW__KUBERNETES__DAGS_VOLUME_SUBPATH: repo # must match AIRFLOW__KUBERNETES__GIT_SUBPATH
AIRFLOW__KUBERNETES__GIT_REPO: <git repo>
AIRFLOW__KUBERNETES__GIT_BRANCH: master
AIRFLOW__KUBERNETES__GIT_DAGS_FOLDER_MOUNT_POINT: /opt/airflow/dags
AIRFLOW__KUBERNETES__GIT_USER: <some user>
AIRFLOW__KUBERNETES__GIT_PASSWORD: <some password>
AIRFLOW__KUBERNETES__GIT_SYNC_CONTAINER_REPOSITORY: gitlab.beno.ai:4567/eng/external-images/k8s.gcr.io/git-sync
AIRFLOW__KUBERNETES__GIT_SYNC_CONTAINER_TAG: v3.1.1

你解决了吗? - eduartua
2个回答

0

0

看起来这个实现不支持git子路径,而且如果你查看子路径方法的背后,会发现有一个git克隆,然后是目录过滤。作为git部分克隆的新功能git-sparse-checkout仍处于实验阶段。

因此,一个解决方案可以是利用dags-path指向存储库中的子目录。

###################################
# Airflow - DAGs Configs
###################################
dags:
  ## the airflow dags folder
  ##
  path: /opt/airflow/dags/repo/dir

注意:我建议您将生产工作负载从此迁移到任何其他维护的airflow实现,因为它现在已存档并且不再修补。

这里是您所需选项的示例bitnami/airflow

# bitnami airflow helm values.yaml reference
repositories:
  - repository: https://gitlab.com/repo.git
    ## Branch from repository to checkout
    ##
    branch: "master"
    ## An unique identifier for repository, must be unique for each repository
    ##
    name: "dags"
    ## Path to a folder in the repository containing the dags
    ##
    path: ""

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接