目标
我想在库伯奈特斯上部署气流,在那里豆荚可以访问相同的DAG,在一个共享的持久卷中。根据文档(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
。
问题
在安装正式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
microk8s.helm install --namespace "airflow" --name "airflow" stable/airflow --values=values_pv.yaml
,values_pv.yaml
:https://pastebin.com/PryCgKnC /home/*user*/github/airflowDAGs
更改为机器上的路径以复制错误。
关注点
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
如何在Kubernetes部署中配置airflow.cfg
?在无容器的气流部署中,可以在~/airflow/airflow.cfg
中找到该文件.
airflow.cfg
中的第69行指:https://github.com/helm/charts/blob/master/stable/airflow/templates/deployments-web.yaml#L69其中包含git
。.yaml
是否配置错误,并且它错误地试图使用git pull
,但是由于没有指定git路径,这会失败吗?
系统
microk8s.kubectl version
:v1.15.4microk8s.helm version
:v2.14.3问题
如何正确地将正确的值传递给气流Helm图表,以便能够在拥有相同DAG和共享持久卷日志的情况下在Kubernetes上部署气流?
发布于 2019-11-25 10:35:45
不确定你是否已经解决了这个问题,但如果你没有,我认为有一个非常简单的方式接近你正在做的事情。
所有的部署、服务、Pods都需要持久化的卷信息--它生活在本地的地方,以及它应该在每一个kube类中所处的位置。看起来,图表的values.yaml提供了一种实现这一目标的方法。我只会在下面的dags中展示这一点,但我认为对于日志也应该是大致相同的过程。
因此,基本的步骤是: 1)告诉kube“音量”(目录)在您的计算机上的位置,2)告诉kube把它放在容器中的位置,3)告诉气流在哪里查找dags。因此,您可以从helm复制values.yaml文件,并使用以下方法对其进行修改。
airflow
部分首先,您需要创建一个包含本地目录中的项的卷(这是下面的extraVolumes
)。然后,这需要挂载-幸运的是,把它放在这里将模板它到所有库贝文件。一旦创建了该卷,就应该告诉它挂载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
airflow:
config:
AIRFLOW__CORE__DAGS_FOLDER: "/usr/local/airflow/dags" # this needs to match the mountPath in the extraVolumeMounts section
values.yaml
文件。helm install --namespace "airflow" --name "airflow" -f local/path/to/values.yaml stable/airflow
最后,这应该允许气流在dags文件夹中看到您的本地目录。如果您添加了一个新文件,它应该会显示在容器中--尽管在UI中显示可能需要一分钟时间--我不认为dagbag进程一直在运行?不管怎样,希望这能帮上忙!
发布于 2019-10-11 04:33:07
用yaml文件来做
因此,如果我们考虑使用values.yaml,就会出现一个问题,因为您用错误的方式编辑了它。
extraVolumeMounts: home/*user*/github/airflowDAGs
## Additional volumeMounts to the main containers in the Scheduler, Worker and Web pods.
# - name: synchronised-dags
# mountPath: /usr/local/airflow/dags
extraVolumes: home/*user*/github/airflowDAGs
## Additional volumes for the Scheduler, Worker and Web pods.
# - name: synchronised-dags
# emptyDir: {}
如果extraVolumeMounts需要name和mounthPath才能工作,那么您不能就这样传递路径,这就是为什么有#
的原因,所以您可以直接删除它们,添加您的值,它应该可以工作。
它应该是这样的
extraVolumeMounts:
- name: synchronised-dags
mountPath: /usr/local/airflow/dags
extraVolumes:
- name: synchronised-dags
emptyDir: {}
这就是安装它的方法:
1.使用helm fetch将气流图下载到您的个人电脑上。
helm fetch stable/airflow --untar
2.编辑airflow/ above . name extraVolumeMount和extraVolume,如上面所示,只需添加您的名称和路径即可。
nano/vi/vim airflow/values.yaml
3.你可以在气流/数值中更换休息物。
helm install ./airflow --namespace "airflow" --name "airflow" -f ./airflow/values.yaml
或
在只编辑extraVolumeMount和extraVolume时使用此命令
helm install --set dags.path=/home/user/github/airflowDAGs/dags --set logs.path=/home/user/github/airflowDAGs/logs --set persistence.enabled=false --set logsPersistence.enabled=false ./airflow --namespace "airflow" --name "airflow" -f ./airflow/values.yaml
结果:
NAME: airflow
LAST DEPLOYED: Fri Oct 11 09:18:46 2019
NAMESPACE: airflow
STATUS: DEPLOYED
RESOURCES:
==> v1/ConfigMap
NAME DATA AGE
airflow-env 20 2s
airflow-git-clone 1 2s
airflow-postgresql 0 2s
airflow-redis 3 2s
airflow-redis-health 3 2s
airflow-scripts 1 2s
==> v1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
airflow-flower 0/1 1 0 1s
airflow-scheduler 0/1 1 0 1s
airflow-web 0/1 1 0 1s
==> v1/PersistentVolumeClaim
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
airflow-postgresql Pending standard 2s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
airflow-flower-5596b45d58-wrg74 0/1 ContainerCreating 0 1s
airflow-postgresql-75bf7d8774-dxxjn 0/1 Pending 0 1s
airflow-redis-master-0 0/1 ContainerCreating 0 1s
airflow-scheduler-8696d66bcf-bwm2s 0/1 ContainerCreating 0 1s
airflow-web-84797489f5-8wzsm 0/1 ContainerCreating 0 1s
airflow-worker-0 0/1 Pending 0 0s
==> v1/Secret
NAME TYPE DATA AGE
airflow-postgresql Opaque 1 2s
airflow-redis Opaque 1 2s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
airflow-flower ClusterIP 10.0.7.168 <none> 5555/TCP 1s
airflow-postgresql ClusterIP 10.0.8.62 <none> 5432/TCP 2s
airflow-redis-headless ClusterIP None <none> 6379/TCP 1s
airflow-redis-master ClusterIP 10.0.8.5 <none> 6379/TCP 1s
airflow-web ClusterIP 10.0.10.176 <none> 8080/TCP 1s
airflow-worker ClusterIP None <none> 8793/TCP 1s
==> v1/ServiceAccount
NAME SECRETS AGE
airflow 1 2s
==> v1/StatefulSet
NAME READY AGE
airflow-worker 0/1 1s
==> v1beta1/Deployment
NAME READY UP-TO-DATE AVAILABLE AGE
airflow-postgresql 0/1 1 0 1s
==> v1beta1/PodDisruptionBudget
NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE
airflow-pdb N/A 1 0 2s
==> v1beta1/Role
NAME AGE
airflow 2s
==> v1beta1/RoleBinding
NAME AGE
airflow 2s
==> v1beta2/StatefulSet
NAME READY AGE
airflow-redis-master 0/1 1s
NOTES:
Congratulations. You have just deployed Apache Airflow
export POD_NAME=$(kubectl get pods --namespace airflow -l "component=web,app=airflow" -o jsonpath="{.items[0].metadata.name}")
echo http://127.0.0.1:8080
kubectl port-forward --namespace airflow $POD_NAME 8080:8080
2. Open Airflow in your web browser
https://stackoverflow.com/questions/58299948
复制相似问题