Unable to connect my scala application to scylladb( scylladb pods are running on k8's)

10 views
Skip to first unread message

Asif Ullah

<ullahasif297@gmail.com>
unread,
Apr 8, 2024, 12:59:59 AMApr 8
to ScyllaDB users

I'm trying to deploy scyllaDB on kubernetes, so Have done the following steps:

here is deployment.yml:

apiVersion: apps/v1 kind: Deployment metadata: name: scylla-db spec: replicas: 1 selector: matchLabels: app: scylla-label template: metadata: labels: app: scylla-label spec: containers: - name: scylla image: scylladb/scylla:4.5.0 ports: - containerPort: 9042

Here is my service.yml:

apiVersion: v1 kind: Service metadata: name: scylla-db-service spec: type: NodePort selector: app: scylla-label ports: - protocol: TCP port: 9042 targetPort: 9042

after deploying pod and service I got:

$ kubectl get po

NAME READY STATUS RESTARTS AGE scylla-db-59bff57bbd-pjwm7 1/1 Running 0 57m

$ kubectl get svc

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE scylla-db-service NodePort 10.106.91.33 <none> 9042:31486/TCP 71m

Here is my scala code that simply build a connection with scylladb and insert data into database.

DataSchema.scala:

import com.outworkers.phantom.dsl._ abstract class DataSchema extends Table[DataSchema, DataModelClass] { override def tableName: String = "dataTable" object id extends StringColumn with PartitionKey { override def name: String = "id" } object name extends StringColumn { override def name: String = "name" } }

DB.scala:

import com.outworkers.phantom.dsl._ class DB(override val connector: CassandraConnection) extends Database[DB](connector) { object Data extends DataSchema with Connector }

ScyllaDBConnection.scala:

import com.outworkers.phantom.connectors._ import com.outworkers.phantom.dsl.CassandraConnection import com.typesafe.config.{Config, ConfigFactory} class ScyllaDBConnection { def connectionProvider: CassandraConnection = { val singleNodeIP = "10.106.91.33" val connection: CassandraConnection = ContactPoints(Seq(singleNodeIP)) .keySpace("ks") connection } }

Repository.scala:

import com.outworkers.phantom.ResultSet import com.outworkers.phantom.dsl._ import scala.concurrent.Future object Repository { val scyllaDBConnection:CassandraConnection = new ScyllaDBConnection().connectionProvider val db = new DB(scyllaDBConnection) import db.{session, space} def insertData(modelClass: DataModelClass): Future[ResultSet] = { db.Data.store(modelClass) .future() } }

Unfortunately I'm getting NoHostAvailableException.

complete error is:

15:15:21.643 [main] DEBUG com.datastax.driver.core.ControlConnection -- [Control connection] error on /10.106.91.33:9042 connection, no more host to try com.datastax.driver.core.exceptions.TransportException: [/10.106.91.33:9042] Cannot connect

What I tried

added service (scylla-db-service) name in ContactPoints instead of IP, but still getting same error.

tomas.nozicka@scylladb.com

<tomas.nozicka@scylladb.com>
unread,
Apr 16, 2024, 2:27:29 AMApr 16
to scylladb-users@googlegroups.com
Hi Asif,

it's impossible to tell from the info you've provided.

Please always collect must-gather to get help and to get all the info.

https://operator.docs.scylladb.com/v1.12/support/must-gather.html#gathering-data-with-must-gather

I'd also recommend reading these:

https://operator.docs.scylladb.com/v1.12/clients/discovery.html
https://operator.docs.scylladb.com/v1.12/clients/cql.html
https://operator.docs.scylladb.com/v1.12/exposing.html

Regards,
Tomas
> import com.outworkers.phantom.dsl._abstract class DataSchema extends
> Table[DataSchema, DataModelClass] { override def tableName: String =
> "dataTable" object id extends StringColumn with PartitionKey { override def
> name: String = "id" } object name extends StringColumn { override def name:
> String = "name" } }
> DB.scala:
> import com.outworkers.phantom.dsl._class DB(override val connector:
> --
> You received this message because you are subscribed to the Google Groups
> "ScyllaDB users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to scylladb-user...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/scylladb-users/62a64227-e7f8-4735-a826-93cdcffe65e2n%40googlegroups.com
> .

Reply all
Reply to author
Forward
0 new messages