bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.97k stars 9.2k forks source link

Can't connect to mongodb when in replicaset mode installed locally #6290

Closed justinmchase closed 3 years ago

justinmchase commented 3 years ago

Which chart:

Describe the bug When I set the chart into replicaset mode I cannot connect from mongo compass to my server any longer. I'm running in docker-desktop.

To Reproduce Steps to reproduce the behavior:

  1. Install chart
    
    export MONGODB_ROOT_PASSWORD=test123
    export MONGODB_REPLICA_SET_KEY=test123
    helm upgrade \
    --install \
    --set architecture=replicaset \
    --set auth.rootPassword=$MONGODB_ROOT_PASSWORD \
    --set auth.replicaSetKey=$MONGODB_REPLICA_SET_KEY \
    --set replicaCount=1 \
    --set externalAccess.enabled=true \
    mongodb bitnami/mongodb

kubectl port-forward service/mongodb-external-0 27017

2. Open MongoDB Compass, enter connection information
![image](https://user-images.githubusercontent.com/10974/117095254-7e5aa200-ad2b-11eb-896c-21ce92d0a44e.png)
![image](https://user-images.githubusercontent.com/10974/117095275-887ca080-ad2b-11eb-9702-e113148e36fb.png)
3. Press the 'Connect' button
4. Dialog hangs, timesout eventually, never connects

**Expected behavior**
I expect it to connect like normal. When not set into replicaset mode and without the 'rs0' replicaset name in the connection dialog, it connects fine.

**Version of Helm and Kubernetes**:

- Output of `helm version`:

version.BuildInfo{Version:"v3.5.4", GitCommit:"1b5edb69df3d3a08df77c9902dc17af864ff05d1", GitTreeState:"clean", GoVersion:"go1.15.11"}


- Output of `kubectl version`:

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:23:52Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:15:20Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"linux/amd64"}


**Additional context**
Just connecting to the port seems to work:
![image](https://user-images.githubusercontent.com/10974/117095456-0e98e700-ad2c-11eb-9f27-273c8462f3a7.png)

If I omit the replica set name in the connection dialog I get this error instead of a timeout:

An error occurred while loading navigation: 'not master and slaveOk=false': It is recommended to change your read preference in the connection dialog to Primary Preferred or Secondary Preferred or provide a replica set name for a full topology connection.



My pod does show a readiness probe error also, though I don't know why:
![image](https://user-images.githubusercontent.com/10974/117095619-6f282400-ad2c-11eb-948f-1d20ee1414a2.png)

The logs appear to indicate that its running fine so I don't know why the probe is showing an error.
justinmchase commented 3 years ago

Related to:

miguelaeh commented 3 years ago

Hi @justinmchase , Are you configuring the external IPs? I can see you are using localhost to connect to MongoDB. I would try the following:

  1. Deploy the chart specifying the external IPs in order to properly configure the MongoDB replicas to be accessible from the outside. Since you are using Docker Desktop you should instead use NodePort services. You may also need to set externalAccess.autoDiscovery.enabled=true for the MongoDB replicas to auto-detect the rest of the nodes.
  2. Change your connection parameters and use the NodePort service port and the docker Desktop IP.
justinmchase commented 3 years ago

I tried adding those settings:

  --set externalAccess.enabled=true \
  --set externalAccess.autoDiscovery.enabled=true \
  --set externalAccess.service.type=NodePort \
  --set externalAccess.service.nodePorts[0]='31017' \

Again, same results. I can see the port is open via http and giving that default message but trying to connect via the tool just hangs and timesout. Perhaps I'm not configuring the connection string correctly but I'm not sure.

miguelaeh commented 3 years ago

Hi @justinmchase , Could you share the connection string you are using? Apart from that, from the screenshot you shared in the first comment it seems that your MongoDB is properly exposed. Also, the replicaCount seems to be 1 while a replica set needs at least three pods to provide its benefits: https://docs.mongodb.com/manual/core/replica-set-architecture-three-members/

justinmchase commented 3 years ago

@miguelaeh

I don't have a connection string, I was trying to use that UI and I think once it connects it may give me the connection string it constructed but it doesn't seem to be working.

And yeah I'm just running this on my local machine and wanted to get access to the Change Streams feature which seems to require replica mode. I don't really care about having 3... unless its required to function at all?

miguelaeh commented 3 years ago

Hi @justinmchase , It should not be needed to use Compass to obtain a connection string, since the browser says it is properly exposed could you try creating your connection string and try to connect from your computer using the MongoDB client?

You can follow this https://docs.mongodb.com/manual/reference/connection-string/

reisang commented 1 year ago

hi @justinmchase, did you manage to get this working. I am also after the Change Stream feature and using Kind. Been searching all over with no luck.