使用 VPC Service Controls

如要保護 Network Connectivity Center (NCC) 設定,請使用 VPC Service Controls。

VPC Service Controls 可加強 Google API 和服務的安全性,包括 NCC 設定。除了 IAM 之外,VPC Service Controls 也會限制可變更 NCC 設定的來源系統。

本頁面說明常見用途和設定範例,允許 NCC 中樞和 VPC 輪輻在 service perimeter 之間存取。

如需完整說明文件,請參閱「VPC Service Controls 總覽」。

範例:跨 service perimeter 的跨專案虛擬私有雲輪輻提案

如果您的設定要求 NCC 中樞和虛擬私有雲 Spoke 位於不同專案,且這些專案屬於不同的 VPC Service Controls perimeter,則必須在兩個 perimeter 中設定輸入和輸出規則。這樣一來,輪輻管理員就能提議參照中樞的虛擬私有雲輪輻,中樞管理員則能接受提議的輪輻。

本頁面的範例假設中樞管理員和節點管理員屬於不同機構。

下表彙整這個範例所需的規則:

範圍 規則 目的
輪輻 perimeter
(輪輻專案)
輸入規則 1 允許輪輻管理員在輪輻專案中建立輪輻 (如果從 SpokePerimeter 外部管理),藉此發起輪輻提案
輸出規則 1 允許輪輻提案啟動與中樞專案中樞的連結,包括驗證支援的虛擬私有雲網路
中樞周邊
(中樞專案)
輸入規則 1 允許中樞管理員在中樞專案中管理中樞,包括接受或拒絕輪輻提案 (如果從 HubPerimeter 外部管理中樞)
輸入規則 2 允許傳入的輪輻提案啟動與中樞的連結
輸出規則 1 允許輪輻提案呼叫輪輻專案,完成輪輻與中樞的連結,包括驗證支援的虛擬私有雲網路

輪輻周邊規則

如要啟用 Spoke 的建立和管理功能,Spoke 管理員須設定下列輸入和輸出規則:

規則 詳細資料
輸入規則 1:建立 Spoke 當輪輻管理員從 perimeter 外部 (例如管理員工作站、Cloud Shell 或 Google Cloud 控制台) 發出建立指令,啟動輪輻提案時,VPC Service Controls 會將該呼叫評估為輪輻專案的輸入要求。SpokePerimeter 必須允許從 NCC API 的 spoke 管理員身分和網路來源傳入流量。

如果輪輻管理作業完全在受 SpokePerimeter 保護的虛擬私有雲網路中執行,就不需要這項規則。
輸出規則 1:中樞連結和網路驗證 當輪輻管理員提議輪輻時,要求會啟動與中樞網路專案中樞網路的連結。在要求過程中,NCC API 也會使用 Compute Engine API 驗證支援的虛擬私有雲網路。SpokePerimeter 必須允許從輪輻管理員輸出資料,以用於 NCC 和 Compute Engine API。

輪輻 perimeter 定義

下列各節中的輸入和輸出規則範例,是以下列 perimeter 定義為準。

如要進一步瞭解 service perimeter,請參閱「service perimeter 詳細資料和設定」。

# Spoke perimeter definition
name: accessPolicies/2345678901/servicePerimeters/SpokePerimeter
status:
  resources:
  - projects/222222222222
  restrictedServices:
  - networkconnectivity.googleapis.com
  - compute.googleapis.com
title: SpokePerimeter

Spoke 輸入規則

本節提供範例,說明如何為輪輻周邊實作輸入規則,如「輪輻周邊規則」一文所述。只有在從 SpokePerimeter 外部管理 Spoke 時,才需要這項規則。

如要瞭解規則語法詳情,請參閱「輸入規則參考資料」。如要套用規則,請參閱「設定輸入和輸出政策」。

echo """
# Rule 1: Allow the spoke administrator to initiate a spoke proposal by creating
# a spoke in the spoke project (if managing from outside SpokePerimeter)
- ingressFrom:
    identities:
    # Specify the principal identifier for the spoke administrator or deployment pipeline:
    - serviceAccount:spoke-admin-sa@spoke-project.iam.gserviceaccount.com
    # - group:spoke-admins@example.org
    # - user:spoke-admin@example.org
    sources:
    - accessLevel: accessPolicies/2345678901/accessLevels/SpokeAdminAccessLevel
    # Alternatively, specify a management project or VPC network if managing
    # from a VPC network outside the perimeter:
    # - resource: projects/MANAGEMENT_PROJECT_NUMBER
  ingressTo:
    operations:
    - serviceName: networkconnectivity.googleapis.com
      methodSelectors:
      - method: "*"
    resources:
    - projects/222222222222
""" > spoke-ingress.yaml

