建立及連結帳單帳戶

Google Distributed Cloud (GDC) 氣隙環境需要帳單帳戶,才能追蹤專案和機構的費用。如果未將帳單帳戶連結至機構或專案,您將無法存取與資源相關聯的費用資料。

如要向客戶收取服務使用費,機構內的所有帳單帳戶都必須使用同一份價目表。

事前準備

請要求機構 IAM 管理員授予下列必要角色。這些角色會繫結至專案命名空間 (適用於專案層級帳單),或是平台命名空間 (適用於機構層級帳單):

  • 機構帳單帳戶管理員:建立、管理及繫結 BillingAccount 資源。請要求機構 IAM 管理員授予您 organization-billing-account-admin 角色。

  • 機構帳單帳戶使用者:讀取、列出及繫結 BillingAccount 資源。請要求機構 IAM 管理員授予您 organization-billing-account-user 角色。

  • 機構帳單帳戶管理員:讀取、列出、建立及更新 BillingAccountBinding 資源。請要求機構 IAM 管理員授予您 organization-billing-manager 角色。

取得 kubeconfig 檔案

如要對 Management API 伺服器執行指令,請確認您具備下列資源:

  1. 登入並產生 Management API 伺服器的 kubeconfig 檔案 (如果沒有)。

  2. 使用 Management API 伺服器的 kubeconfig 檔案路徑,取代這些操作說明中的 MANAGEMENT_API_SERVER_KUBECONFIG

建立新的帳單帳戶

帳單帳戶的專屬 ID 為 namenamespace。如要建立帳單帳戶,請使用自訂資源建立 namenamespace

  1. 建立 YAML 檔案,並新增 BillingAccount 自訂資源和下列內容:

    apiVersion: billing.gdc.goog/v1
    kind: BillingAccount
    metadata:
      namespace: platform
      name: BIL_ACCOUNT_NAME
    spec:
      displayName: BIL_DISPLAY_NAME
      paymentSystemConfig:
        cloudBillingConfig:
          accountID: "012345-6789AB-CDEF01"
    

    請替換下列變數:

    • BIL_ACCOUNT_NAME:帳單帳戶的名稱。 例如:test-billing-account
    • BIL_DISPLAY_NAME:帳單帳戶顯示名稱。 例如:"Test Billing Account"
  2. 確認付款設定類型。Distributed Cloud 帳單帳戶必須採用下列其中一種付款設定:

    • cloudBillingConfig:預設付款設定。這項設定會儲存 Cloud Billing 帳戶 ID。

    • customConfig:合作夥伴的自訂設定,用於儲存付款設定,以便向機構收費。customConfig 支援鍵/值字串的字典,且必須包含 payment-config-type 鍵。

    下列範例顯示不同付款設定的 BillingAccount YAML 檔案程式碼片段:

    cloudBillingConfig

    spec:
      paymentSystemConfig:
        cloudBillingConfig:
          accountID: CLOUD_BILLING_ACCOUNT_ID
    

    CLOUD_BILLING_ACCOUNT_ID 替換為您的Google Cloud 帳單帳戶 ID。

    customConfig

    spec:
     paymentSystemConfig:
       customConfig:
          "payment-config-type": PAYMENT_CONFIG_TYPE
    

    請將 PAYMENT_CONFIG_TYPE 替換為您為自訂帳單設定選擇的付款設定類型。

    如果沒有貴機構的customConfig設定資訊,請輸入下列詳細資料:

    spec:
     paymentSystemConfig:
       customConfig:
          "payment-config-type": "N/A"
    

    下列 YAML 檔案顯示完整的 BillingAccount 資源,其中包含 cloudBillingConfig 設定:

    apiVersion: billing.gdc.goog/v1
    kind: BillingAccount
    metadata:
      namespace: platform
      name: test-billing-account
    spec:
      displayName: "Test Billing Account"
      paymentSystemConfig:
        cloudBillingConfig:
          accountID: "012345-6789AB-CDEF01"
    
  3. 儲存 YAML 檔案。執行 kubectl CLI,在 Management API 伺服器中套用資源,以指定要計費的機構或專案:

    kubectl --kubeconfig MANAGEMENT_API_SERVER_KUBECONFIG apply -f billingaccount.yaml
    

    MANAGEMENT_API_SERVER_KUBECONFIG 替換為 Management API 伺服器 kubeconfig 檔案。

