Mongodb string connection to pod

4/5/2020

I'm trying to install the countly application on k8s. Countly needs mongodb to be able to write the data and I'm trying to configure the connection string.

      - name: COUNTLY_CONFIG_API_MONGODB
        value: "mongodb://mongo-mongodb-statefulset.mongo-mongodb-statefulset:27017/countly?mongodb-0"

currently when i going to see the log on the mongodb pod it said waiting for connections on port 27017

however when i watch the log on the countly pod i got

2020-04-05T21:52:10.289Z: ERROR [db:read]   Error reading plugins {"name":"findOne","args":[{"_id":"plugins"},null]} MongoParseError: Incomplete key value pair for option {"name":"MongoParseError"}
2020-04-05T21:52:10.290Z: ERROR [db:read]   Error reading plugins {"name":"findOne","args":[{"_id":"plugins"},null]} MongoParseError: Incomplete key value pair for option {"name":"MongoParseError"}
2020-04-05T21:52:10.290Z: ERROR [db:write]  Error writing sessions_ {"name":"replaceOne","args":[{"_id":"16aCG-ceXPidlM5yDvoJn4wBRQGTy"},{"_id":"16aCG-ceXPidlM5yDvoJn4wBRQGTy","session":"{\"cookie\":{\"originalMaxAge\":86400000,\"expires\":\"2020-04-06T21:52:10.290Z\",\"secure\":false,\"httpOnly\":true,\"path\":\"/\"},\"csrfSecret\":\"NmOJ6Tki4LKeonLCborIYVxL\"}","expires":"2020-04-06T21:52:10.290Z"},{"upsert":true},null]} MongoParseError: Incomplete key value pair for option {"name":"MongoParseError"}
MongoParseError: Incomplete key value pair for option

do you know how i can test my connection string ?

i'dont have access to a terminal :(

-- morla
countly-analytics
google-kubernetes-engine
kubernetes
kubernetes-pod
mongodb

3 Answers

4/5/2020

Do you have a MongoDB instance running? The Mongo URL doesn't look like a valid URL (unlikely namespace name). If you don't have a mongo instance, create a Deploymant and Service using

kubectl create deploy mymongodb --image=mongo
kubectl create service clusterip mymongodb --tcp=27017

The MongoDB intance should be available at

mongodb://mymongodb:27017

For serious use cases, adjust Deployment manifest with auth, etc. or use Helm chart.

-- moazzem
Source: StackOverflow

4/8/2020

i fix my issue with the mongo string connection : .

"mongodb://mongo-0.mongo,mongo-1.mongo:27017/dbname_?"

i hope this will help someone

-- morla
Source: StackOverflow

4/7/2020

The error says Incomplete key value pair for option, that's because you have ?mongodb-0 in the end which is treated as a key, but it doesn't have a value. Just remove it and it should work assuming the address itself is valid.

-- Artem
Source: StackOverflow