Prerequisites
- Review the . Make sure you understand and acknowledge the responsibilities you hold for management of your cloud infrastucture and the necessary permissions you must grant to Cockroach Labs.
- if you do not already have one.
- More than one BYOC cluster can run in a single GCP project. However, if the project contains a BYOC cluster created before multiple-cluster support was enabled, that cluster must be deleted or its data migrated before additional clusters can be created in the same project.
- The BYOC deployment option is not available by default and must be requested. Reach out to your account team to express interest in BYOC.
- Once your cloud account is prepared for a CockroachDB BYOC deployment, cluster configuration and management is identical to a CockroachDB Cloud Advanced cluster. Review the documentation to plan your cluster sizing and resource allocation.
- Review cloud service regions supported by .
- The GCP project must not contain resources that can affect the control plane’s ability to operate on CockroachDB clusters.
- Create an to use the with your CockroachDB Cloud organization.
Step 1. Create a new GCP project
Provision a fresh GCP project dedicated to CockroachDB infrastructure. The project configuration for BYOC requires you to grant Cockroach Labs permissions to access and modify resources in this project, so this step is necessary to isolate these permissions from non-CockroachDB Cloud resources. This project can be reused for multiple CockroachDB clusters. The following requirements apply to the GCP project used for your BYOC deployment:- The project ID must not begin with the reserved prefix
crl-. - Enable the Service Usage API and the Cloud Resource Manager APIs for this project. Cockroach Labs will enable additional APIs as needed, but these two must be initialized first.
Step 2. Grant permissions to the Cockroach Labs service account
Cockroach Labs uses cross-account service account impersonation to provision and manage resources in your GCP project. This requires two GCP service accounts:- A service account owned by Cockroach Labs which must be granted roles to view and access service accounts in your GCP project.
- An intermediary service account in your GCP project which must be granted roles to create and manage infrasturcture. This service account is the target used by Cockroach Labs for cross-account impersonation, and you specify this service account when creating CockroachDB Cloud clusters in this organization.
-
Send a
GETrequest to the/v1/organizationendpoint of the similar to the following example:In the response, the value ofcockroach_cloud_service_principals.gcp.service_account_emailis the email address of the Cockroach Labs service account: - Grant this Cockroach Labs service account the following roles in the GCP IAM Console:
Service Account Token Creator (roles/iam.serviceAccountTokenCreator)View Service Accounts (roles/iam.serviceAccountViewer)
Step 3. Configure the intermediate service account
In this step, create the intermediate service account in your GCP project and grant it the necessary roles in your GCP project.This permission policy is the minimum required for Cockroach Labs to provision, operate, patch, back up, and heal your cluster over its full lifecycle. This is not a temporary permission set used only at time of creation.Do not remove, narrow, or add conditions to these permissions after setup. Many of these are exercised only during a specific lifecycle event, such as replacing a failed node, applying a patch, rotating an encryption key, or running a managed backup. These permissions are required throughout the cluster’s lifecycle. Removing a permission might not cause an immediate error. A later operation that requires it, such as replacing a failed node or running a backup, can fail. Reducing the permission set voids the availability commitment for the cluster.Guardrails that restrict the account to particular regions or services, without touching the permissions the deployment requires, are compatible. Organization policies that restrict this permission set are not supported.
- Open the GCP IAM Console.
- Create a new service account. The account’s name is arbitrary and can be whatever you want, but be sure to note down the email address of the account.
-
Grant the following IAM roles to the service account:
Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1)Compute Network Admin (roles/compute.networkAdmin)Compute Security Admin (roles/compute.securityAdmin)Kubernetes Engine Admin (roles/container.admin)Role Administrator (roles/iam.roleAdmin)Service Account Admin (roles/iam.serviceAccountAdmin)Service Account Key Admin (roles/iam.serviceAccountKeyAdmin)Service Account Token Creator (roles/iam.serviceAccountTokenCreator)Service Account User (roles/iam.serviceAccountUser)Logs Configuration Writer (roles/logging.configWriter)Project IAM Admin (roles/resourcemanager.projectIamAdmin)Project Mover (roles/resourcemanager.projectMover)Service Usage Admin (roles/serviceusage.serviceUsageAdmin)Storage Admin (roles/storage.admin)
Step 4. Create the CockroachDB Cloud cluster
In BYOC deployments, CockroachDB clusters can be deployed in the CockroachDB Cloud Console or with the .Create a cluster with the CockroachDB Cloud Console
Follow these steps to create a CockroachDB cluster in the CockroachDB Cloud console:- Open the CockroachDB Cloud and select the organization that has been enabled for BYOC.
- Click Create cluster.
- Under Select a plan, click Advanced.
- Under Cloud & Regions, click Bring Your Own Cloud and select Google Cloud.
- Under Cloud account, click Select your cloud account > Add new cloud account. Enter the service account email associated with the intermediate service account you created, not the email address of the Cockroach Labs service account.
- Follow the rest of the Create Cluster steps to configure your cluster’s regions, capacity, and features as desired. Read the documentation for more details.
Create a cluster with the CockroachDB Cloud API
Send aPOST request to the the /v1/clusters endpoint to .
The following example request creates a 3-node Advanced cluster in the us-east1 region, specifying the intermediate service account you created in the service_account_email field:
Create additional BYOC clusters
A GCP project prepared for BYOC can support multiple CockroachDB Cloud clusters. To create an additional BYOC cluster in the same account, follow the Create the CockroachDB Cloud cluster steps again.Delete a BYOC cluster
To delete a BYOC cluster, delete the cluster from the or with the . Deleting the cluster is permanent and cannot be undone. When you delete a BYOC cluster, Cockroach Labs removes the managed resources that it provisioned in your GCP project for the cluster. The intermediate service account you created during setup is not removed automatically and remains under your control. You can remove it once deletion is complete.Do not remove the intermediate service account or its permissions before deletion has finished. Cockroach Labs needs them to remove the managed resources from your GCP project. Removing access early can leave resources behind that you will need to clean up manually, and that will continue to incur charges from your cloud provider.

