Home > Software engineering >  How do I access a DSE cluster from an app running in a Kubernetes cluster?
How do I access a DSE cluster from an app running in a Kubernetes cluster?

Time:07-17

I have a provided Cassandra Database installation on a server.

On the other hand my customer has a Kubernetes Cluster with a deployed application that needs to connect to the database and we expirience the following error when the container tries to start up.

WARN  [com.dat.oss.dri.int.cor.con.ControlConnection] (vert.x-eventloop-thread-1) [s0] Error connecting to Node(endPoint=cassandra:9042, hostId=null, hashCode=379c44fa), trying next node (UnknownHostException: cassandra: Temporary failure in name resolution)

An suggestions what I am missing or what I need to do in my cluster?

CodePudding user response:

Do you have DNS setup where the Cassandra service is available to the k8s cluster through a DNS name cassandra? Since this is an outside component, k8s relies on your external DNS resolution to discover this service.

Notice it is attempting to connect to a URL cassandra:9042. This means k8s should be able to resolve the hostname cassandra somehow, internally or externally.

If not, you have to determine your service URL, like <some-IP>:<some-Port>/some_endpoint and provide this to your k8s application, which will connect with it directly.

CodePudding user response:

The issue is that you haven't configured the correct contact points in your application. In the error you posted, your application is connecting to an unknown host cassandra:

... Error connecting to Node(endPoint=cassandra:9042, ...

but your app doesn't know how to resolve the hostname cassandra leading to:

UnknownHostException: cassandra: Temporary failure in name resolution

We recommend that you specify at least two IP addresses of nodes in the "local DC" as contact points. For example if you're using the Java driver to connect to your Cassandra cluster, configure the contact points with:

datastax-java-driver {
  basic {
    contact-points = [ "node_IP1:9042", "node_IP2:9042" ]
  }
}

Since your application is running in Kubernetes, you'll need to make sure that it has network connectivity to your Cassandra cluster. Cheers!

  • Related