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
metadata:
labels:
app: couchbase
name: couchbase-service
spec:
ports:
- port: 8091
name: high
protocol: TCP
targetPort: 8091
type: LoadBalancer
selector:
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
spec:
selector:
app: eis-mock
ports:
- 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);
bucket.waitUntilReady(Duration.ofSeconds(10));
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.