Unable to connect to couchbase server CE from Java SDK on Google Kubernetes Engine (GKE)

We have created one spring boot microservice and trying to connect to couchbase CE Server which has been deployed as a LoadBalancer service in Google kubernetes Engine both in the same cluster.

Couchbase service:

apiVersion: v1
kind: Service
    app: couchbase
  name: couchbase-service
    - port: 8091
      name: high
      protocol: TCP
      targetPort: 8091
  type: LoadBalancer
    app: couchbase
  #clusterIP: None

Microservice deployment:

apiVersion: v1 # Kubernetes API version
kind: Service # Kubernetes resource kind we are creating
metadata: # Metadata of the resource kind we are creating
  name: eis-mock
    app: eis-mock
    - protocol: "TCP"
      port: 8080 # The port that the service is running on in the cluster
      targetPort: 8080 # The port exposed by the service
  type: LoadBalancer

Now from the microservice we are connecting to couchbase with the following piece of code:

Cluster cluster = Cluster.connect(“couchbase://” + connectionString, username, password);
// Get a bucket, scope and collection reference
Bucket bucket = cluster.bucket(bucketName);
Scope scope = bucket.scope(scopeName);
Collection collection = scope.collection(collectionName);

When microservice and couchbase (installed using docker) are both in the local system (in this case the connectionString is “localhost”), we are able to connect to couchbase successfully.

But when both microservice and couchbase are installed on Google Kubernetes Engine (GKE),(in this case the connectionString is the IP of the couchbase server), we are not able to connect and are getting the TimeoutException. We tried increasing the time also but eventually it failed giving the same exception.

Please advice if we are missing on something.

Make sure all the couchbase ports are mapped and accessible Couchbase Server Ports | Couchbase Docs

Yes, it was the ports issue. It worked after all the couchbase ports. Thanks.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.