cockroachdb icon indicating copy to clipboard operation
cockroachdb copied to clipboard

CockroachDB on Fly.io

Note: this app requires version 0.0.223 or greater of the Fly CLI. Run flyctl version update before you follow these instructions.

This is an example CockroachDB cluster that runs on multiple Fly.io regions.

Deploying this app is relatively simple:

  1. Clone this repository
  2. Install the fly CLI
  3. Run fly launch.
    1. Pick "yes" to copy existing configuration
    2. When it asks if you want to deploy, say no
  4. Create volumes:
    # one in Chicago
    fly volumes create cdb_data --region ord --size 10
    # one in Paris
    fly volumes create cdb_data --region cdg --size 10
    # one in Singapore
    fly volumes create cdb_data --region sin --size 10
    
  5. Deploy an empty node
    > fly deploy
    
  6. Init the cluster:
    > fly ssh console -C '/cockroach/init_cluster.sh'
    Connecting to cockroachdb-example.internal... complete
    Cluster successfully initialized
    
  7. Scale to 3 nodes
    > fly scale count 3
    Count changed to 3
    
  8. View CockroachDB status
    fly ssh console -C '/cockroach/cockroach node status --insecure'
    

Hook up Grafana

This example exports metrics for Fly.io to scrape. You can import CockroachDB's Grafana dashboards to see how your cluster is doing.