Hello all,
recently I installed via mongodb operator the mongodb replicaset database.
What I’m not able to do is to connectl from a client to the dataabse.
It is not clera to me if is it necessary to create a specific service and if, how to create it.
Inside the kubernetes cluster the connection works well.
This is an example :
This are the two service I have into my cluster:
root@kubemaster:~/no_helm_mongoDB_under_kubernetes# kubectl get svc -n mongodb
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
example-mongodb-svc ClusterIP None 27017/TCP 27h
mongodb-external LoadBalancer 10.104.139.25 192.168.1.210 27017:32666/TCP 23m
I created mongodb-external and it work inside the cluster.
root@mongo-shell:/# mongosh mongodb://gabriele:gabriele@192.168.1.210:27017/?replicaSet=example-mongodb
Current Mongosh Log ID: 671a043c18cfdd4969fe6910
Connecting to: mongodb://@192.168.1.210:27017/?replicaSet=example-mongodb&appName=mongosh+2.3.2
Using MongoDB: 6.0.5
Using Mongosh: 2.3.2
For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/
The server generated these startup warnings when booting
2024-10-23T04:33:55.818+00:00: vm.max_map_count is too low
example-mongodb [primary] test>
but from an external client I receive following error:
Please enter a MongoDB connection string (Default: mongodb://localhost/): mongodb://gabriele:gabriele@192.168.1.210:27017/?replicaSet=example-mongodb
mongodb://gabriele:gabriele@192.168.1.210:27017/?replicaSet=example-mongodb
Current Mongosh Log ID: 671a04c0e1ea13956e86b01c
Connecting to: mongodb://@192.168.1.210:27017/?replicaSet=example-mongodb&appName=mongosh+2.3.2
MongoNetworkError: getaddrinfo ENOTFOUND example-mongodb-0.example-mongodb-svc.mongodb.svc.cluster.local
Press any key to exit:
Someone can hellp me please and explain what is it necessary to do to access to the database from the external?
thanks
Gabriele