How to connect to nodes in multiregion cluster setup in GCP


#1

Once we have the mutliregion cluster setup for GCP, can you give an example of how to connect to via a connection string to the SQL service ?

kubectl describe svc cockroachdb-public
Name: cockroachdb-public
Namespace: default
Labels:
Annotations: kubectl.kubernetes.io/last-applied-configuration={“apiVersion”:“v1”,“kind”:“Service”,“metadata”:{“annotations”:{},“name”:“cockroachdb-public”,“namespace”:“default”},“spec”:{“externalName”:"cockroachdb
Selector:
Type: ExternalName
IP:
External Name: cockroachdb-public.us-west1-a.svc.cluster.local
Session Affinity: None
Events:
VIGANAPA-M-2492:multicluster viganapa$

I am looking to do something like this:
sql -h host -d bank -u from the shell on my laptop.


(Tim O'Brien) #2

Hi @V4s,

Assuming an insecure cluster, you should be able to connect from the command line by running kubectl exec -it <podname> -- ./cockroach sql --insecure --host=cockroachdb-public. We have similar examples in our kubernetes orchestration docs. Does that help answer your question?


#3

Thanks Tim,
My set up is a secure one. Yes, the docs give us a way to connect to SQL cmdline by launching a client pod inside the cluster.
I want to connect the SQL shell from my laptop as follows.

sql -h host -d bank -u --cert-dir=<>

Is there a way to connect to the cockroachDB containers from the laptop?