简体   繁体   English

Airflow 连接单个 DAG

[英]Airflow connection for a single DAG

I am creating a connection with a Google Service Account in my Google Cloud Composer that privilegies a DAG for a specific use case with deals with sensitive data, the point is that I want that connection to be exclusive for a certain DAG and no other could see or use it.我正在我的 Google Cloud Composer 中创建与 Google 服务帐户的连接,该连接为处理敏感数据的特定用例授予 DAG 特权,关键是我希望该连接专供某个 DAG 使用,其他人看不到或使用它。

Is there a way of doing it?有没有办法做到这一点?

Currently this is not possible in airflow, and even you cannot implement that using a custom backend secret or another solution, where the connection is not a context variable, and it's accessible from anywhere in airflow not only from a run context.目前这在 airflow 中是不可能的,即使您无法使用自定义后端密钥或其他解决方案来实现它,其中连接不是上下文变量,并且不仅可以从运行上下文中从 airflow 中的任何位置访问它。

Infortunately the service account given to Cloud Composer in the creation of cluster, is for all DAGs of this cluster.幸运的是,在创建集群时为 Cloud Composer 提供的服务帐户适用于该集群的所有 DAG。

It can be too much, but maybe you can create another Cloud Composer cluster 2 (GKE autopilot), with the minimum sizing for machines, containing this DAG that treats sensitive data.它可能太多了,但也许您可以创建另一个 Cloud Composer 集群 2(GKE 自动驾驶仪),具有最小的机器大小,包含处理敏感数据的 DAG。 Then you can give a SA with the needed privileges to this cluster.然后,您可以向该集群授予具有所需权限的 SA。

The disadvantage of this solution is you will have a higher cost, because you have a second cluster.此解决方案的缺点是您将拥有更高的成本,因为您有第二个集群。 It will increases the cost even if the machine sizes are low.即使机器尺寸很小,也会增加成本。 It is worth noting that Composer 2 with GKE autopilot is cheaper that classical GKE cluster.值得注意的是,带有 GKE 自动驾驶仪的 Composer 2 比经典的 GKE 集群更便宜。

Maybe another solution, if the rework is not too important, you can rewrite only your DAG treating sensitive data to Cloud Workflow.也许另一种解决方案,如果返工不是太重要,您可以只将处理敏感数据的 DAG 重写到 Cloud Workflow。 Cloud Workflow is serverless and you can give it a dedicated service account. Cloud Workflow 是无服务器的,您可以为其提供专用服务帐户。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM