Overview
CockroachDB is a distributed SQL database that provides automatic replication, horizontal scalability, and built-in fault tolerance across multiple regions. This template deploys a multi-region CockroachDB cluster on Control Plane as a stateful workload with replica-direct load balancing. Each location runs a configurable number of replicas that discover and join one another using Control Plane’s internal DNS. On first deployment, the cluster initializes itself, creates a database and user, registers all regions, and sets the survival goal toSURVIVE REGION FAILURE.
What Gets Created
- GVC — A dedicated GVC across the specified locations.
- Stateful Workload — CockroachDB (
v25.4.0) with per-location replica scaling and replica-direct load balancing. - Volume Set — Persistent ext4 storage (general-purpose-ssd) with final snapshot creation and 7-day retention.
- Identity & Policy — An identity bound to the workload with
revealaccess to the startup and user secrets. - Secrets — A startup script for cluster join/initialization and an opaque secret for the database user credential.
Architecture
CockroachDB uses the Raft consensus protocol to replicate data across nodes. Each Control Plane location maps to a CockroachDB locality region, and replicas advertise their address via internal DNS (replica-N.WORKLOAD.LOCATION.GVC.cpln.local).
With 3 or more regions and the SURVIVE REGION FAILURE survival goal, the cluster tolerates the complete loss of one region without impacting availability.
Installation
This template has no external prerequisites. To install, follow the instructions for your preferred method:UI
Browse, install, and manage templates visually
CLI
Manage templates from your terminal
Terraform
Declare templates in your Terraform configurations
Pulumi
Declare templates in your Pulumi programs
Configuration
The defaultvalues.yaml for this template:
Locations and Replicas
Configure thegvc.locations section to control which regions the cluster spans and how many replicas run in each.
While CockroachDB can run on 2 locations, a minimum of 3 locations with 3 replicas per location is recommended. This is the minimum required for CockroachDB to survive a full region failure.
replicas to 0 suspends the workload in that location without removing it from the configuration.
Database Initialization
Thedatabase section specifies a database and user to create automatically when the cluster first initializes:
Resources and Storage
resources.cpuandresources.memoryset the CPU and memory allocated to each CockroachDB replica.volumeset.capacitysets the initial persistent volume size in GiB (minimum 10).
Internal Access
Theinternal_access section controls which workloads can reach the CockroachDB cluster internally:
| Type | Description |
|---|---|
same-gvc | Allow access from all workloads in the same GVC |
same-org | Allow access from all workloads in the same organization |
workload-list | Allow access only from specific workloads listed in workloads (can be combined with same-gvc) |
workload-list, specify each workload using its full link format:
Connecting to CockroachDB
Once deployed, the SQL interface is available on port 26257 (default). You can connect from a workload within the same GVC using:This template deploys CockroachDB in insecure mode (no TLS). It is intended for internal workloads that connect through Control Plane’s internal network.
This template creates a GVC with a default name defined in the values file. If you plan to deploy multiple instances, you must assign a unique GVC name for each deployment.