建議您盡可能定義明確的輸入規則:

  • identities:請只指定環境所需的主體 ID,而非廣泛的身分類型。在本範例中,規則 1 指定自動部署管道的服務帳戶。或者,您也可以指定 Google 群組做為團隊管理員,或指定個別使用者帳戶。詳情請參閱「輸入和輸出規則支援的身分」。

  • sources:將來源限制為已知的存取層級。這個範例會指定存取政策中的存取層級,以授權外部來源 (例如管理員工作站、Cloud Shell 或 Google Cloud 控制台) 管理 SpokePerimeter。或者,您也可以使用 - resource: 屬性指定專案或虛擬私有雲網路,允許來自 perimeter 外部管理虛擬私有雲網路的存取要求。詳情請參閱「允許從 perimeter 外部存取」和「含有輸入規則的情境感知存取權」一文。

  • operations:系統會在服務層級強制執行 networkconnectivity.googleapis.com 的限制,因此需要 method: "*"。這項服務不支援更精細的方法。

  • resources:在 resources 中指定確切的輻射專案編號。避免使用萬用字元 (*)。

Spoke 輸出規則

本節提供範例,說明如何為輪輻周邊實作輸出規則,如「輪輻周邊規則」一文所述。

如要瞭解規則語法詳情,請參閱「輸出規則參考資料」。

echo """
# Rule 1: Allow the outbound spoke proposal to initiate attachment to the hub in
# the hub project, which includes verifying the backing VPC network
- egressTo:
    operations:
    - serviceName: networkconnectivity.googleapis.com
      methodSelectors:
      - method: "*"
    - serviceName: compute.googleapis.com
      methodSelectors:
      - method: NetworksService.Get
    resources:
    - projects/111111111111
  egressFrom:
    identities:
    # Specify the principal identifier for the spoke administrator or deployment pipeline:
    - serviceAccount:spoke-admin-sa@spoke-project.iam.gserviceaccount.com
    # - group:spoke-admins@example.org
    # - user:spoke-admin@example.org
""" > spoke-egress.yaml

建議盡可能定義明確的輸出規則:

  • identities:請只指定環境所需的主體 ID,而非廣泛的身分類型。在本範例中,規則 1 指定自動部署管道的服務帳戶。或者,您也可以指定 Google 群組做為團隊管理員,或指定個別使用者帳戶。詳情請參閱「輸入和輸出規則支援的身分」。

  • operations:系統會在服務層級強制執行 networkconnectivity.googleapis.com 的限制,因此需要 method: "*"。如為 compute.googleapis.com,請指定 method: NetworksService.Get,在啟動與中樞的連結時,授予驗證支援 VPC 網路的權限。

  • resources:在 resources 中指定確切的中心專案編號。避免使用萬用字元 (*)。

中樞周邊規則

如要啟用中樞管理功能並允許傳入的 Spoke 提案,中樞管理員須設定下列輸入和輸出規則:

規則 詳細資料
輸入規則 1:中樞管理 如果中心管理員從 perimeter 外部管理中心 (例如從管理員工作站、Cloud Shell 或 Google Cloud 控制台),VPC Service Controls 會將呼叫評估為對中心專案的輸入要求。這項規則可讓中樞管理員審查並接受建議的輪輻 (將輪輻轉換為 ACTIVE),或拒絕建議 (將輪輻轉換為 REJECTED)。HubPerimeter 必須允許來自中樞管理員身分和網路來源的連入流量。

如果中樞管理作業完全在受 HubPerimeter 保護的虛擬私有雲網路中執行,則不需要這項規則。
輸入規則 2:中樞附件 當輪輻管理員提議輪輻時,系統會啟動在中心專案中附加至中心的程序。HubPerimeter 必須允許從輪輻管理員的身分和網路來源,跨服務安全防護範圍輸入 NCC API。
輸出規則 1:連結 Spoke 並驗證網路 當輪輻管理員提議輪輻時,要求會回呼至輪輻專案,完成將輪輻連結至中樞,並將輪輻設為 PENDING_REVIEW 狀態。在要求中,NCC API 也會使用 Compute Engine API 驗證支援的 VPC 網路。HubPerimeter 必須允許從輪輻管理員輸出 NCC 和 Compute Engine API。

中樞範圍定義

下列各節中的輸入和輸出規則範例,是以下列 perimeter 定義為準。

如要進一步瞭解 service perimeter,請參閱「service perimeter 詳細資料和設定」。

# Hub perimeter definition
name: accessPolicies/1234567890/servicePerimeters/HubPerimeter
status:
  resources:
  - projects/111111111111
  restrictedServices:
  - networkconnectivity.googleapis.com
  - compute.googleapis.com
title: HubPerimeter

Hub 輸入規則

本節提供範例,實作中心周邊的輸入規則,如「中心周邊規則」一文所述。

如要瞭解規則語法詳情,請參閱「輸入規則參考資料」。如要套用規則,請參閱「設定輸入和輸出政策」。

