Cloud Composer + Airflow:设置DAW以在HTTP上触发(或者我应该使用Cloud Functions吗?)

编程入门 行业动态 更新时间:2024-10-27 22:20:42
本文介绍了Cloud Composer + Airflow:设置DAW以在HTTP上触发(或者我应该使用Cloud Functions吗?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

最终,我想做的是有一个Python脚本,该脚本可以在创建HTTP请求时动态地运行.就像这样:App 1运行并发出一个Webhook,Python脚本立即捕获该Webhook并执行其所有操作.

Ultimately, what I want to do is have a Python script that runs whenever a HTTP request is created, dynamically. It'd be like: App 1 runs and sends out a webhook, Python script catches the webhook immediately and does whatever it does.

我看到您可以在GCP中使用Composer和Airflow来做到这一点.

I saw that you could do this in GCP with Composer and Airflow.

但是在这些工具之后,我遇到了几个问题 cloud.google/composer/docs/how-to/using/triggering-with-gcf :

But I'm having several issues following these instrutions cloud.google/composer/docs/how-to/using/triggering-with-gcf:

  • 在Cloud Shell中运行此操作以授予Blob签名权限:

  • Running this in Cloud Shell to grant blob signing permissions:

    gcloud iam服务帐户add-iam-policy-binding your-project-id@appspot.gserviceaccount --member = serviceAccount:your-project-id@appspot.gserviceaccount --role = roles/iam.serviceAccountTokenCreator

    gcloud iam service-accounts add-iam-policy-binding your-project-id@appspot.gserviceaccount --member=serviceAccount:your-project-id@appspot.gserviceaccount --role=roles/iam.serviceAccountTokenCreator

    当我输入项目ID时,我会得到一个找不到针对您的project-id@appspot.gserviceaccount的盖亚ID"

    When I put in my project ID, I get a "Gaia id not found for your-project-id@appspot.gserviceaccount"

  • 当我运行airflow_uri = environment_data ['config'] ['airflowUri']位时,我在'config'上遇到关键错误.
  • 是否有更好的方法来做我想做的事情(即动态运行Python脚本)?


    Is there a better way to do what I'm trying to do (i.e. run Python scripts dynamically)?

    推荐答案

    获得原因:未找到电子邮件的盖亚ID< project-id> @ appspot.gserviceaccount 错误在您的项目中启用所有必需的API.请按照以下步骤操作:

    The reason for getting: Gaia id not found for email <project-id>@appspot.gserviceaccount error is not enabling all needed APIs in your project. Please follow the steps:

  • 创建或选择您要使用的Google Cloud Platform项目.
  • 启用Cloud Composer,Google Cloud Functions和Cloud Identity以及Google Identity and Access Management(IAM)API.您可以在 Menu ->中找到它.产品-> Marketplace ,然后输入相应API的名称.
  • 授予对Cloud Functions Service帐户的Blob签名权限.为了使GCF向保护气流Web服务器的代理Cloud IAP进行身份验证,您需要向Appspot服务帐户GCF授予服务帐户令牌创建者角色.为此,请在您的Cloud Shell中运行以下命令,将项目名称替换为< your-project-id> :
  • Create or select Google Cloud Platform Project you wish to work with.
  • Enable the Cloud Composer, Google Cloud Functions and Cloud Identity and Google Identity and Access Management (IAM) APIs. You can find it in Menu -> Products -> Marketplace and typing the name of corresponding API.
  • Grant blob signing permissions to the Cloud Functions Service Account. In order for GCF to authenticate to Cloud IAP, the proxy that protects the Airflow webserver, you need to grant the Appspot Service Account GCF the Service Account Token Creator role. Do so by running the following command in your Cloud Shell, substituting the name of your project for <your-project-id>:
  • gcloud iam service-accounts add-iam-policy-binding \ <your-project-id>@appspot.gserviceaccount \ --member=serviceAccount:<your-project-id>@appspot.gserviceaccount \ --role=roles/iam.serviceAccountTokenCreator

    我测试了该方案,首先没有启用API,并且检索到与您相同的错误.启用API后,错误消失并且IAM策略已正确更新.

    I tested the scenario, firstly without enabling APIs and I've retrieved the same error as you. After enabling the APIs, error disappear and IAM policy has been updated correctly.

    已经充分描述了代码实验室教程,其中显示了使用Google Cloud Functions触发DAG的工作流程.

    There is already well described Codelabs tutorial, which shows the workflow of triggering the DAG with Google Cloud Functions.

    更多推荐

    Cloud Composer + Airflow:设置DAW以在HTTP上触发(或者我应该使用Cloud Functions吗?)

    本文发布于:2023-11-24 11:19:17,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1624995.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Airflow   Composer   Cloud   Functions   HTTP

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!