简体   繁体   English

如何让 Google Cloud Composer (airflow) 在不同的 kubernetes 集群上运行作业?

[英]How to let Google Cloud Composer (airflow) run jobs on a different kubernetes cluster?

I want to have my Cloud Composer environment (Google Cloud's managed Apache Airflow service) start pods on a different kubernetes cluster.我想让我的 Cloud Composer 环境(Google Cloud 的托管 Apache Airflow 服务)在不同的kubernetes 集群上启动 pod。 How should I do this?我该怎么做?

Note that Cloud composer runs airflow on a kubernetes cluster.请注意,Cloud composer 在 kubernetes 集群上运行气流。 That cluster is considered to be the composer "environment".该集群被认为是作曲家的“环境”。 Using the default values for the KubernetesPodOperator , composer will schedule pods on its own cluster.使用KubernetesPodOperator的默认值,composer 将在自己的集群上调度 pod。 However in this case, I have a different kubernetes cluster on which I want to run the pods.但是,在这种情况下,我有一个不同的 kubernetes 集群,我想在其上运行 pod。

I can connect to the worker pods and run a gcloud container clusters get-credentials CLUSTERNAME there, but every now and then the pods get recycled so this is not a durable solution.我可以连接到工作 Pod 并在gcloud container clusters get-credentials CLUSTERNAME运行gcloud container clusters get-credentials CLUSTERNAME ,但gcloud container clusters get-credentials CLUSTERNAME地回收这些 Pod,所以这不是一个持久的解决方案。

I noticed that the KubernetesPodOperator has both an in_cluster and a cluster_context argument, which seem useful.我注意到KubernetesPodOperator有一个in_cluster和一个cluster_context参数,这似乎很有用。 I would expect that this would work:我希望这会起作用:

pod = kubernetes_pod_operator.KubernetesPodOperator(
    task_id='my-task',
    name='name',
    in_cluster=False,
    cluster_context='my_cluster_context',
    image='gcr.io/my/image:version'
)

But this results in kubernetes.config.config_exception.ConfigException: Invalid kube-config file. Expected object with name CONTEXTNAME in kube-config/contexts list但这会导致kubernetes.config.config_exception.ConfigException: Invalid kube-config file. Expected object with name CONTEXTNAME in kube-config/contexts list kubernetes.config.config_exception.ConfigException: Invalid kube-config file. Expected object with name CONTEXTNAME in kube-config/contexts list

Although if I run kubectl config get-contexts in the worker pods, I can see the cluster config listed.虽然如果我在工作 Pod 中运行kubectl config get-contexts ,我可以看到列出的集群配置。

So what I fail to figure out is:所以我无法弄清楚的是:

  • how to make sure that the context for my other kubernetes cluster is available on the worker pods (or should that be on the nodes?) of my composer environment?如何确保我的其他 kubernetes 集群的上下文在我的 Composer 环境的工作 Pod 上可用(或者应该在节点上?)
  • if the context is set (as I did manually for testing purposes), how can I tell airflow to use that context?如果设置了上下文(就像我为测试目的手动设置的那样),我如何告诉气流使用该上下文?

Check out the GKEPodOperator for this. 为此,请查看GKEPodOperator

Example usage from the docs :文档中的示例用法:

operator = GKEPodOperator(task_id='pod_op',
                          project_id='my-project',
                          location='us-central1-a',
                          cluster_name='my-cluster-name',
                          name='task-name',
                          namespace='default',
                          image='perl')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google的Cloud Run与传统的Kubernetes集群有何不同? - How is Google's Cloud Run different from a traditional Kubernetes cluster? Google Cloud:如何将 kubernetes 集群移动到不同的区域? - Google Cloud: How to move kubernetes cluster to different region? 如何在Kubernetes集群上最好地运行Apache Airflow任务? - How to best run Apache Airflow tasks on a Kubernetes cluster? 气流kubernetes执行器:在同一Pod上运行2个作业 - Airflow kubernetes executor: Run 2 jobs on the same pod 从Google Composer(气流)检索Kubernetes的秘密 - Retrieve Kubernetes' Secret from Google Composer (Airflow) 如何在kubernetes上为Google Cloud Composer apt-get安装软件包 - How to apt-get install packages on kubernetes for Google cloud composer 如何与kubernetes集群共享我的Google云实例的数量 - How to share volume of my google cloud instance with the kubernetes cluster 如何将kubernetes事件从GKE集群传播到谷歌云日志 - How to propagate kubernetes events from a GKE cluster to google cloud log Google Cloud Kubernetes - 如何创建区域或区域 GKE 集群? - Google Cloud Kubernetes - How to create Zonal or Regional GKE cluster? 如何将谷歌云功能连接到kubernetes集群中的cassandra数据库 - How to connect a google cloud function to cassandra database in kubernetes cluster
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM