Connect JetBrains DataGrip to a Secure CockroachDB Cluster Running in Docker
See the process of using a multi-node CockroachDB cluster running in Docker, a load balancer container based on HAProxy and an early access version of DataGrip.
Join the DZone community and get the full member experience.Join For Free
CockroachDB is a cloud-native SQL database for building global, scalable cloud services that survive disasters. CockroachDB is built with containers as a first-class citizen. It works well in baremetal, VM, and container environments like Kubernetes, Docker Swarm, and HashiCorp Nomad. One of my customers has a requirement to connect JetBrains DataGrip to a secure cluster. This short tutorial will step through the process of wiring this together using a multi-node CockroachDB cluster running in Docker, a load balancer container based on HAProxy and an early access version of DataGrip.
- Start a three-node CockroachDB cluster in Docker
- Connect DataGrip to the secure cluster
- Verify Setup
- Clean up
If you're following my repo, issue the following command to start
After a short while, the cluster will be up. At this point, you can follow the excellent DataGrip tutorial to connect Docker to DataGrip. After you're done setting up DataGrip for Docker, you can view your running Docker deployment in DataGrip.
At this point, you should be able to create a new datasource for CockroachDB. Fill out the properties as shown below.
If you're using a secure cluster, you need to download the certs from the cluster to your host. My
up.sh helper script downloads the certs to the current project directory automatically. I generate certs for a
root as well as
roach user. You can use either one. Additionally, notice I'm using port
26000 instead of default
26257, I'm exposing the load balancer port at port 26000 to emphasize the connection is indeed coming from a load balancer. When complete, do not click apply as we still need to fill out the SSL Tab.
docker cp roach-0:/certs .
Point the certs to the directory where your certs are located.
DataGrip has native support for CockroachDB and auto-detects a supported CockroachDB version, notice the version next to
Test Connection button. We can safely test the connection or hit
Apply to save the configuration.
Additionally, DataGrip supports CockroachDB syntax with IntelliSense. It makes working with CockroachDB so much better!
If you followed the CockroachDB docs to spin up a cluster, use these instructions to clean up. If you followed my repo, then issue:
Published at DZone with permission of Artem Ervits. See the original article here.
Opinions expressed by DZone contributors are their own.