Helm stable/airflow - 使用 Helm 图表失败时使用共享持久卷进行 Airflow 部署的自定义值

2023-12-23

客观的

我想在 Kubernetes 上部署 Airflow,其中 Pod 可以访问共享持久卷中的相同 DAG。 根据文档(https://github.com/helm/charts/tree/master/stable/airflow#using-one-volume-for-both-logs-and-dags https://github.com/helm/charts/tree/master/stable/airflow#using-one-volume-for-both-logs-and-dags),看来我必须设置这些值并将其传递给 Helm:extraVolume, extraVolumeMount, persistence.enabled, logsPersistence.enabled, dags.path, logs.path.

Problem

我在安装官方 Helm 图表时传递的任何自定义值都会导致类似于以下内容的错误:

Error: YAML parse error on airflow/templates/deployments-web.yaml: error converting YAML to JSON: yaml: line 69: could not find expected ':'
  • 工作正常:microk8s.helm install --namespace "airflow" --name "airflow" stable/airflow
  • 不工作:
microk8s.helm install --namespace "airflow" --name "airflow" stable/airflow \
--set airflow.extraVolumes=/home/*user*/github/airflowDAGs \
--set airflow.extraVolumeMounts=/home/*user*/github/airflowDAGs \
--set dags.path=/home/*user*/github/airflowDAGs/dags \
--set logs.path=/home/*user*/github/airflowDAGs/logs \
--set persistence.enabled=false \
--set logsPersistence.enabled=false
  • Also not working: microk8s.helm install --namespace "airflow" --name "airflow" stable/airflow --values=values_pv.yaml, with values_pv.yaml: https://pastebin.com/PryCgKnC https://pastebin.com/PryCgKnC
    • 编辑:请更改/home/*user*/github/airflowDAGs到您计算机上的路径以复制错误。

Concerns

  1. 也许是因为默认的这些行而出错values.yaml:
## Configure DAGs deployment and update
dags:
  ##
  ## mount path for persistent volume.
  ## Note that this location is referred to in airflow.cfg, so if you change it, you must update airflow.cfg accordingly.
  path: /home/*user*/github/airflowDAGs/dags

我该如何配置airflow.cfg在 Kubernetes 部署中?在 Airflow 的非容器化部署中,可以在以下位置找到此文件~/airflow/airflow.cfg.

  1. 69号线airflow.cfg指:https://github.com/helm/charts/blob/master/stable/airflow/templates/deployments-web.yaml#L69 https://github.com/helm/charts/blob/master/stable/airflow/templates/deployments-web.yaml#L69

其中包含git。是.yaml配置错误,并且错误地尝试使用git pull,但是由于没有指定 git 路径,所以失败了?

System

  • 操作系统:Ubuntu 18.04(单机)
  • MicroK8s:v1.15.4 修订版:876
  • microk8s.kubectl version:v1.15.4
  • microk8s.helm version:v2.14.3

Question

如何正确地将正确的值传递到 Airflow Helm 图表,以便能够在 Kubernetes 上部署 Airflow,并且 Pod 可以访问共享持久卷上的相同 DAG 和日志?


不确定你是否已经解决了这个问题,但如果你还没有解决,我认为有一个非常简单的方法接近你正在做的事情。

所有部署、服务、Pod 都需要持久卷信息——它在本地的位置以及在每种 kube 类型中应该放置的位置。看起来图表的 value.yaml 提供了一种方法来执行此操作。我只会在下面用 dags 来展示这一点,但我认为日志的过程也应该大致相同。

因此,基本步骤是,1)告诉 kube “卷”(目录)在计算机上的位置,2)告诉 kube 将其放在容器中的何处,以及 3)告诉气流在哪里寻找 dags。因此,您可以从 helm 存储库复制values.yaml 文件并使用以下内容对其进行更改。

  1. The airflow section

首先,您需要创建一个包含本地目录中的项目的卷(这是extraVolumes以下)。然后,需要安装它 - 幸运的是,将其放在这里会将其模板化到所有 kube 文件中。创建该卷后,您应该告诉它挂载dags。所以基本上,extraVolumes创建体积,并且extraVolumeMounts安装卷。

airflow:
  extraVolumeMounts: # this will get the volume and mount it to that path in the container                                                                                                                                                               
  - name: dags
    mountPath: /usr/local/airflow/dags  # location in the container it will put the directory mentioned below.

  extraVolumes: # this will create the volume from the directory
  - name: dags
    hostPath:
      path: "path/to/local/directory"  # For you this is something like /home/*user*/github/airflowDAGs/dags

  1. 告诉气流配置 dags 在容器中的位置(与上面相同的 yaml 部分)。
airflow:
  config:
    AIRFLOW__CORE__DAGS_FOLDER: "/usr/local/airflow/dags"  # this needs to match the mountPath in the extraVolumeMounts section
  1. 使用 helm 和新的安装values.yaml file.
helm install --namespace "airflow" --name "airflow" -f local/path/to/values.yaml stable/airflow

最后,这应该允许气流看到 dags 文件夹中的本地目录。如果您添加一个新文件,它应该显示在容器中 - 尽管可能需要一分钟才能显示在 UI 中 - 我不认为 dagbag 进程一直在运行?无论如何,希望这有帮助!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Helm stable/airflow - 使用 Helm 图表失败时使用共享持久卷进行 Airflow 部署的自定义值 的相关文章

随机推荐