啟用及停用 Managed Airflow 服務

Managed Airflow (第 3 代) | Managed Airflow (第 2 代) | Managed Airflow (舊版第 1 代)

本頁面說明如何在 Google Cloud 專案中啟用及停用 Managed Service for Apache Airflow 服務。

如要瞭解 Google Cloud上的服務管理,請參閱「啟用及停用服務」。

如需 Managed Airflow 在 VPC Service Controls 設定中所需的服務清單,請參閱「設定 VPC Service Controls」。

Managed Service for Apache Airflow 必要的服務

本節說明 Managed Airflow (第 2 代) 所需的服務。在某些情況下,組織或專案管理員可以限制專案中可使用的 Google 服務。

Managed Airflow (第 2 代) 需要下列服務:

  • composer.googleapis.com
  • compute.googleapis.com
  • logging.googleapis.com
  • monitoring.googleapis.com
  • storage.googleapis.com
  • cloudresourcemanager.googleapis.com
  • servicedirectory.googleapis.com
  • pubsub.googleapis.com
  • sqladmin.googleapis.com
  • cloudkms.googleapis.com (如果您使用 Cloud KMS 或 CMEK 金鑰)
  • secretmanager.googleapis.com (如果使用 Secret Manager 做為 Secret 後端)

  • artifactregistry.googleapis.com

  • cloudbuild.googleapis.com

  • container.googleapis.com

  • (僅限 Managed Airflow 2.0.* 版) deploymentmanager.googleapis.com

在多數專案中,Cloud DNS 或 IAM 等 Google 服務預設為允許。

啟用 Managed Airflow 服務

本節說明如何在 Google Cloud 專案中啟用 Managed Airflow 服務。

啟用服務前的準備工作

啟用 Cloud Composer API

控制台

啟用 Cloud Composer API:

啟用 API 所需的角色

如要啟用 API,您必須具備 serviceusage.services.enable 權限。如果您建立了專案,可能已透過擁有者角色 (roles/owner) 取得這項權限。否則,您可以透過 Service Usage 管理員角色 (roles/serviceusage.serviceUsageAdmin) 取得這項權限。瞭解如何授予角色。

啟用 API

gcloud

啟用 composer.googleapis.com API:

啟用 API 所需的角色

如要啟用 API,您必須具備 serviceusage.services.enable 權限。如果您建立了專案,可能已透過「擁有者」角色 (roles/owner) 取得這項權限。否則,您可以透過「Service Usage 管理員」角色 (roles/serviceusage.serviceUsageAdmin) 取得這項權限。瞭解如何授予角色。

gcloud services enable composer.googleapis.com

API

使用 services.enable 方法啟用 composer.googleapis.com API。

Terraform

使用 google_project_service 資源設定 composer.googleapis.com API。

啟用 Managed Airflow (第 2 代) 依附元件

如要啟用 Managed Airflow (第 2 代) 所需的所有依附元件,請使用下列 Google Cloud CLI 指令啟用 services/composer.googleapis.com/groups/dependencies@composer2 服務群組:

gcloud

執行 gcloud beta services enable 指令:

gcloud beta services enable composer.googleapis.com \
    --group dependencies@composer2

或者,您也可以手動啟用 Managed Airflow (第 2 代) 所需的其他依附元件,例如透過 Google Cloud 控制台或 Terraform:

  • artifactregistry.googleapis.com
  • cloudbuild.googleapis.com
  • container.googleapis.com
  • pubsub.googleapis.com
  • sqladmin.googleapis.com

啟用 DAG 所需的服務

除了 Managed Airflow 所需的服務外,請一併啟用 DAG 使用的所有服務,例如:

  • bigquery.googleapis.com
  • dataflow.googleapis.com
  • datacatalog.googleapis.com

如要查看服務的 *.googleapis.com 名稱,請前往 API Explorer 頁面,點選連結前往 API 頁面。

停用 Managed Airflow 服務

本節說明如何停用 Google Cloud 專案中的 Managed Airflow 服務。

停用服務前的注意事項

  • 如要停用 Managed Airflow 服務,您必須具備正確的 Identity and Access Management 權限。如要瞭解 Service Usage 的 IAM 需求,請參閱 Service Usage 的「存取控管」頁面。

  • 請確認專案中的所有 Managed Airflow 環境都已刪除。停用 API 會永久刪除 Managed Airflow 環境的租戶專案部分,導致這些環境無法使用。

  • 為避免產生額外費用,請先為每個環境完成下列步驟,再停用 Cloud Composer API:

    1. 暫停 DAG。
    2. 如有需要,請匯出環境的資料,例如環境 bucket 中的 DAG。
    3. 刪除環境,包括未自動刪除的資源。

停用 Cloud Composer API

如要停用 Managed Airflow 服務,請按照下列步驟操作:

控制台

  1. 前往 Google Cloud 控制台的「Cloud Composer API」頁面。

    前往 Cloud Composer API

  2. 點選「管理」。

  3. 點選「停用 API」。

gcloud

執行 gcloud services disable 指令:

gcloud services disable composer.googleapis.com

API

使用 services.disable 方法停用 composer.googleapis.com API。

Terraform

移除 composer.googleapis.com API 的設定。您通常會使用 google_project_service 資源來設定 Google Cloud 服務。

淘汰 Managed Airflow (第 3 代) 不需要使用的服務

我們將逐步淘汰 Managed Airflow (第 3 代) 不需要使用的 API。

下列 API 依附元件尚未分離,預計日後會從 Cloud Composer API 分離:

  • sqladmin.googleapis.com
  • pubsub.googleapis.com

下列 API 已完全可拆式。停用下列 API 不會導致 Cloud Composer API 停用:

  • artifactregistry.googleapis.com
  • cloudbuild.googleapis.com
  • container.googleapis.com

啟用 Cloud Composer API 時,系統不會再自動啟用所有列為分離的 API。如要在新專案中建立 Managed Airflow (第 2 代) 環境,除了 Cloud Composer API 之外,也請啟用一組分離的 API。

如果專案已啟用 Cloud Composer API,則現有的 Managed Airflow (第 3 代) 和 Managed Airflow (第 2 代) 環境不受這項異動影響。您可以採取以下做法:

  • 如果專案只有 Managed Airflow (第 3 代) 環境,您可以手動停用已卸載的 API。

  • 如果專案有 Managed Airflow (第 2 代) 環境,建議您保持啟用這些 API,否則停用可能會導致環境故障。

  • 如果您使用自動化指令碼佈建 Managed Airflow (第 2 代) 環境,請務必啟用列出的 API 和 Cloud Composer API。您可以手動啟用,或使用 gcloud CLI 指令啟用。

後續步驟