設定 Network Connectivity Center 並建立中樞

本頁說明如何使用混合檢查拓撲建立 Network Connectivity Center 中樞,以便將 NCC 閘道輪輻和 VPC 輪輻新增至中樞。

如需 NCC 閘道的簡介,請參閱 NCC 閘道總覽

事前準備

開始設定前,請先詳閱下列各節。

建立或選取專案

為方便設定 Network Connectivity Center,請先找出有效的專案。

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Install the Google Cloud CLI.

  5. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  6. To initialize the gcloud CLI, run the following command:

    gcloud init
  7. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  8. Make sure that billing is enabled for your Google Cloud project.

  9. Install the Google Cloud CLI.

  10. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  11. To initialize the gcloud CLI, run the following command:

    gcloud init
  12. 如果您使用 Google Cloud CLI,請使用 gcloud config set 指令設定專案 ID。

    gcloud config set project PROJECT_ID

    PROJECT_ID 替換為專屬專案 ID。

    這個頁面的 gcloud CLI 指令假設您已設定專案 ID。

  13. 如要確認專案 ID 設定正確無誤,請使用 gcloud config list 指令

    gcloud config list --format='text(core.project)'
  14. 啟用 Network Connectivity API

    您必須先啟用 Network Connectivity API,才能使用 NCC Gateway 執行任何工作。

    控制台

    如要啟用 Network Connectivity API,請按照下列步驟操作:

    1. 前往 Google Cloud 控制台的「Network Connectivity Center」頁面。

      前往 Network Connectivity Center

    2. 按一下「啟用」

    或者,您也可以使用Google Cloud 控制台 API 程式庫啟用 API,如「啟用 API」一文所述。

    取得存取權

    如要使用 Network Connectivity Center 和 NCC 閘道,您需要角色和權限一文所述的權限。

    找出資源

    使用 gcloud CLI 或 API 參照資源時,請採用下表所述的慣例。

    集會/座談 僅支援 附註 範例
    完整 URI 所有資源 請使用下列任一方法參照路由器設備執行個體。
    "https://www.googleapis.com/compute/projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME"
    
          
    相對資源名稱 所有資源
    "projects/PROJECT_ID/zones/ZONE/instances/INSTANCE_NAME"
    
        
    名稱 區域和全域資源 這個方法適用於中樞、輪輻、VPN 通道和 VLAN 連結。
     "HUB_NAME"
    
        

    建立 Network Connectivity Center 中樞

    如要使用預設的混合式檢查拓撲建立 Network Connectivity Center 中樞,請按照下列步驟操作:

    gcloud

    使用 gcloud network-connectivity hubs create 指令,並指定預設混合式檢查拓撲。

    gcloud beta network-connectivity hubs create HUB_NAME \
        --preset-topology=hybrid-inspection
    

    HUB_NAME 替換為新中樞的名稱。

    API

    請使用 projects.locations.global.hubs.create 方法

    POST https://networkconnectivity.googleapis.com/v1beta/projects/PROJECT_ID/locations/global/hubs
    {
      "name":"HUB_NAME",
      "description":"DESCRIPTION",
      "labels": {
        "KEY": "VALUE"
      },
      "presetTopology": "HYBRID_INSPECTION"
    }
    

    更改下列內容:

    • PROJECT_ID:含有新中樞的專案 ID
    • HUB_NAME:新中樞的名稱
    • DESCRIPTION:描述中心的選填文字
    • KEY:選用標籤文字的鍵/值配對中的鍵
    • VALUE:選用標籤文字的鍵/值組合中的值

    將虛擬私有雲網路連線至中樞

    將虛擬私有雲網路連線至中樞的程序,會因網路和中樞是否位於同一專案而有所不同。

    連結不同專案中的虛擬私有雲網路和中樞

    如要連線不同專案的 VPC 網路,請按照下列步驟操作:

    在同一個專案中連結虛擬私有雲網路和中樞

    如果虛擬私有雲網路和中繼站位於同一個專案中,請按照本節中的步驟操作。

    gcloud

    使用 gcloud network-connectivity spokes linked-vpc-network create 指令

    gcloud network-connectivity spokes linked-vpc-network create SPOKE_NAME \
        --hub=HUB_NAME \
        --description=DESCRIPTION \
        --vpc-network=VPC_NETWORK_URI \
        --global \
        --group=GROUP_NAME
    

    更改下列內容:

    • SPOKE_NAME:您要建立的 Spoke 名稱,例如 vpc-spoke1
    • HUB_NAME:輪輻的中樞
    • DESCRIPTION:(選用) 輪輻的說明
    • VPC_NETWORK_URI:這個 Spoke 指向的虛擬私有雲網路
    • GROUP_NAME:這個 Spoke 所屬的群組

    由於中樞採用混合檢查拓撲,虛擬私有雲 Spoke 的有效群組名稱為 prodnon-prodservices

    如要瞭解新增虛擬私有雲輪輻時可用的其他選項,包括匯出篩選器的詳細資料,請參閱「建立虛擬私有雲輪輻」。

    API

    使用 projects.locations.spokes.create 方法

    POST https://networkconnectivity.googleapis.com/v1/projects/PROJECT_ID/locations/global/spokes/SPOKE_NAME
    
    {
     "hub":"HUB_NAME",
     "description": "DESCRIPTION",
     "linkedVpcNetwork": {
        "uri": "VPC_NETWORK_URI",
        "include_export_ranges": "[INCLUDE_RANGES]",
        "exclude_export_ranges": "[EXCLUDE_IPV4_RANGES]",
        "group": "GROUP_NAME"
     },
    }
    

    更改下列內容:

    • SPOKE_NAME:您要建立的 Spoke 名稱,例如 vpc-spoke1
    • HUB_NAME:輪輻的中樞
    • DESCRIPTION:(選用) 輪輻的說明
    • VPC_NETWORK_URI:這個 Spoke 指向的虛擬私有雲網路
    • GROUP_NAME:這個 Spoke 所屬的群組

    由於中樞採用混合檢查拓撲,虛擬私有雲 Spoke 的有效群組名稱為 prodnon-prodservices

    如要瞭解新增虛擬私有雲輪輻時可用的其他選項,包括匯出篩選器的詳細資料,請參閱「建立虛擬私有雲輪輻」。