[英]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:所以我无法弄清楚的是:
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.