mongo not working with external access
sagarshrestha24 opened this issue · comments
What did you do to encounter the bug?
I've created a mongodb replica set with the configured horizons:
apiVersion: mongodbcommunity.mongodb.com/v1
kind: MongoDBCommunity
metadata:
name: mongodb-replica-set
spec:
members: 2
replicaSetHorizons:
- external: "mongodb-0.example.com:27017"
internal: "mongodb-replica-set-0.mongodb-replica-set-svc.default.svc.cluster.local:27017"
- external: "mongodb-1.example.com:27018"
internal: "mongodb-replica-set-1.mongodb-replica-set-svc.default.svc.cluster.local:27017"
type: ReplicaSet
version: "5.0.5"
security:
authentication:
modes: ["SCRAM"]
additionalMongodConfig:
storage.wiredTiger.engineConfig.journalCompressor: zlib
statefulSet:
spec:
template:
spec:
hostAliases:
- ip: "172.18.255.203"
hostnames:
- "mongodb-0.example.com"
- ip: "172.18.255.203"
hostnames:
- "mongodb-1.example.com"
users:
- name: admin
db: admin
passwordSecretRef: # a reference to the secret that will be used to generate the user's password
name: admin-password
roles:
- name: clusterAdmin
db: admin
- name: userAdminAnyDatabase
db: admin
- name: root
db: admin
scramCredentialsSecretName: admin-scram
but when trying to connect with mongosh , i got
Connecting to: mongodb://<credentials>@mongodb-0.example.com:27017,mongodb-1.example.com:27017/admin?authMechanism=DEFAULT&appName=mongosh+2.1.5
MongoServerSelectionError: getaddrinfo EAI_AGAIN mongodb-replica-set-0.mongodb-replica-set-svc.default.svc.cluster.local
I have tried to access from outside the cluster by adding the hostAliases which will map the ip with domain , but also i got same error.
When i tried with one host it will connect but when trying the multiple host it throws above error
What did you expect?
i want to access mongo replica set from outside with multiple host.