本節提供一系列步驟,說明如何將機構或專案連結至 BillingAccount

如要將專案連結至 BillingAccount,請按照下列步驟操作:

  1. 將下列內容新增至 billingaccountbinding.yaml 檔案:

    • billingAccountRef 區段中,將 name 欄位填入要連結的 BillingAccountname 欄位的內容。
    • metadata 區段中,使用 BillingAccount 資源中相同欄位的內容填入 namespace 欄位。

    在本範例中,專案命名空間為 PROJECT_NAME

    apiVersion: billing.gdc.goog/v1
    kind: BillingAccountBinding
    metadata:
      name: billing
      namespace: PROJECT_NAME
    spec:
      billingAccountRef:
        name: BIL_ACCOUNT_NAME
        namespace: platform
    

    PROJECT_NAME 替換為繫結至帳單帳戶的專案名稱。

  2. 執行下列 kubectl 指令,套用 billingaccountbinding.yaml 檔案:

    kubectl --kubeconfig MANAGEMENT_API_SERVER_KUBECONFIG apply -f billingaccountbinding.yaml
    

如要將機構連結至 BillingAccount,請按照下列步驟操作:

  1. 將下列內容新增至 YAML 檔案 billingaccountbinding.yaml

    • billingAccountRef 區段中,使用要連結的 BillingAccountname 欄位的內容,填入 name 欄位。
    • metadata 部分,使用 BillingAccount 資源中相同欄位的內容填入 namespace 欄位。在本例中,機構命名空間為 platform
    apiVersion: billing.gdc.goog/v1
    kind: BillingAccountBinding
    metadata:
      name: billing
      namespace: platform
    spec:
      billingAccountRef:
        name: BIL_ACCOUNT_NAME
        namespace: platform
    
  2. 執行下列 kubectl 指令,套用 billingaccountbinding.yaml 檔案:

    kubectl --kubeconfig MANAGEMENT_API_SERVER_KUBECONFIG apply -f billingaccountbinding.yaml
    

在 Distributed Cloud 中,您無法刪除帳單帳戶。如要變更帳單設定,請修改 BillingAccountBinding,將機構或專案與現有帳單帳戶取消連結。這個應用實例的部分情境包括以下範例:

  • 貴公司的會計規則要求您將與開發人員和生產層級工作負載相關的費用,分別計入不同帳戶。
  • 您建立帳單帳戶,以便在一年期間收取客戶合約費用。合約到期後,您必須支付超過一年的剩餘期間費用。

如要取消帳單帳戶與機構或專案的連結,請按照下列步驟操作:

  1. 建立要連結至專案的新 BillingAccount。這個帳戶會取代舊帳戶。

  2. 在專案或 platform 命名空間中找出 BillingAccountBinding 資源 YAML 檔案,然後修改下列欄位:

    • billingAccountRef 區段中,填入新的 name BillingAccount 名稱。

以下範例顯示的 BillingAccountBinding YAML 檔案中,帳戶 expired-billing-account 已連結至專案 project-one

  apiVersion: billing.gdc.goog/v1
  kind: BillingAccountBinding
  metadata:
    # The name of a BillingAccountBinding will typically always be `billing`.
    name: billing
    # This is the project.
    namespace: project-one
  spec:
    billingAccountRef:
      # This is an example of a BillingAccount that has expired.
      name: expired-billing-account
      namespace: platform

以下範例顯示先前範例中的 BillingAccountBinding YAML 檔案經過修改,可連結名為 new billing account 的新帳戶:

  apiVersion: billing.gdc.goog/v1
  kind: BillingAccountBinding
  metadata:
    name: billing
    # This is the project.
    namespace: project-one
  spec:
    billingAccountRef:
      # This is the example of the new BillingAccount.
      name: new-billing-account
      namespace: platform