【发布时间】:2019-11-28 03:32:53
【问题描述】:
我有兴趣在 Kubernetes 上运行特定的 Airflow 任务。气流工作者本身不需要在 Kubernetes 上运行。做了一些研究,我遇到了 KubernetesPodOperator。但是我没有找到如何配置操作员在集群中运行的示例。是否可以将 KubernetesPodOperator 配置为在远程集群上运行任务?行为应该类似于 ECSOperator。
【问题讨论】:
标签: kubernetes airflow
我有兴趣在 Kubernetes 上运行特定的 Airflow 任务。气流工作者本身不需要在 Kubernetes 上运行。做了一些研究,我遇到了 KubernetesPodOperator。但是我没有找到如何配置操作员在集群中运行的示例。是否可以将 KubernetesPodOperator 配置为在远程集群上运行任务?行为应该类似于 ECSOperator。
【问题讨论】:
标签: kubernetes airflow
Airflow 可以在 Kubernetes 内部和外部运行。
在您的情况下,当您在 Kubernetes 集群之外运行气流时,您需要告诉气流在哪里可以找到 Kubernetes 集群。
在KubernetesPodOperator source code
client = kube_client.get_kube_client(in_cluster=self.in_cluster,
cluster_context=self.cluster_context,
config_file=self.config_file)
在启动 KubernetesPodOperator 时需要设置这三个参数
这些参数的详细解释也在源代码中:
:param in_cluster: run kubernetes client with in_cluster configuration.
:param cluster_context: context that points to kubernetes cluster. Ignored when in_cluster is True. If None, current-context is used.
:param config_file: The path to the Kubernetes config file. (templated) If not specified, default value is ``~/.kube/config``
【讨论】: