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: 9042Here 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: 9042after 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 71mHere 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 connectWhat I tried
added service (scylla-db-service) name in ContactPoints instead of IP, but still getting same error.