Hello, in other thread I made I asked for the solution to a problem regarding connecting to Couchbase.
From then, I’ve experimented with other approach. Carefully following every step in Couchbase documentation, I have managed to setup a Couchbase cluster on Kubernetes.
However, I still cannot connect SDK to it. How do I run Python outside of Kubernetes and connect to the Couchbase instance hosted locally on Kubernetes cluster? Specifically, what is the “connection_string” in the standard code I post below:
connection_string = "<WHAT TO PUT THERE?>"
cluster = Cluster.connect(connection_string,
ClusterOptions(PasswordAuthenticator(os.getenv("LOGIN"), os.getenv("PASSWORD"))))
bucket = cluster.bucket('travel-sample')
coll = bucket.default_collection()
query_iter = cluster.query("SELECT * FROM `travel-sample` LIMIT 100")
for r in query_iter.rows():
print(f"Found row: {r}")
Are you running Couchbase using the Autonomous Operator? If so, there is a handy guide on connecting to the Couchbase cluster running on Kubernetes here.
Essentially, it depends on how you are exposing the kubernetes service to the outside world. This page explains some of the options.
@nithishr My Kubernetes setup works - when I forward the port to 8091 as in Couchbase documentation, I am able to successfully use the UI. Of course the client still doesn’t work.
To me the documentation you provided is hard to understand…I added all those things from the ** Configure Public Networking** link you sent me. I also created all those TLS certificates as in the instructions.
If I configured the public networking, shouldn’t the UI already be enabled somewhere? If so, under which address (assuming everything is default, because it is), would I access it? I still need to do this port forwarding thingy to make it work, so what was the point of this configuration?
Then I go to the first link you sent and…what do I do to make this work actually? I set everything up as default, did not change anything from the documentation.
Could you elaborate on the exact steps I’d need to take (like, really “explain like I’m five” kind of explanation)? Sorry for my lack of knowledge.
PS: Now that I think about it, there is a DNS option and I don’t have any DNS option available, I just want to run it locally. Maybe that’s also partly the reason why nothing works…I just want to be able to do this locally, any access from the public internet is not needed.
Sorry for the late response. Reading your response, there are a few things to explain. The default settings are not meant to work out of the box like the TLS & DNS settings. You need to set up your external DNS settings using your domain registration service like Route53.
If you don’t want to run it locally, you can use the DNS provided out of the box by Kubernetes for the services running on it. You can read about it here.
Essentially, the connection string from the above link depends on a few parameters like where the application is running (within the cluster, within the same namespace, etc). For example, if your application is running in the same namespace, you should be able to access it using the connection string couchbase://my-cluster-srv?network=default