echo """
# Rule 1: Allow the hub administrator to manage the hub in the hub project
# (if managing from outside HubPerimeter)
- ingressFrom:
    identities:
    # Specify the principal identifier for the hub administrator:
    - group:hub-admins@example.com
    # - user:hub-admin@example.com
    # - serviceAccount:hub-admin-sa@hub-project.iam.gserviceaccount.com
    sources:
    - accessLevel: accessPolicies/1234567890/accessLevels/HubAdminAccessLevel
    # Alternatively, specify a management project or VPC network if managing
    # from a VPC network outside the perimeter:
    # - resource: projects/MANAGEMENT_PROJECT_NUMBER
  ingressTo:
    operations:
    - serviceName: networkconnectivity.googleapis.com
      methodSelectors:
      - method: "*"
    resources:
    - projects/111111111111

# Rule 2: Allow the inbound spoke proposal to initiate attachment to the hub
- ingressFrom:
    identities:
    # Specify the principal identifier for the spoke administrator or deployment pipeline:
    - serviceAccount:spoke-admin-sa@spoke-project.iam.gserviceaccount.com
    # - group:spoke-admins@example.org
    # - user:spoke-admin@example.org
    sources:
    # Specify an access level defined in the hub organization's access policy if
    # the spoke administrator manages spokes from the Google Cloud console or
    # external networks:
    - accessLevel: accessPolicies/1234567890/accessLevels/SpokeAdminAccessLevel
    # Alternatively, specify the spoke project if the spoke administrator
    # manages from a VPC network in the spoke project:
    # - resource: projects/222222222222
  ingressTo:
    operations:
    - serviceName: networkconnectivity.googleapis.com
      methodSelectors:
      - method: "*"
    resources:
    - projects/111111111111
""" > hub-ingress.yaml

建議您盡可能定義明確的輸入規則:

  • identities:請只指定環境所需的主體 ID,而非廣泛的身分類型:

    • 在規則 1 中,這個範例指定了中樞管理員 Google 群組,用於團隊管理。或者,您也可以指定個別使用者帳戶或服務帳戶。只有從 HubPerimeter 外部管理中樞時,才需要這項規則。
    • 在規則 2 中,這個範例會為自動部署管道指定 spoke 管理員服務帳戶。或者,您也可以指定 Google 群組做為團隊管理員,或指定個別使用者帳戶。

    詳情請參閱「輸入和輸出規則支援的身分」。

  • sources:將來源限制為已知的存取層級或專案:

    • 在規則 1 中,這個範例指定了存取政策管理 HubPerimeter 的中樞管理員存取層級,授權外部來源 (例如管理員工作站、Cloud Shell 或Google Cloud 控制台)。或者,您也可以使用 - resource: 屬性指定專案或虛擬私有雲網路,允許來自 perimeter 外部管理虛擬私有雲網路的存取要求。詳情請參閱「允許從 perimeter 外部存取」和「含有輸入規則的情境感知存取權」一文。
    • 在規則 2 中,這個範例會為管理 HubPerimeter 的存取政策指定輪輻管理員的存取層級,授權外部來源 (例如管理員工作站、Cloud Shell 或 Google Cloud 控制台)。或者,您也可以使用 - resource: 屬性指定子專案編號 (例如用於自動部署管道),允許來自子專案虛擬私有雲網路的存取要求。
  • operations:系統會在服務層級強制執行 networkconnectivity.googleapis.com 的限制,因此需要 method: "*"。這項服務不支援更精細的方法。

  • resources:在 resources 中指定確切的中心專案編號。避免使用萬用字元 (*)。

Hub 輸出規則

本節提供範例,實作中樞周邊的輸出規則,如「中樞周邊規則」一文所述。

如要瞭解規則語法詳情,請參閱「輸出規則參考資料」。

echo """
# Rule 1: Allow the inbound spoke proposal to call back to the spoke project to
# complete linking the spoke to the hub, which includes verifying the backing
# VPC network
- egressTo:
    operations:
    - serviceName: networkconnectivity.googleapis.com
      methodSelectors:
      - method: "*"
    - serviceName: compute.googleapis.com
      methodSelectors:
      - method: NetworksService.Get
    resources:
    - projects/222222222222
  egressFrom:
    identities:
    # Specify the principal identifier for the spoke administrator or deployment pipeline:
    - serviceAccount:spoke-admin-sa@spoke-project.iam.gserviceaccount.com
    # - group:spoke-admins@example.org
    # - user:spoke-admin@example.org
""" > hub-egress.yaml

建議盡可能定義明確的輸出規則:

  • identities:指定輪輻系統管理員的主體 ID (例如部署管道服務帳戶、群組或使用者帳戶)。輪輻管理員提議輪輻時,HubPerimeter 會以輪輻管理員的身分評估輸出流量,完成輪輻專案中輪輻與中樞的連結,包括驗證支援的虛擬私有雲網路。

    詳情請參閱「輸入和輸出規則支援的身分」。

  • operations:系統會在服務層級強制執行 networkconnectivity.googleapis.com 的限制,因此需要 method: "*"。如要指定 compute.googleapis.com,請指定 method: NetworksService.Get,以便在完成輪輻專案的連結時,授予驗證支援虛擬私有雲網路的權限。

  • resources:在 resources 中指定確切的輻射專案編號。避免使用萬用字元 (*)。