This document describes the steps to create a Google Distributed Cloud (GDC) air-gapped billing account to track resource usage.
Distributed Cloud environments require a billing account to track usage costs for projects and organizations. All billing accounts within an organization use a single price sheet to charge service usage to the customer. If you don't link a billing account to an organization or project, you'll lose cost data associated with the resource, resulting in cost discrepancies.
This document is for developers in platform administrator or application operator groups that create and administer billing accounts in GDC. For more information, see Audiences for GDC air-gapped documentation.
Before you begin
Request IAM roles
Contact your Organization Identity and Access Management (IAM) Admin to request the following roles:
Global Organization Billing Account Admin (
organization-billing-account-admin): create, manage, and bind theBillingAccountresource in theplatformnamespace.Global Organization Billing Account User (
organization-billing-account-user): read, list, and bind theBillingAccountresource in theplatformnamespace.Global Organization Billing Account Manager (
organization-billing-manager): read, list, create, and update theBillingAccountBindingresource across namespaces (such as theplatformnamespace for organization-level billing or a project namespace for project-level billing).
Get the kubeconfig file
To run verification commands against the global API server, ensure you have the following resources:
Sign in and generate the kubeconfig file for the global API server if you don't have one.
Use the path to the kubeconfig file of the global API server to replace
GLOBAL_API_SERVER_KUBECONFIGin these instructions.
Create a new billing account
CLI
To create a billing account, use the gdcloud billing accounts create command.
For more information, see gdcloud billing accounts create.
IaC
To create a billing account on the global API server using Infrastructure as Code (IaC), do the following:
Create a
billingaccount-BIL_ACCOUNT_NAME.yamlfile in theinfrastructure/global/orgs/ORG_NAME/oc/bil/directory of your localiacrepository (IAC_REPO_PATH/infrastructure/global/orgs/ORG_NAME/oc/bil/billingaccount-BIL_ACCOUNT_NAME.yaml), and add theBillingAccountcustom resource with the following contents:apiVersion: billing.global.gdc.goog/v1 kind: BillingAccount metadata: namespace: platform name: BIL_ACCOUNT_NAME spec: displayName: BIL_DISPLAY_NAME paymentSystemConfig: cloudBillingConfig: accountID: CLOUD_BILLING_ACCOUNT_IDReplace the following variables:
IAC_REPO_PATH: the path to the root of your localiacrepository.ORG_NAME: the name of the organization.BIL_ACCOUNT_NAME: the name of the billing account, for example,test-billing-account.BIL_DISPLAY_NAME: the billing account display name, for example,"Test Billing Account".CLOUD_BILLING_ACCOUNT_ID: your Google Cloud billing account ID, for example,"012345-6789AB-CDEF01".
Verify your payment configuration type. Distributed Cloud billing accounts must have one of the following payment configurations:
cloudBillingConfig: the default payment configuration. This configuration stores a Cloud Billing account ID.customConfig: a custom configuration for partners to store their payment configuration to bill the organization.customConfigsupports a dictionary of key-value strings, with a mandatory keypayment-config-type.
The following examples show
BillingAccountYAML file snippets for different payment configurations:cloudBillingConfigexample:spec: paymentSystemConfig: cloudBillingConfig: accountID: CLOUD_BILLING_ACCOUNT_IDReplace
CLOUD_BILLING_ACCOUNT_IDwith your Google Cloud billing account ID.customConfigexample:spec: paymentSystemConfig: customConfig: "payment-config-type": PAYMENT_CONFIG_TYPEReplace
PAYMENT_CONFIG_TYPEwith your chosen payment configuration type for your custom billing configuration.If you don't have the information for your organization's
customConfigconfiguration, enter the following details:spec: paymentSystemConfig: customConfig: "payment-config-type": "N/A"The following example YAML file shows a complete
BillingAccountresource with thecloudBillingConfigconfiguration:apiVersion: billing.global.gdc.goog/v1 kind: BillingAccount metadata: namespace: platform name: test-billing-account spec: displayName: "Test Billing Account" paymentSystemConfig: cloudBillingConfig: accountID: "012345-6789AB-CDEF01"Wire the resource in the
kustomization.yamlhierarchy of your localiacrepository (which targets the global API server) and submit a merge request:Ensure all three
kustomization.yamllevels underinfrastructure/global/orgs/ORG_NAME/reference the billing resource and its parent directories:In
infrastructure/global/orgs/ORG_NAME/oc/bil/kustomization.yaml, includebillingaccount-BIL_ACCOUNT_NAME.yamlin theresourceslist (keeping any existing billing account or binding files):apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: # Keep existing resources in this list - billingaccount-BIL_ACCOUNT_NAME.yamlIn
infrastructure/global/orgs/ORG_NAME/oc/kustomization.yaml, ensurebilis listed inresources:apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: # Keep existing resources in this list - bilIn
infrastructure/global/orgs/ORG_NAME/kustomization.yaml, ensureocis listed inresources:apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: # Keep existing resources in this list - oc
Commit and push the changes to a new branch in GitLab to create a merge request and trigger the multi-party approval (MPA) workflow by following the
IAC-R0004: Create and merge a merge requestrunbook:cd IAC_REPO_PATH git checkout -b USER_BRANCH git add infrastructure/global/orgs/ORG_NAME/oc/bil/billingaccount-BIL_ACCOUNT_NAME.yaml \ infrastructure/global/orgs/ORG_NAME/oc/bil/kustomization.yaml \ infrastructure/global/orgs/ORG_NAME/oc/kustomization.yaml \ infrastructure/global/orgs/ORG_NAME/kustomization.yaml git commit -m "Create billing account" git -c http.sslVerify=false push -o merge_request.create origin USER_BRANCHReplace
USER_BRANCHwith your chosen Git branch name.
Link an organization or project to a billing account
You must link a billing account to the organization before creating any projects. This ensures that all projects created within the organization inherit a valid billing account by default.
You can also explicitly link a project to a specific billing account if you want it to differ from the organization's billing account.
To link an organization or project to a BillingAccount on the global API server using Infrastructure as Code (IaC), do the following:
Create a
BillingAccountBindingYAML file for your target scope:Link an organization
Add the following content to
billingaccountbinding-platform.yaml:apiVersion: billing.global.gdc.goog/v1 kind: BillingAccountBinding metadata: name: billing namespace: platform spec: billingAccountRef: name: BIL_ACCOUNT_NAME namespace: platformReplace
BIL_ACCOUNT_NAMEwith the name of the billing account.Link a project
Add the following content to
billingaccountbinding-PROJECT_NAME.yaml:apiVersion: billing.global.gdc.goog/v1 kind: BillingAccountBinding metadata: name: billing namespace: PROJECT_NAME spec: billingAccountRef: name: BIL_ACCOUNT_NAME namespace: platformReplace the following variables:
PROJECT_NAME: the name of the project bound to the billing account.BIL_ACCOUNT_NAME: the name of the billing account.
Add the
BillingAccountBindingresource to youriacrepository:- Place the
BillingAccountBindingYAML file (billingaccountbinding-platform.yamlorbillingaccountbinding-PROJECT_NAME.yaml) in theinfrastructure/global/orgs/ORG_NAME/oc/bil/directory within your localiacrepository. - Add the
BillingAccountBindingYAML filename to theresourceslist ininfrastructure/global/orgs/ORG_NAME/oc/bil/kustomization.yaml. Also ensure thatinfrastructure/global/orgs/ORG_NAME/oc/kustomization.yamlincludesbilandinfrastructure/global/orgs/ORG_NAME/kustomization.yamlincludesocin theirresourceslists if not already present, as shown in Create a new billing account. - Commit and push the changes to GitLab to create a merge request and trigger the approval workflow by following the
IAC-R0004: Create and merge a merge requestrunbook, as shown in Create a new billing account.
- Place the
(Optional) After the merge request is approved and synced, verify the status of the
BillingAccountBindingresource on the global API server:kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG describe billingaccountbinding billing -n NAMESPACEReplace
NAMESPACEwithplatformfor the organization, orPROJECT_NAMEfor a project.
List billing account bindings
View a list of all deployed BillingAccountBinding resources and their current
status across all namespaces in the organization on the global API server:
kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG get billingaccountbinding -A -o 'custom-columns=NAME:metadata.name,NAMESPACE:metadata.namespace,BillingAccountName:spec.billingAccountRef.name,STATUS:status.conditions[0].status'
This command outputs the NAME, NAMESPACE, BillingAccountName, and STATUS
of each BillingAccountBinding. The STATUS field indicates whether the binding
is active or if there are any errors.
Billing account hierarchy and behavior
When linking billing accounts to organizations and projects, the following hierarchy and behaviors apply:
Project-level association takes precedence: If a specific project, such as
project-A, is explicitly linked to aBillingAccount, for example,billing-account-1, then all costs forproject-Abill exclusively tobilling-account-1. This project-level association remains valid regardless of any organization-level billing account settings.Organization-level association for unlinked projects: If your organization links to a
BillingAccount, for example,billing-account-0, all projects within that organization that don't have their own explicitBillingAccountBindingautomatically associate with and charge tobilling-account-0. This association typically takes effect approximately 15 minutes after a project is created.Changing organization billing accounts: If the billing account linked to an organization changes, for example,
billing-account-0changes tobilling-account-new,billing-account-0projects don't automatically switch tobilling-account-new. These projects remain bound tobilling-account-0, and you must manually update the billing account to have the projects usebilling-account-new.
Change the linked billing account
In Distributed Cloud, you can't delete a billing account. If you need to
change to your billing configuration, you must change the billing account that is
linked to the organization or project by modifying the BillingAccountBinding.
Some scenarios for this use case include the following examples:
- Accounting rules within your company require you split charges associated with developer and production-level workloads into separate accounts.
You create a billing account to charge a customer contract for a one year period. When the contract expires, you must charge for the remaining period that exceeds a year.
For a project
To change the billing account for a project using Infrastructure as Code (IaC), do the following:
Create a new
BillingAccountto link to the project. This account replaces the old account.(Optional) Check the
BillingAccountBindingresource in the project namespace on the global API server to see if an explicit project-level billing account binding exists:kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG describe billingaccountbinding billing -n PROJECT_NAMEReplace
PROJECT_NAMEwith the name of the project. If the project is using the default billing account inherited from the organization (which is automatically created on the zonal management cluster rather than the global API server), this command returns aNotFounderror on the global API server.Update or create the
BillingAccountBindingdefinition in your localiacrepository:- In
infrastructure/global/orgs/ORG_NAME/oc/bil/, locatebillingaccountbinding-PROJECT_NAME.yaml. If the project was previously using the default inherited organization binding (which is automatically created on the zonal management cluster rather than the global API server, and is not yet in theiacrepository), createbillingaccountbinding-PROJECT_NAME.yamlas shown in Link an organization or project to a billing account and add theBillingAccountBindingYAML filename to theresourceslist ininfrastructure/global/orgs/ORG_NAME/oc/bil/kustomization.yaml(along with the parentoc/kustomization.yamlandorgs/ORG_NAME/kustomization.yamlentries if not already present). - Modify the
spec.billingAccountRef.namefield to use the newBillingAccountname created in step 1. - Commit and push the changes to GitLab to create a merge request and trigger the approval workflow by following the
IAC-R0004: Create and merge a merge requestrunbook, as described in Create a new billing account.
- In
(Optional) After the changes are approved and synced, verify that the
BillingAccountBindingresource is updated on the global API server:kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG describe billingaccountbinding billing -n PROJECT_NAME
The following example shows a BillingAccountBinding YAML file with the account
expired-billing-account linked to the project project-one:
apiVersion: billing.global.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
The following example shows the BillingAccountBinding YAML file from the earlier
example modified to link a new account called new-billing-account:
apiVersion: billing.global.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
For an organization
To change the billing account for an organization using Infrastructure as Code (IaC), do the following:
Create a new
BillingAccountto link to the organization. This account replaces the old account.(Optional) Check the
BillingAccountBindingresource in theplatformnamespace on the global API server to see which billing account is linked:kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG describe billingaccountbinding billing -n platformUpdate the
BillingAccountBindingdefinition in your localiacrepository:- Locate the
billingaccountbinding-platform.yamlfile for the organization ininfrastructure/global/orgs/ORG_NAME/oc/bil/. - Modify the
spec.billingAccountRef.namefield to use the newBillingAccountname created in step 1. - Commit and push the changes to GitLab to create a merge request and trigger the approval workflow by following the
IAC-R0004: Create and merge a merge requestrunbook, as described in Create a new billing account.
- Locate the
(Optional) After the changes are approved and synced, verify that the
BillingAccountBindingresource is updated on the global API server:kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG describe billingaccountbinding billing -n platform