Managed Service for Apache Spark 網路設定

本文說明 Managed Service for Apache Spark 網路設定的必要條件。

虛擬私有雲子網路需求

本文說明 Apache Spark 代管服務批次工作負載和互動式工作階段的虛擬私有雲網路需求。

私人 Google 存取權

Managed Service for Apache Spark 批次工作負載和互動式工作階段,只會在具有內部 IP 位址的 VM 上執行,並在區域子網路上自動啟用 Private Google Access (PGA)

如果您未指定子網路,Managed Service for Apache Spark 會在批次工作負載或工作階段區域中選取 default 子網路,做為批次工作負載或工作階段的子網路。

如果工作負載需要外部網路或網際網路存取權 (例如從 PyTorch HubHugging Face 下載機器學習模型等資源),您可以設定 Cloud NAT,允許使用虛擬私有雲網路的內部 IP 位址傳送輸出流量。

開放子網路連線

為 Managed Service for Apache Spark 批次工作負載或互動式工作階段選取的區域,其虛擬私有雲子網路必須允許子網路內 VM 執行個體之間的所有通訊埠進行內部通訊。

為防止一個工作負載中的惡意指令碼影響其他工作負載,Managed Service for Apache Spark 會部署預設安全措施

下列 Google Cloud CLI 指令會將網路防火牆附加至子網路,允許 VM 之間使用所有通訊埠的所有通訊協定進行內部傳入通訊:

gcloud compute firewall-rules create allow-internal-ingress \
    --network=NETWORK_NAME \
    --source-ranges=SUBNET_RANGES \
    --destination-ranges=SUBNET_RANGES \
    --direction=ingress \
    --action=allow \
    --rules=all

注意:

  • SUBNET_RANGES: 請參閱「允許 VM 之間的內部輸入連線」。專案中的 default 虛擬私有雲網路具有 default-allow-internal 防火牆規則,允許所有通訊埠 (tcp:0-65535udp:0-65535icmp protocols:ports) 的輸入通訊,符合開放子網路連線需求。不過,這項規則也允許網路上的任何 VM 執行個體輸入流量。

自動建立的區域性系統防火牆政策

如要滿足開放子網路連線需求,使用執行階段版本 3.0 以上版本的 Managed Service for Apache Spark 批次工作負載和互動式工作階段,會自動在批次或工作階段 VPC 子網路上建立區域系統防火牆政策 dataproc-firewall-policy-[network-id]-regiondataproc-fw-[network-id]-region。這項政策包含下列輸入和輸出規則。

名稱 目的 優先順序 流向 動作 來源和目的地 通訊協定和通訊埠
dataproc-allow-internal-ingress-rule-[subnetworkId] 只允許來自相同子網路中,其他已加上標記的 Managed Service for Apache Spark VM 進行所有必要的內部通訊。 4 INGRESS 允許
  • srcSecureTag:這個子網路的安全標記值。
  • targetSecureTags:這個子網路的安全標記值。
  • tcp:0-65535、udp:0-65535、icmp 通訊協定:通訊埠
    dataproc-allow-internal-egress-rule-[subnetworkId] 允許 Managed Service for Apache Spark VM 下載套件 (例如 pip 和 apt-get),並使用 Private Google Access 存取 Google API。 5 EGRESS 允許
  • destIpRanges:0.0.0.0/0。
  • targetSecureTags:這個子網路的安全標記值。
  • tcp:0-65535、udp:0-65535、icmp 通訊協定:通訊埠

    注意:

    • Managed Service for Apache Spark 會佈建與使用者專案相關聯的租戶專案,用於儲存安全標記。Managed Service for Apache Spark 會在租戶專案中為子網路建立安全標記,並將其附加至 Managed Service for Apache Spark VM,確保建立的系統防火牆政策只適用於 Managed Service for Apache Spark VM。

    • 系統自動建立的防火牆政策不支援Shared VPC

    Managed Service for Apache Spark 和 VPC-SC 網路

    網路管理員可以使用 VPC Service Controls 定義 Google 代管服務資源的安全範圍,藉此控管對這些服務和這些服務之間的通訊。

    搭配使用 VPC-SC 網路與 Managed Service for Apache Spark 時,請考慮下列策略:

    詳情請參閱「VPC Service Controls - Managed Service for Apache Spark」。